Add tests for mute relationship and notification behaviour
This commit is contained in:
parent
744724bc3a
commit
7afff7884e
|
@ -105,6 +105,29 @@ describe Ajax::AnswerController, :ajax_controller, type: :controller do
|
||||||
|
|
||||||
it_behaves_like "fails when answer content is empty"
|
it_behaves_like "fails when answer content is empty"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when the question author mutes the user" do
|
||||||
|
let(:inbox_user) { user }
|
||||||
|
let(:expected_response) do
|
||||||
|
{
|
||||||
|
"success" => true,
|
||||||
|
"status" => "okay",
|
||||||
|
"message" => anything
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
question.user.mute(inbox_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
include_examples "creates the answer"
|
||||||
|
|
||||||
|
it_behaves_like "fails when answer content is empty"
|
||||||
|
|
||||||
|
it "does not create a notification for the question author" do
|
||||||
|
expect{ subject }.to change { question.user.notifications.count }.by(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when inbox is false" do
|
context "when inbox is false" do
|
||||||
|
|
|
@ -100,6 +100,28 @@ describe Ajax::CommentController, :ajax_controller, type: :controller do
|
||||||
|
|
||||||
include_examples "does not create the comment"
|
include_examples "does not create the comment"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when the answer author is muting the user" do
|
||||||
|
before do
|
||||||
|
answer.user.mute(user)
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:expected_response) do
|
||||||
|
{
|
||||||
|
"success" => true,
|
||||||
|
"status" => "okay",
|
||||||
|
"message" => anything,
|
||||||
|
"render" => anything,
|
||||||
|
"count" => 1
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
include_examples "creates the comment"
|
||||||
|
|
||||||
|
it "does not create a notification for the author" do
|
||||||
|
expect{ subject }.to change { answer.user.notifications.count }.by(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when answer does not exist" do
|
context "when answer does not exist" do
|
||||||
|
|
|
@ -155,6 +155,24 @@ describe Ajax::QuestionController, :ajax_controller, type: :controller do
|
||||||
include_examples "does not create the question", check_for_inbox: false
|
include_examples "does not create the question", check_for_inbox: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when the sender is muted by the user" do
|
||||||
|
before(:each) do
|
||||||
|
target_user.mute(user)
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:anonymous_question) { "false" }
|
||||||
|
let(:user_allows_anonymous_questions) { true }
|
||||||
|
let(:expected_response) do
|
||||||
|
{
|
||||||
|
"success" => true,
|
||||||
|
"status" => "okay",
|
||||||
|
"message" => anything
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
include_examples "creates the question but doesn't send it to the user's inbox"
|
||||||
|
end
|
||||||
|
|
||||||
context "when the sender is blocking the user" do
|
context "when the sender is blocking the user" do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
user.block(target_user)
|
user.block(target_user)
|
||||||
|
|
|
@ -54,6 +54,16 @@ describe Ajax::RelationshipController, type: :controller do
|
||||||
let(:type) { "follow" }
|
let(:type) { "follow" }
|
||||||
|
|
||||||
include_examples "valid relationship type"
|
include_examples "valid relationship type"
|
||||||
|
|
||||||
|
context "target user mutes source user" do
|
||||||
|
before do
|
||||||
|
user2.mute(user)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "creates the relationship but no notification" do
|
||||||
|
expect { subject }.to change { Notification.count }.by(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "type = 'block'" do
|
context "type = 'block'" do
|
||||||
|
@ -62,6 +72,12 @@ describe Ajax::RelationshipController, type: :controller do
|
||||||
include_examples "valid relationship type"
|
include_examples "valid relationship type"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "type = 'mute'" do
|
||||||
|
let(:type) { "mute" }
|
||||||
|
|
||||||
|
include_examples "valid relationship type"
|
||||||
|
end
|
||||||
|
|
||||||
context "type = 'dick'" do
|
context "type = 'dick'" do
|
||||||
let(:type) { "dick" }
|
let(:type) { "dick" }
|
||||||
|
|
||||||
|
@ -121,6 +137,12 @@ describe Ajax::RelationshipController, type: :controller do
|
||||||
include_examples "valid relationship type"
|
include_examples "valid relationship type"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "type = 'mute'" do
|
||||||
|
let(:type) { "mute" }
|
||||||
|
|
||||||
|
include_examples "valid relationship type"
|
||||||
|
end
|
||||||
|
|
||||||
context "type = 'dick'" do
|
context "type = 'dick'" do
|
||||||
let(:type) { "dick" }
|
let(:type) { "dick" }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue