Merge pull request #793 from Retrospring/prevent-receiving-questions-while-banned
Prevent questions from being sent to banned users
This commit is contained in:
commit
e8437a5226
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue