diff --git a/test/models/product_update_notifier_test.rb b/test/models/product_update_notifier_test.rb index 9cc58dd0ed8..d8aa3ec6239 100644 --- a/test/models/product_update_notifier_test.rb +++ b/test/models/product_update_notifier_test.rb @@ -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