-
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 #7889 from fjordllc/bug/notify_only_when_blog_firs…
…t_published ブログを更新するたびに通知されていたバグを初回公開時のみ通知されるように修正
- Loading branch information
Showing
2 changed files
with
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'application_system_test_case' | ||
|
||
class ArticlesTest < ApplicationSystemTestCase | ||
setup do | ||
@article = articles(:article1) | ||
@delivery_mode = AbstractNotifier.delivery_mode | ||
AbstractNotifier.delivery_mode = :normal | ||
end | ||
|
||
teardown do | ||
AbstractNotifier.delivery_mode = @delivery_mode | ||
end | ||
|
||
test 'the notification is sent only when the article is first published' do | ||
visit_with_auth new_article_path, 'komagata' | ||
fill_in('article_title', with: '通知テスト1回目') | ||
fill_in('article_body', with: 'test') | ||
click_on '公開する' | ||
assert_text '記事を作成しました' | ||
|
||
visit_with_auth notifications_path, 'hajime' | ||
within first('.card-list-item.is-unread') do | ||
assert_text 'komagataさんがブログに「通知テスト1回目」を投稿しました。' | ||
end | ||
click_link '全て既読にする' | ||
|
||
visit_with_auth edit_article_path(@article), 'komagata' | ||
fill_in('article_title', with: '通知テスト2回目') | ||
click_on '更新する' | ||
|
||
visit_with_auth notifications_path, 'hajime' | ||
assert_no_selector '.card-list-item.is-unread' | ||
assert_no_text 'komagataさんがブログに「通知テスト2回目」を投稿しました。' | ||
end | ||
|
||
test 'the notification is not sent when the article with WIP is saved' do | ||
visit_with_auth new_article_path, 'komagata' | ||
fill_in('article_title', with: '通知テストwip') | ||
fill_in('article_body', with: 'test') | ||
click_on 'WIP' | ||
assert_text '記事をWIPとして保存しました' | ||
|
||
visit_with_auth notifications_path, 'hajime' | ||
assert_no_selector '.card-list-item.is-unread' | ||
assert_no_text 'komagataさんがブログに「通知テストwip」を投稿しました。' | ||
end | ||
end |