Apply anonymous blocks without an owner as global

This commit is contained in:
Karina Kwiatek 2022-08-12 11:54:00 +02:00
parent 0bbb435858
commit 74e309e9fc
2 changed files with 13 additions and 1 deletions

View File

@ -72,7 +72,7 @@ module UseCase
def filtered?(question)
target_user.mute_rules.any? { |rule| rule.applies_to? question } ||
(anonymous && target_user.anonymous_blocks.where(identifier: question.author_identifier).any?)
(anonymous && AnonymousBlock.where(identifier: question.author_identifier, user_id: [target_user.id, nil]).any?)
end
def source_user

View File

@ -79,6 +79,18 @@ describe UseCase::Question::Create do
it_behaves_like "creates the question", false
end
context "question is from an anon who is blocked globally" do
before do
AnonymousBlock.create!(
identifier: author_identifier,
question_id: FactoryBot.create(:question).id,
user_id: nil
)
end
it_behaves_like "creates the question", false
end
end
context "user signed in" do