-
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 #5227 from fjordllc/feature/notify-mentor-when-new…
…-user-registers 新規ユーザー登録時にメンターにメール通知およびサイト内通知するようにした
- Loading branch information
Showing
10 changed files
with
200 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
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: "#{@sender.login_name}さんが新しく入会しました!", link_url: notification_url(@notification), link_text: "#{@sender.login_name}さんのページへ" |
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 |
---|---|---|
|
@@ -356,4 +356,32 @@ class NotificationMailerTest < ActionMailer::TestCase | |
assert_equal '[FBC] sotugyouさんが卒業しました。', email.subject | ||
assert_match(/卒業/, email.body.to_s) | ||
end | ||
|
||
test 'signed up' do | ||
user = users(:hajime) | ||
mentor = users(:mentormentaro) | ||
Notification.create!( | ||
kind: 20, | ||
sender: user, | ||
user: mentor, | ||
message: '🎉 hajimeさんが新しく入会しました!', | ||
link: "/users/#{user.id}", | ||
read: false | ||
) | ||
mailer = NotificationMailer.with( | ||
sender: user, | ||
receiver: mentor | ||
).signed_up | ||
|
||
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] hajimeさんが新しく入会しました!', 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'application_system_test_case' | ||
|
||
class Notification::SignedUpTest < ApplicationSystemTestCase | ||
setup do | ||
@delivery_mode = AbstractNotifier.delivery_mode | ||
AbstractNotifier.delivery_mode = :normal | ||
end | ||
|
||
teardown do | ||
AbstractNotifier.delivery_mode = @delivery_mode | ||
end | ||
|
||
test 'notify mentors when signed up as adviser' do | ||
visit '/users/new?role=adviser' | ||
|
||
email = '[email protected]' | ||
|
||
within 'form[name=user]' do | ||
fill_in 'user[login_name]', with: 'haruko' | ||
fill_in 'user[email]', with: email | ||
fill_in 'user[name]', with: 'テスト 春子' | ||
fill_in 'user[name_kana]', with: 'テスト ハルコ' | ||
fill_in 'user[description]', with: 'テスト春子です。' | ||
fill_in 'user[password]', with: 'testtest' | ||
fill_in 'user[password_confirmation]', with: 'testtest' | ||
find('label', text: 'アンチハラスメントポリシーに同意').click | ||
find('label', text: '利用規約に同意').click | ||
end | ||
|
||
click_button 'アドバイザー登録' | ||
assert_text 'サインアップメールをお送りしました。メールからサインアップを完了させてください。' | ||
assert User.find_by(email: email).adviser? | ||
|
||
visit_with_auth notifications_path, 'komagata' | ||
within first('.card-list-item.is-unread') do | ||
assert_selector '.card-list-item-title__link-label', text: '🎉 harukoさんが新しく入会しました!' | ||
end | ||
end | ||
|
||
test 'notify mentors when signed up as trainee' do | ||
visit '/users/new?role=trainee' | ||
|
||
email = '[email protected]' | ||
|
||
within 'form[name=user]' do | ||
fill_in 'user[login_name]', with: 'natsumi' | ||
fill_in 'user[email]', with: email | ||
fill_in 'user[name]', with: 'テスト 夏美' | ||
fill_in 'user[name_kana]', with: 'テスト ナツミ' | ||
fill_in 'user[description]', with: 'テスト夏美です。' | ||
fill_in 'user[password]', with: 'testtest' | ||
fill_in 'user[password_confirmation]', with: 'testtest' | ||
select '学生', from: 'user[job]' | ||
find('label', text: 'Mac(Apple チップ)').click | ||
select '未経験', from: 'user[experience]' | ||
first('.choices__inner').click | ||
find('.choices__list--dropdown').click | ||
find('.choices__list').click | ||
find('#choices--js-choices-single-select-item-choice-2').click | ||
find('label', text: 'アンチハラスメントポリシーに同意').click | ||
find('label', text: '利用規約に同意').click | ||
end | ||
|
||
click_button '参加する' | ||
assert_text 'サインアップメールをお送りしました。メールからサインアップを完了させてください。' | ||
assert User.find_by(email: email).trainee? | ||
|
||
visit_with_auth notifications_path, 'komagata' | ||
within first('.card-list-item.is-unread') do | ||
assert_selector '.card-list-item-title__link-label', text: '🎉 natsumiさんが新しく入会しました!' | ||
end | ||
end | ||
|
||
test 'notify mentors when signed up as normal user' do | ||
visit '/users/new' | ||
within 'form[name=user]' do | ||
fill_in 'user[login_name]', with: 'taro' | ||
fill_in 'user[email]', with: '[email protected]' | ||
fill_in 'user[name]', with: 'テスト 太郎' | ||
fill_in 'user[name_kana]', with: 'テスト タロウ' | ||
fill_in 'user[description]', with: 'テスト太郎です。' | ||
fill_in 'user[password]', with: 'testtest' | ||
fill_in 'user[password_confirmation]', with: 'testtest' | ||
fill_in 'user[after_graduation_hope]', with: '起業したいです' | ||
select '学生', from: 'user[job]' | ||
find('label', text: 'Mac(Apple チップ)').click | ||
select '未経験', from: 'user[experience]' | ||
find('label', text: 'アンチハラスメントポリシーに同意').click | ||
find('label', text: '利用規約に同意').click | ||
end | ||
|
||
fill_stripe_element('4242 4242 4242 4242', '12 / 50', '111') | ||
|
||
VCR.use_cassette 'sign_up/valid-card', vcr_options do | ||
click_button '参加する' | ||
assert_text 'サインアップメールをお送りしました。メールからサインアップを完了させてください。' | ||
end | ||
|
||
visit_with_auth notifications_path, 'komagata' | ||
within first('.card-list-item.is-unread') do | ||
assert_selector '.card-list-item-title__link-label', text: '🎉 taroさんが新しく入会しました!' | ||
end | ||
end | ||
end |