Skip to content

Commit

Permalink
通知のテストを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
motohiro-mm committed Jul 1, 2024
1 parent 43c83f8 commit 9643988
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions test/system/notification/articles_test.rb
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

0 comments on commit 9643988

Please sign in to comment.