diff options
Diffstat (limited to 'activemodel/test/cases')
-rw-r--r-- | activemodel/test/cases/model_test.rb | 20 |
1 files changed, 15 insertions, 5 deletions
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 |