Prevent other user's anon blocks from affecting each other
This commit is contained in:
parent
abd07373e3
commit
41e476a2f7
|
@ -83,8 +83,8 @@ class Ajax::QuestionController < AjaxController
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
unless MuteRule.where(user: target_user).any? { |rule| rule.applies_to? question } ||
|
unless target_user.mute_rules.any? { |rule| rule.applies_to? question } ||
|
||||||
(author_is_anonymous && AnonymousBlock.where(identifier: AnonymousBlock.get_identifier(request.ip)).any?)
|
(author_is_anonymous && target_user.anonymous_blocks.where(identifier: AnonymousBlock.get_identifier(request.ip)).any?)
|
||||||
Inbox.create!(user_id: target_user.id, question_id: question.id, new: true)
|
Inbox.create!(user_id: target_user.id, question_id: question.id, new: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -274,6 +274,24 @@ describe Ajax::QuestionController, :ajax_controller, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when the sender is blocked by another user" do
|
||||||
|
let(:user_allows_anonymous_questions) { true }
|
||||||
|
let(:expected_question_user) { nil }
|
||||||
|
let(:expected_question_direct) { true }
|
||||||
|
|
||||||
|
before do
|
||||||
|
identifier = AnonymousBlock.get_identifier("0.0.0.0")
|
||||||
|
dummy_question = FactoryBot.create(:question, author_is_anonymous: true, author_identifier: identifier)
|
||||||
|
AnonymousBlock.create(
|
||||||
|
user: FactoryBot.create(:user),
|
||||||
|
identifier: identifier,
|
||||||
|
question: dummy_question
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
include_examples "creates the question"
|
||||||
|
end
|
||||||
|
|
||||||
context "when user does not allow anonymous questions" do
|
context "when user does not allow anonymous questions" do
|
||||||
let(:user_allows_anonymous_questions) { false }
|
let(:user_allows_anonymous_questions) { false }
|
||||||
let(:expected_response) do
|
let(:expected_response) do
|
||||||
|
|
Loading…
Reference in New Issue