From fee0bc09e66c133854f65d7fa093935dc0b0bd74 Mon Sep 17 00:00:00 2001 From: Chip Date: Thu, 17 Aug 2023 13:41:58 -0400 Subject: [PATCH] issue 95 fix undiscard returns false unless discarded? --- lib/discard/model.rb | 2 +- spec/discard/model_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/discard/model.rb b/lib/discard/model.rb index 5ba0740..07d24ef 100644 --- a/lib/discard/model.rb +++ b/lib/discard/model.rb @@ -138,7 +138,7 @@ def discard! # # @return [Boolean] true if successful, otherwise false def undiscard - return unless discarded? + return false unless discarded? run_callbacks(:undiscard) do update_attribute(self.class.discard_column, nil) end diff --git a/spec/discard/model_spec.rb b/spec/discard/model_spec.rb index 40c69b3..1373f39 100644 --- a/spec/discard/model_spec.rb +++ b/spec/discard/model_spec.rb @@ -85,6 +85,10 @@ post.undiscard }.not_to change { post.reload.discarded_at } end + + it "returns false" do + expect(post.undiscard).to be false + end end describe '#undiscard!' do @@ -139,6 +143,10 @@ post.discard }.not_to change { post.reload.discarded_at } end + + it "returns false" do + expect(post.discard).to be false + end end describe '#discard!' do