Skip to content
Browse files

Merge pull request #11004 from fredwu/4-0-activemodel-inclusion-chain…

…-fix

Fixed ActiveModel::Model's inclusion chain
  • Loading branch information...
2 parents f81dd36 + 2d9b73b commit 6ed17e2a65c9cad6f5bf73080493a732828da2d5 @josevalim josevalim committed Jun 18, 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
View
2 activemodel/lib/active_model/model.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+.
View
12 activemodel/test/cases/model_test.rb
@@ -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 6ed17e2

Please sign in to comment.
Something went wrong with that request. Please try again.