1 # frozen_string_literal: true
3 require "factory_bot_rails"
5 class UserMailerPreview < ActionMailer::Preview
6 include FactoryBot::Syntax::Methods
8 # Wraps the preview in a transaction, so that no changes
9 # are persisted to the development db
12 ActiveRecord::Base.transaction do
14 raise ActiveRecord::Rollback
20 user = create(:user, :languages => [I18n.locale])
21 token = "token-123456"
22 UserMailer.signup_confirm(user, token)
26 user = create(:user, :languages => [I18n.locale], :new_email => "newemail@example.com")
27 token = "token-123456"
28 UserMailer.email_confirm(user, token)
32 user = create(:user, :languages => [I18n.locale])
33 token = "token-123456"
34 UserMailer.lost_password(user, token)
38 user = create(:user, :languages => [I18n.locale])
39 trace = create(:trace, :user => user)
40 UserMailer.gpx_success(trace, trace.size + 2)
44 user = create(:user, :languages => [I18n.locale])
45 trace = create(:trace, :user => user)
47 LibXML::XML::Parser.string("<gpx>").parse
48 rescue LibXML::XML::Error => e
51 UserMailer.gpx_failure(trace, error)
54 def message_notification
55 recipient = create(:user, :languages => [I18n.locale])
56 message = create(:message, :recipient => recipient)
57 UserMailer.message_notification(message)
60 def diary_comment_notification
61 recipient = create(:user, :languages => [I18n.locale])
62 diary_entry = create(:diary_entry)
63 diary_comment = create(:diary_comment, :diary_entry => diary_entry)
64 UserMailer.diary_comment_notification(diary_comment, recipient)
67 def follow_notification
68 following = create(:user, :languages => [I18n.locale])
69 follow = create(:follow, :following => following)
70 UserMailer.follow_notification(follow)
73 def note_comment_notification
74 recipient = create(:user, :languages => [I18n.locale])
75 commenter = create(:user)
76 comment = create(:note_comment, :author => commenter)
77 UserMailer.note_comment_notification(comment, recipient)
80 def changeset_comment_notification
81 recipient = create(:user, :languages => [I18n.locale])
82 comment = create(:changeset_comment)
83 UserMailer.changeset_comment_notification(comment, recipient)