diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-06-20 06:14:41 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-06-20 06:14:41 -0700 |
commit | 7c69a829a311a31109939cff19b700b36b97d5c4 (patch) | |
tree | 9d02b29c3e6d8e19a64fc82747fd9f864839759d | |
parent | 4c5e166c60615e50a4e9eab9f97c441feb5ecf6b (diff) | |
parent | 85750d43fa714f6773396b8304430f2d1f459350 (diff) | |
download | rails-7c69a829a311a31109939cff19b700b36b97d5c4.tar.gz rails-7c69a829a311a31109939cff19b700b36b97d5c4.tar.bz2 rails-7c69a829a311a31109939cff19b700b36b97d5c4.zip |
Merge pull request #11020 from fredwu/master-activemodel-inclusion-chain-fix-iii
ActiveModel::Model inclusion chain backward compatibility
-rw-r--r-- | activemodel/lib/active_model/model.rb | 2 | ||||
-rw-r--r-- | activemodel/test/cases/model_test.rb | 20 |
2 files changed, 16 insertions, 6 deletions
diff --git a/activemodel/lib/active_model/model.rb b/activemodel/lib/active_model/model.rb index 5904d686e5..f048dda5c6 100644 --- a/activemodel/lib/active_model/model.rb +++ b/activemodel/lib/active_model/model.rb @@ -80,7 +80,7 @@ module ActiveModel self.public_send("#{attr}=", value) end if params - super(*params) + super() end # Indicates if the model is persisted. Default is +false+. diff --git a/activemodel/test/cases/model_test.rb b/activemodel/test/cases/model_test.rb index 651d20b3cb..ee0fa26546 100644 --- a/activemodel/test/cases/model_test.rb +++ b/activemodel/test/cases/model_test.rb @@ -10,6 +10,7 @@ class ModelTest < ActiveModel::TestCase def initialize(*args) @attr ||= 'default value' + super end end @@ -19,8 +20,15 @@ class ModelTest < ActiveModel::TestCase attr_accessor :attr end + class BasicModelWithReversedMixins + include ActiveModel::Model + include DefaultValue + attr_accessor :attr + end + class SimpleModel include ActiveModel::Model + attr_accessor :attr end def setup @@ -32,11 +40,17 @@ class ModelTest < ActiveModel::TestCase assert_equal "value", object.attr end + def test_initialize_with_params_and_mixins_reversed + object = BasicModelWithReversedMixins.new(attr: "value") + assert_equal "value", object.attr + end + def test_initialize_with_nil_or_empty_hash_params_does_not_explode assert_nothing_raised do BasicModel.new() - BasicModel.new nil + BasicModel.new(nil) BasicModel.new({}) + SimpleModel.new(attr: 'value') end end @@ -58,8 +72,4 @@ class ModelTest < ActiveModel::TestCase def test_mixin_initializer_when_args_dont_exist assert_raises(NoMethodError) { SimpleModel.new(hello: 'world') } end - - def test_mixin_when_no_ancestors - assert SimpleModel.new - end end |