Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into ApplicationRecord-s…
Browse files Browse the repository at this point in the history
…upport

* origin/master:
  fix README for archived calls' outputs, assert more specifically in the tests that #archived? is returning booleans
  #archived? should return a true/false, instead of truthy/nil
  • Loading branch information
janxious committed Apr 4, 2016
2 parents a1e8c85 + 0ad256d commit 9267924
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* add rails 5 support
* remove a bunch of deprecations
* improve compatibility with various new versions of software like mysql when testing
* make `#archived?` return an actual boolean value

## 0.6.1
* Fix deprecation warnings on Rails 4.1
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ i.e. `rails g migration AddAAAToPost archive_number archived_at:datetime`

Any dependent-destroy AAA model associated to an AAA model will be archived with its parent.

_If you're stuck on Rails 3.0x/2, check out the available branches, which are no longer in active development._
_If you're stuck on Rails 3x/2x, check out the available branches, which are no longer in active development._

## Example

Expand All @@ -52,7 +52,7 @@ end
h = Hole.create #
h.archived? # => false
h.archive # => true
h.archived? # => "b56876de48a5dcfe71b2c13eec15e4a2"
h.archived? # => true
h.archive_number # => "b56876de48a5dcfe71b2c13eec15e4a2"
h.archived_at # => Thu, 01 Jan 2012 01:49:21 -0400
h.unarchive # => true
Expand All @@ -69,7 +69,7 @@ r = h.rats.create #
h.archive # => true
h.archive_number # => "b56876de48a5dcfe71b2c13eec15e4a2"
r.archive_number # => "b56876de48a5dcfe71b2c13eec15e4a2"
r.archived? # => "b56876de48a5dcfe71b2c13eec15e4a2"
r.archived? # => true
h.unarchive # => true
h.archive_number # => nil
r.archive_number # => nil
Expand Down
2 changes: 1 addition & 1 deletion lib/expected_behavior/acts_as_archival.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def raise_if_not_archival
end

def archived?
self.archived_at? && self.archive_number
!!(self.archived_at? && self.archive_number)
end

def archive(head_archive_number=nil)
Expand Down
4 changes: 2 additions & 2 deletions test/basic_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ class BasicTest < ActiveSupport::TestCase
test "archive archives the record" do
archival = Archival.create!
archival.archive
assert archival.reload.archived?
assert_equal true, archival.reload.archived?
end

test "unarchive unarchives archival records" do
archival = Archival.create!(:archived_at => Time.now, :archive_number => 1)
archival.unarchive
assert_not archival.reload.archived?
assert_equal false, archival.reload.archived?
end

test "archive returns true on success" do
Expand Down

0 comments on commit 9267924

Please sign in to comment.