Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…ain-fix

Fixed ActiveModel::Model's inclusion chain
  • Loading branch information...
commit 067153dabfde7c664457c9d635d0431c7feb13ca 1 parent 58d4c1d
@josevalim josevalim authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.