From dd8f51160fd191bcca171f98de22e349bbc8c8b8 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Tue, 7 Feb 2023 22:56:41 +0100 Subject: [PATCH] Add test for unpinning when the answer is not pinned --- spec/lib/use_case/answer/unpin_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/lib/use_case/answer/unpin_spec.rb b/spec/lib/use_case/answer/unpin_spec.rb index b6f5ea9c..f4d7a3cb 100644 --- a/spec/lib/use_case/answer/unpin_spec.rb +++ b/spec/lib/use_case/answer/unpin_spec.rb @@ -17,6 +17,15 @@ describe UseCase::Answer::Unpin do it "unpins the answer" do expect { subject }.to change { answer.pinned_at }.from(pinned_at).to(nil) end + + context "answer is already unpinned" do + let(:pinned_at) { nil } + + it "raises an error" do + expect { subject }.to raise_error(Errors::BadRequest) + expect(answer.reload.pinned_at).to eq(nil) + end + end end context "as other user" do