From fa8acf5d518cc0a4dbcda5b8db286d254e107991 Mon Sep 17 00:00:00 2001 From: monyatto Date: Fri, 28 Jul 2023 17:44:37 +0900 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E3=82=92=E3=81=97=E3=81=AA?= =?UTF-8?q?=E3=81=84=E5=A0=B4=E5=90=88=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=82=82=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/models/product_update_notifier_test.rb | 50 +++++++++++++++++++++ 1 file changed, 50 insertions(+) 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