From 1e86043750015d1c0698aaf560ff917e8a6e6dc2 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Wed, 15 Jun 2022 00:15:35 +0200 Subject: [PATCH] Add tests for removing anonymous blocks --- .../ajax/anonymous_block_controller_spec.rb | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/spec/controllers/ajax/anonymous_block_controller_spec.rb b/spec/controllers/ajax/anonymous_block_controller_spec.rb index 6471d072..97537bae 100644 --- a/spec/controllers/ajax/anonymous_block_controller_spec.rb +++ b/spec/controllers/ajax/anonymous_block_controller_spec.rb @@ -54,6 +54,32 @@ describe Ajax::AnonymousBlockController, :ajax_controller, type: :controller do end describe "#destroy" do - pending + subject { delete(:destroy, params: params) } + + context "user signed in" do + let(:user) { FactoryBot.create(:user) } + + before do + sign_in(user) + end + + context "when all parameters are given" do + let(:question) { FactoryBot.create(:question, author_identifier: "someidentifier") } + let(:block) { AnonymousBlock.create(user: user, identifier: "someidentifier", question: question) } + let(:params) do + { id: block.id } + end + + let(:expected_response) do + { + "success" => true, + "status" => "okay", + "message" => anything + } + end + + include_examples "returns the expected response" + end + end end end