diff --git a/app/workers/question_worker.rb b/app/workers/question_worker.rb index 0416244a..8f7823a6 100644 --- a/app/workers/question_worker.rb +++ b/app/workers/question_worker.rb @@ -12,6 +12,7 @@ class QuestionWorker question = Question.find(question_id) user.followers.each do |f| + next if f.banned? next if MuteRule.where(user: f).any? { |rule| rule.applies_to? question } Inbox.create(user_id: f.id, question_id: question_id, new: true) diff --git a/spec/workers/question_worker_spec.rb b/spec/workers/question_worker_spec.rb index 94f45a50..cafbc455 100644 --- a/spec/workers/question_worker_spec.rb +++ b/spec/workers/question_worker_spec.rb @@ -21,7 +21,7 @@ describe QuestionWorker do it "places the question in the inbox of the user's followers" do expect { subject } .to( - change { Inbox.where(user_id: user.followers.ids, question_id: question_id, new: true).count } + change { Inbox.where(user_id: user.followers.ids, question_id:, new: true).count } .from(0) .to(5) ) @@ -35,7 +35,18 @@ describe QuestionWorker do expect { subject } .to( - change { Inbox.where(user_id: user.followers.ids, question_id: question_id, new: true).count } + change { Inbox.where(user_id: user.followers.ids, question_id:, new: true).count } + .from(0) + .to(4) + ) + end + + it "does not send questions to banned users" do + user.followers.first.ban + + expect { subject } + .to( + change { Inbox.where(user_id: user.followers.ids, question_id:, new: true).count } .from(0) .to(4) )