From 3c1d1ef6f387f36e198f5dc17978b4c3e6728401 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Fri, 5 Jul 2024 16:18:21 +0100 Subject: [PATCH] Add basic NotificationMailerPreview This one is quite difficult to create stub data for. Just to get this working quickly I've directly looked up one of the fixture events to act as the Notification association. Would have used FactoryBot, but that can't build a Notification; only create, which would be annoying in development. --- .../previews/notification_mailer_preview.rb | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 spec/mailers/previews/notification_mailer_preview.rb diff --git a/spec/mailers/previews/notification_mailer_preview.rb b/spec/mailers/previews/notification_mailer_preview.rb new file mode 100644 index 0000000000..0db58e16cf --- /dev/null +++ b/spec/mailers/previews/notification_mailer_preview.rb @@ -0,0 +1,21 @@ +class NotificationMailerPreview < ActionMailer::Preview + def daily_summary + NotificationMailer.daily_summary(user, notifications) + end + + private + + def user + User.new( + name: 'Pro user', + email: 'pro@localhost' + ) + end + + # 902: useless_incoming_message_event + def notifications + [ + Notification.new(user: user, info_request_event: InfoRequestEvent.find(902)) + ] + end +end