mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 14:19:53 +01:00
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
2 changed files with 14 additions and 2 deletions
|
@ -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 a new issue