2016-07-21 19:11:15 +08:00
|
|
|
class AppMailerPreview < ActionMailer::Preview
|
|
|
|
def confirmation_instructions
|
2016-10-13 14:54:29 +08:00
|
|
|
AppMailer.confirmation_instructions(fake_user, 'faketoken', {})
|
2016-07-21 19:11:15 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def reset_password_instructions
|
2016-10-13 14:54:29 +08:00
|
|
|
AppMailer.reset_password_instructions(fake_user, 'faketoken', {})
|
2016-07-21 19:11:15 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def unlock_instructions
|
2016-10-13 14:54:29 +08:00
|
|
|
AppMailer.unlock_instructions(fake_user, 'faketoken', {})
|
2016-07-21 19:11:15 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def invitation_instructions
|
2016-10-13 14:54:29 +08:00
|
|
|
AppMailer.invitation_instructions(fake_user, 'faketoken', {})
|
|
|
|
end
|
|
|
|
|
|
|
|
def assignment_notification
|
|
|
|
AppMailer.notification(
|
|
|
|
fake_user,
|
|
|
|
Notification.new(
|
|
|
|
type_of: :assignment,
|
|
|
|
title: I18n.t(
|
2017-01-25 20:56:43 +08:00
|
|
|
'notifications.assign_user_to_team',
|
2016-10-13 14:54:29 +08:00
|
|
|
assigned_user: fake_user_2.full_name,
|
|
|
|
role: 'Administrator',
|
2017-01-25 20:56:43 +08:00
|
|
|
team: fake_team.name,
|
2016-10-13 14:54:29 +08:00
|
|
|
assigned_by_user: fake_user.full_name
|
|
|
|
),
|
|
|
|
message: ActionController::Base.helpers.sanitize(
|
2017-01-25 20:56:43 +08:00
|
|
|
"<a href='#' target='_blank'>#{fake_team.name}</a>"
|
2016-10-13 17:14:25 +08:00
|
|
|
),
|
|
|
|
generator_user: fake_user,
|
|
|
|
created_at: Time.now
|
2016-10-13 14:54:29 +08:00
|
|
|
)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def recent_changes_notification
|
2016-10-13 17:14:25 +08:00
|
|
|
user = User.first
|
|
|
|
user = fake_user if user.blank?
|
2016-10-13 14:54:29 +08:00
|
|
|
AppMailer.notification(
|
2016-10-13 17:14:25 +08:00
|
|
|
user,
|
2016-10-13 14:54:29 +08:00
|
|
|
Notification.new(
|
|
|
|
type_of: :recent_changes,
|
|
|
|
title: I18n.t(
|
|
|
|
'activities.create_module',
|
2016-10-13 17:14:25 +08:00
|
|
|
user: user.full_name,
|
2016-10-13 14:54:29 +08:00
|
|
|
module: 'How to shred'
|
|
|
|
),
|
|
|
|
message: ActionController::Base.helpers.sanitize(
|
2016-10-13 17:14:25 +08:00
|
|
|
'Project: <a href="#" target="_blank">School of Rock</a>'
|
|
|
|
),
|
|
|
|
generator_user: user,
|
|
|
|
created_at: Time.now
|
2016-10-13 14:54:29 +08:00
|
|
|
)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def system_message_notification
|
|
|
|
AppMailer.notification(
|
|
|
|
fake_user,
|
|
|
|
Notification.new(
|
|
|
|
type_of: :system_message,
|
2018-05-21 21:33:23 +08:00
|
|
|
title: 'SciNote 9.1 released!',
|
2016-10-13 17:14:25 +08:00
|
|
|
message: '<a href="#" target="_blank">View release notes</a>',
|
|
|
|
created_at: Time.now
|
2016-10-13 14:54:29 +08:00
|
|
|
)
|
|
|
|
)
|
2016-07-21 19:11:15 +08:00
|
|
|
end
|
|
|
|
|
2018-11-24 00:24:10 +08:00
|
|
|
def delivery_notification
|
|
|
|
AppMailer.notification(
|
|
|
|
fake_user,
|
|
|
|
Notification.new(
|
|
|
|
type_of: :deliver,
|
|
|
|
title: 'Your requested export package is ready!',
|
|
|
|
message: '<a href="/zip_exports/download/1" target="_blank" ' \
|
|
|
|
'data-id="1">export_YYYY-MM-DD_HH-mm-ss.zip</a>',
|
|
|
|
created_at: Time.now
|
|
|
|
)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2019-02-14 19:51:30 +08:00
|
|
|
def system_notification
|
|
|
|
sn = FactoryBot.build(:system_notification)
|
|
|
|
user = FactoryBot.build(:user)
|
|
|
|
AppMailer.system_notification(user, sn)
|
|
|
|
end
|
|
|
|
|
2016-07-21 19:11:15 +08:00
|
|
|
private
|
|
|
|
|
|
|
|
def fake_user
|
|
|
|
User.new(
|
2016-10-13 14:54:29 +08:00
|
|
|
full_name: 'Johny Cash',
|
|
|
|
initials: 'JC',
|
|
|
|
email: 'johny.cash@gmail.com',
|
2016-07-21 19:11:15 +08:00
|
|
|
created_at: Time.now,
|
|
|
|
updated_at: Time.now,
|
|
|
|
confirmed_at: Time.now
|
|
|
|
)
|
|
|
|
end
|
2016-10-13 14:54:29 +08:00
|
|
|
|
|
|
|
def fake_user_2
|
|
|
|
User.new(
|
|
|
|
full_name: 'Bob Dylan',
|
|
|
|
initials: 'BD',
|
|
|
|
email: 'bob.dylan@gmail.com',
|
|
|
|
created_at: Time.now,
|
|
|
|
updated_at: Time.now,
|
|
|
|
confirmed_at: Time.now
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2017-01-25 20:56:43 +08:00
|
|
|
def fake_team
|
|
|
|
Team.new(
|
2016-10-13 14:54:29 +08:00
|
|
|
name: 'Greatest musicians of all time'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|