From 99bae4a7a7d1209772562bc25cceda62bcd60aee Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sun, 12 Jun 2022 23:35:20 +0200 Subject: [PATCH] Add tests for adding blocked users to lists --- spec/controllers/ajax/list_controller_spec.rb | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/spec/controllers/ajax/list_controller_spec.rb b/spec/controllers/ajax/list_controller_spec.rb index 4c5bb134..0a9d0c62 100644 --- a/spec/controllers/ajax/list_controller_spec.rb +++ b/spec/controllers/ajax/list_controller_spec.rb @@ -325,6 +325,38 @@ describe Ajax::ListController, :ajax_controller, type: :controller do end end + context "when the target user is blocking the current user" do + let(:members) { [user] } + let(:add_param) { "add" } + let(:expected_response) do + { + "success" => false, + "status" => "other_blocking_self", + "message" => anything, + } + end + + it "does not add the user to the list" do + expect { subject }.not_to(change { list.members }) + end + end + + context "when the user being added is blocking the current user" do + let(:members) { [user] } + let(:add_param) { "add" } + let(:expected_response) do + { + "success" => false, + "status" => "self_blocking_other", + "message" => anything, + } + end + + it "does not add the user to the list" do + expect { subject }.not_to(change { list.members }) + end + end + context "when user is not signed in" do let(:add_param) { "whatever" } let(:expected_response) do