Skip to content

Commit

Permalink
issue 95 fix undiscard returns false unless discarded?
Browse files Browse the repository at this point in the history
  • Loading branch information
chiperific committed Aug 17, 2023
1 parent 534739e commit fee0bc0
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 fee0bc0

Please sign in to comment.