diff --git a/spec/controllers/ajax/answer_controller_spec.rb b/spec/controllers/ajax/answer_controller_spec.rb index fc5abe9a..1e3c7fb4 100644 --- a/spec/controllers/ajax/answer_controller_spec.rb +++ b/spec/controllers/ajax/answer_controller_spec.rb @@ -105,6 +105,29 @@ describe Ajax::AnswerController, :ajax_controller, type: :controller do it_behaves_like "fails when answer content is empty" 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 context "when inbox is false" do diff --git a/spec/controllers/ajax/comment_controller_spec.rb b/spec/controllers/ajax/comment_controller_spec.rb index 332659dd..54b8b5fa 100644 --- a/spec/controllers/ajax/comment_controller_spec.rb +++ b/spec/controllers/ajax/comment_controller_spec.rb @@ -100,6 +100,28 @@ describe Ajax::CommentController, :ajax_controller, type: :controller do include_examples "does not create the comment" 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 context "when answer does not exist" do diff --git a/spec/controllers/ajax/question_controller_spec.rb b/spec/controllers/ajax/question_controller_spec.rb index cbb1a0f1..021a4172 100644 --- a/spec/controllers/ajax/question_controller_spec.rb +++ b/spec/controllers/ajax/question_controller_spec.rb @@ -155,6 +155,24 @@ describe Ajax::QuestionController, :ajax_controller, type: :controller do include_examples "does not create the question", check_for_inbox: false 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 before(:each) do user.block(target_user) diff --git a/spec/controllers/ajax/relationship_controller_spec.rb b/spec/controllers/ajax/relationship_controller_spec.rb index 40be8626..11d2ddbd 100644 --- a/spec/controllers/ajax/relationship_controller_spec.rb +++ b/spec/controllers/ajax/relationship_controller_spec.rb @@ -54,6 +54,16 @@ describe Ajax::RelationshipController, type: :controller do let(:type) { "follow" } 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 context "type = 'block'" do @@ -62,6 +72,12 @@ describe Ajax::RelationshipController, type: :controller do include_examples "valid relationship type" end + context "type = 'mute'" do + let(:type) { "mute" } + + include_examples "valid relationship type" + end + context "type = 'dick'" do let(:type) { "dick" } @@ -121,6 +137,12 @@ describe Ajax::RelationshipController, type: :controller do include_examples "valid relationship type" end + context "type = 'mute'" do + let(:type) { "mute" } + + include_examples "valid relationship type" + end + context "type = 'dick'" do let(:type) { "dick" }