diff --git a/.gitignore b/.gitignore index ace5640e..17ef9ac2 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ vendor/* .tags_sorted_by_file .ruby-version .ruby-gemset +.rbenv-gemsets diff --git a/test/unit/model_test.rb b/test/unit/model_test.rb index f86e79e8..c40e4ff7 100644 --- a/test/unit/model_test.rb +++ b/test/unit/model_test.rb @@ -645,17 +645,28 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase assert_not_nil @wotsit.versions.last.reify.updated_at end + # Tests that it doesn't try to write created_on as an attribute just because + # a created_on method exists. + # + # - Deprecation warning in Rails 3.2 + # - ActiveModel::MissingAttributeError in Rails 4 + # + # In rails 5, `capture` is deprecated in favor of `capture_io`. + # should 'not generate warning' do - # Tests that it doesn't try to write created_on as an attribute just because a created_on - # method exists. - warnings = capture(:stderr) { # Deprecation warning in Rails 3.2 - assert_nothing_raised { # ActiveModel::MissingAttributeError in Rails 4 + assert_update_raises_nothing = -> { + assert_nothing_raised { @wotsit.update_attributes! :name => 'changed' } } + warnings = + if respond_to?(:capture_io) + capture_io { assert_update_raises_nothing.call }.last + else + capture(:stderr) { assert_update_raises_nothing.call } + end assert_equal '', warnings end - end