]> git.openstreetmap.org Git - rails.git/blob - test/mailers/previews/user_mailer_preview.rb
Merge remote-tracking branch 'upstream/pull/6455'
[rails.git] / test / mailers / previews / user_mailer_preview.rb
1 # frozen_string_literal: true
2
3 require "factory_bot_rails"
4
5 class UserMailerPreview < ActionMailer::Preview
6   include FactoryBot::Syntax::Methods
7
8   # Wraps the preview in a transaction, so that no changes
9   # are persisted to the development db
10   def self.call(...)
11     preview = nil
12     ActiveRecord::Base.transaction do
13       preview = super(...)
14       raise ActiveRecord::Rollback
15     end
16     preview
17   end
18
19   def diary_comment_notification
20     recipient = create(:user, :languages => [I18n.locale])
21     diary_entry = create(:diary_entry)
22     diary_comment = create(:diary_comment, :diary_entry => diary_entry)
23     UserMailer.diary_comment_notification(diary_comment, recipient)
24   end
25 end