Permalink
Browse files

Merge pull request #11002 from fredwu/master-activemodel-inclusion-ch…

…ain-fix

Fixed ActiveModel::Model's inclusion chain
  • Loading branch information...
2 parents 2b817a5 + e3dc10f commit 878ab18c5e6b0d9dd3c0608fc54265de4ad6665d @josevalim josevalim committed Jun 19, 2013
Showing with 14 additions and 0 deletions.
  1. +2 −0 activemodel/lib/active_model/model.rb
  2. +12 −0 activemodel/test/cases/model_test.rb
@@ -79,6 +79,8 @@ def initialize(params={})
params.each do |attr, value|
self.public_send("#{attr}=", value)
end if params
+
+ super
end
# Indicates if the model is persisted. Default is +false+.
@@ -3,7 +3,14 @@
class ModelTest < ActiveModel::TestCase
include ActiveModel::Lint::Tests
+ module DefaultValue
+ def initialize(*args)
+ @attr ||= 'default value'
+ end
+ end
+
class BasicModel
+ include DefaultValue
include ActiveModel::Model
attr_accessor :attr
end
@@ -29,4 +36,9 @@ def test_persisted_is_always_false
object = BasicModel.new(attr: "value")
assert object.persisted? == false
end
+
+ def test_mixin_inclusion_chain
+ object = BasicModel.new
+ assert_equal object.attr, 'default value'
+ end
end

0 comments on commit 878ab18

Please sign in to comment.