Re-introduce email previews that were broken
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
I was going to add the following email previews in https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/5031 but I couldn't quite get them working and it isn't really a blocker to leave them out. We should re-introduce them.
spec/mailers/previews/notify_preview.rb
def issue_moved_email
# TODO: fails to load, undefined method `id' for 320:Fixnum Did you mean? i
Notify.issue_moved_email(user.id, issue.id, issue.id, user.id).message
end
def new_gpg_key_email
cleanup do
# TODO: I am not sure how to create a GPG key that is actually persisted and has an ID
gpg_key = GpgKeys::CreateService.new(user, key: 'foo').execute
# puts "zxcv #{gpg_key.to_yaml} #{gpg_key.persisted?}"
Notify.new_gpg_key_email(gpg_key.id).message
end
end
spec/mailers/previews/abuse_report_mailer_preview.rb
class AbuseReportMailerPreview < ActionMailer::Preview
def notify
cleanup do
# TODO: I am not sure how to create a GPG key that is actually persisted and has an ID
abuse_report = AbuseReport.create(message: 'some messsage', user_id: user.id)
# puts "zxcv #{abuse_report.to_yaml} #{abuse_report.persisted?}"
AbuseReportMailer.notify(abuse_report.id).message
end
end
private
def user
@user ||= User.last
end
def cleanup
email = nil
ActiveRecord::Base.transaction do
email = yield
raise ActiveRecord::Rollback
end
email
end
end
cc @mdelaossa
Edited by 🤖 GitLab Bot 🤖