Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

お知らせのテストをリファクタリング #3994

Merged
merged 2 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/views/announcements/_form.html.slim
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
= render 'errors', object: announcement
= form_with model: announcement, local: true do |f|
= form_with model: announcement,
local: true,
html: { name: 'announcement' } do |f|
.form__items
.form-item
.row
Expand Down
22 changes: 13 additions & 9 deletions test/system/notification/announcements_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ class Notification::AnnouncementsTest < ApplicationSystemTestCase
@receiver_count = User.where(retired_on: nil).size - 1 # 送信者は除くため-1
end

test 'all menber recieve a notification when announcement posted' do
visit_with_auth '/announcements', 'komagata'
click_link 'お知らせ作成'

find("input[name='announcement[title]']").set('タイトル通知用の確認です')
find("textarea[name='announcement[description]']").set('お知らせ内容です')
find("input[value='all']", { visible: false }).set(true)
click_button '作成'
test 'all member recieve a notification when announcement posted' do
visit_with_auth '/announcements/new', 'komagata'

within 'form[name=announcement]' do
fill_in 'announcement[title]', with: 'タイトル通知用の確認です'
fill_in 'announcement[description]', with: 'お知らせ内容です'
choose '全員にお知らせ', allow_label_click: true
click_button '作成'
end

logout

visit_with_auth '/', 'sotugyou'
Expand All @@ -28,6 +30,8 @@ class Notification::AnnouncementsTest < ApplicationSystemTestCase
visit_with_auth '/', 'komagata'
refute_text @notice_text

assert_equal(@notified_count + @receiver_count, Notification.where(kind: @notice_kind).size)
expected = @notified_count + @receiver_count
actual = Notification.where(kind: @notice_kind).size
assert_equal expected, actual
end
end