-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5768 from fjordllc/feature/notify-when-regular-ev…
…ents-change 定期イベントの内容が更新されたら参加者に通知する
- Loading branch information
Showing
16 changed files
with
136 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class RegularEventUpdateNotifier | ||
def call(regular_event) | ||
participants = regular_event.participants | ||
participants.each do |target| | ||
NotificationFacade.update_regular_event(regular_event, target) if regular_event.user != target | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
= render 'notification_mailer_template', title: "定期イベント【#{@regular_event.title}】の詳細が更新されました。", link_url: notification_url(@notification), link_text: '定期イベント詳細へ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
regular_event_participation1: | ||
user: hatsuno | ||
regular_event: regular_event1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -413,4 +413,24 @@ class NotificationMailerTest < ActionMailer::TestCase | |
assert_equal '[FBC] kimuraさんが休会しました。', email.subject | ||
assert_match(/休会/, email.body.to_s) | ||
end | ||
|
||
test 'update_regular_event' do | ||
regular_event = regular_events(:regular_event1) | ||
notification = notifications(:notification_regular_event_updated) | ||
mailer = NotificationMailer.with( | ||
regular_event: regular_event, | ||
receiver: notification.user | ||
).update_regular_event | ||
|
||
perform_enqueued_jobs do | ||
mailer.deliver_later | ||
end | ||
|
||
assert_not ActionMailer::Base.deliveries.empty? | ||
email = ActionMailer::Base.deliveries.last | ||
assert_equal ['[email protected]'], email.from | ||
assert_equal ['[email protected]'], email.to | ||
assert_equal '[FBC] 定期イベント【開発MTG】が更新されました。', email.subject | ||
assert_match(/定期イベント/, email.body.to_s) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'application_system_test_case' | ||
|
||
class Notification::ProductsTest < ApplicationSystemTestCase | ||
setup do | ||
@delivery_mode = AbstractNotifier.delivery_mode | ||
AbstractNotifier.delivery_mode = :normal | ||
end | ||
|
||
teardown do | ||
AbstractNotifier.delivery_mode = @delivery_mode | ||
end | ||
|
||
test 'Notify when a regular event change' do | ||
regular_event = regular_events(:regular_event1) | ||
visit_with_auth "/regular_events/#{regular_event.id}/edit", 'komagata' | ||
within('form[name=regular_event]') do | ||
fill_in('regular_event[description]', with: 'updated') | ||
end | ||
click_button '内容変更' | ||
assert_text '定期イベントを更新しました。' | ||
|
||
visit_with_auth '/notifications', 'hatsuno' | ||
within first('.card-list-item.is-unread') do | ||
assert_text "定期イベント【#{regular_event.title}】が更新されました。" | ||
end | ||
end | ||
end |