Skip to content

Commit

Permalink
通知をしない場合のテストも追加
Browse files Browse the repository at this point in the history
  • Loading branch information
monyatto committed Jul 28, 2023
1 parent 938d869 commit fa8acf5
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions test/models/product_update_notifier_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,54 @@ class ProductUpdateNotifierTest < ActiveSupport::TestCase
assert_equal product.checker_id, notification.user_id
assert_equal "#{product.user.login_name}さんの提出物が更新されました", notification.message
end

test 'does not notify when product is wip' do
product = Product.new(
body: 'test',
user: users(:hajime),
practice: practices(:practice1),
checker_id: users(:komagata).id,
wip: true
)
product.save!

assert_difference 'Notification.count', 0 do
perform_enqueued_jobs do
ProductUpdateNotifier.new.call({ product:, current_user: product.user })
end
end
end

test 'does not notify when checker_id is nil' do
product = Product.new(
body: 'test',
user: users(:hajime),
practice: practices(:practice1),
checker_id: users(:komagata).id,
wip: true
)
product.save!

assert_difference 'Notification.count', 0 do
perform_enqueued_jobs do
ProductUpdateNotifier.new.call({ product:, current_user: product.user })
end
end
end

test 'does not notify when current_user is admin or mentor' do
product = Product.new(
body: 'test',
user: users(:hajime),
practice: practices(:practice1),
checker_id: users(:komagata).id
)
product.save!

assert_difference 'Notification.count', 0 do
perform_enqueued_jobs do
ProductUpdateNotifier.new.call({ product:, current_user: users(:mentormentaro) })
end
end
end
end

0 comments on commit fa8acf5

Please sign in to comment.