diff --git a/app/workers/question_worker.rb b/app/workers/question_worker.rb index 5d10904f..969b725f 100644 --- a/app/workers/question_worker.rb +++ b/app/workers/question_worker.rb @@ -30,7 +30,7 @@ class QuestionWorker return true if follower.banned? return true if muted?(follower, question) return true if user.muting?(question.user) - return true if question.long? && !user.profile.allow_long_questions + return true if question.long? && !follower.profile.allow_long_questions false end diff --git a/spec/workers/question_worker_spec.rb b/spec/workers/question_worker_spec.rb index cf022124..8070392b 100644 --- a/spec/workers/question_worker_spec.rb +++ b/spec/workers/question_worker_spec.rb @@ -6,7 +6,8 @@ describe QuestionWorker do describe "#perform" do let(:user) { FactoryBot.create(:user) } let(:user_id) { user.id } - let(:question) { FactoryBot.create(:question, user:) } + let(:content) { Faker::Lorem.sentence } + let(:question) { FactoryBot.create(:question, content:, user:) } let(:question_id) { question.id } before do @@ -92,5 +93,20 @@ describe QuestionWorker do ) end end + + context "long question" do + let(:content) { "x" * 1000 } + + it "sends to recipients who allow long questions" do + user.followers.first.profile.update(allow_long_questions: true) + + expect { subject } + .to( + change { Inbox.where(user_id: user.followers.ids, question_id:, new: true).count } + .from(0) + .to(1) + ) + end + end end end