Skip to content

Commit

Permalink
Merge pull request #11004 from fredwu/4-0-activemodel-inclusion-chain…
Browse files Browse the repository at this point in the history
…-fix

Fixed ActiveModel::Model's inclusion chain
  • Loading branch information
José Valim committed Jun 19, 2013
2 parents f81dd36 + 2d9b73b commit 6ed17e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions activemodel/lib/active_model/model.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def initialize(params={})
params.each do |attr, value| params.each do |attr, value|
self.public_send("#{attr}=", value) self.public_send("#{attr}=", value)
end if params end if params

super
end end


# Indicates if the model is persisted. Default is +false+. # Indicates if the model is persisted. Default is +false+.
Expand Down
12 changes: 12 additions & 0 deletions activemodel/test/cases/model_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
class ModelTest < ActiveModel::TestCase class ModelTest < ActiveModel::TestCase
include ActiveModel::Lint::Tests include ActiveModel::Lint::Tests


module DefaultValue
def initialize(*args)
@attr ||= 'default value'
end
end

class BasicModel class BasicModel
include DefaultValue
include ActiveModel::Model include ActiveModel::Model
attr_accessor :attr attr_accessor :attr
end end
Expand All @@ -29,4 +36,9 @@ def test_persisted_is_always_false
object = BasicModel.new(:attr => "value") object = BasicModel.new(:attr => "value")
assert object.persisted? == false assert object.persisted? == false
end end

def test_mixin_inclusion_chain
object = BasicModel.new
assert_equal object.attr, 'default value'
end
end end

0 comments on commit 6ed17e2

Please sign in to comment.