Skip to content

Commit

Permalink
Merge pull request #96 from chiperific/95_undiscard_return_false
Browse files Browse the repository at this point in the history
#95 Fix `undiscard` returns false unless discarded?
  • Loading branch information
jarednorman committed Aug 17, 2023
2 parents 534739e + fee0bc0 commit 79cc5cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/discard/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions spec/discard/model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 79cc5cb

Please sign in to comment.