Add tests for answering while blocked/blocking

This commit is contained in:
Karina Kwiatek 2022-06-11 23:15:36 +02:00 committed by Karina Kwiatek
parent febbee1306
commit c6c3c32260
1 changed files with 32 additions and 0 deletions

View File

@ -139,6 +139,38 @@ describe Ajax::AnswerController, :ajax_controller, type: :controller do
include_examples "does not create the answer"
end
context "when user is blocked by the question author" do
let!(:block) { Relationships::Block.create(source_id: question.user.id, target_id: user.id) }
let(:shared_services) { %w[] }
let(:answer) { "u suck >:3" }
let(:expected_response) do
{
"success" => false,
"status" => "answering_other_blocked_self",
"message" => I18n.t("errors.answering_other_blocked_self")
}
end
include_examples "returns the expected response"
end
context "when question author is blocked by the user" do
let!(:block) { Relationships::Block.create(source_id: user.id, target_id: question.user.id) }
let(:shared_services) { %w[] }
let(:answer) { "u suck >:3" }
let(:expected_response) do
{
"success" => false,
"status" => "answering_self_blocked_other",
"message" => I18n.t("errors.answering_self_blocked_other")
}
end
include_examples "returns the expected response"
end
end
end