From 9d38292d4a055127bd4098aa735383414800c10a Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Mon, 2 Jan 2023 09:20:59 +0100 Subject: [PATCH 1/2] question/create_followers: fix incrementing asked_count --- lib/use_case/question/create_followers.rb | 2 +- spec/lib/use_case/question/create_followers_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/use_case/question/create_followers.rb b/lib/use_case/question/create_followers.rb index b74517e5..cc9d03d0 100644 --- a/lib/use_case/question/create_followers.rb +++ b/lib/use_case/question/create_followers.rb @@ -29,7 +29,7 @@ module UseCase private def increment_asked_count - source_user.increment(:asked_count) + source_user.increment!(:asked_count) end def source_user diff --git a/spec/lib/use_case/question/create_followers_spec.rb b/spec/lib/use_case/question/create_followers_spec.rb index 19e91de3..7b3e2d75 100644 --- a/spec/lib/use_case/question/create_followers_spec.rb +++ b/spec/lib/use_case/question/create_followers_spec.rb @@ -23,5 +23,9 @@ describe UseCase::Question::CreateFollowers do it "enqueues a QuestionWorker job" do expect(QuestionWorker).to have_enqueued_sidekiq_job(source_user.id, subject[:resource].id) end + + it "increments the asked count" do + expect { subject }.to change { source_user.reload.asked_count }.by(1) + end end end From 86441cda571f22f4065d5303c558b29b06e371f8 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Mon, 2 Jan 2023 09:24:34 +0100 Subject: [PATCH 2/2] rubodog --- lib/use_case/question/create_followers.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/use_case/question/create_followers.rb b/lib/use_case/question/create_followers.rb index cc9d03d0..21c2e89d 100644 --- a/lib/use_case/question/create_followers.rb +++ b/lib/use_case/question/create_followers.rb @@ -29,7 +29,8 @@ module UseCase private def increment_asked_count - source_user.increment!(:asked_count) + source_user.increment(:asked_count) + source_user.save end def source_user