Permalink
Browse files

Fixed ActiveModel::Model's inclusion chain

  • Loading branch information...
1 parent f81dd36 commit 2d9b73b202e4f5fe3b81a1a2e231981b649ca7d8 @fredwu fredwu 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 2d9b73b

Please sign in to comment.