Skip to content

Commit

Permalink
Merge branch 'mjbellantoni-fix-bug-113'
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed Jun 16, 2015
2 parents d50f715 + e004c1a commit 274a87e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/lotus/action/params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ def self.whitelisting?
# @since 0.3.2
# @api private
def self.build_validation_class(&block)
kls = Class.new(Params)
kls = Class.new(Params) do
def lotus_nested_attributes?
true
end
end
kls.class_eval(&block)
kls
end
Expand Down
23 changes: 23 additions & 0 deletions test/action/params_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,29 @@
h.must_be_kind_of(::Hash)
end
end

describe 'when whitelisting' do
# This is bug 113.
it 'handles nested params' do
hash = {
'name' => 'John',
'age' => 1,
'address' => {
'line_one' => '10 High Street',
'deep' => {
'deep_attr' => 'hello',
}
}
}

actual = TestParams.new(hash).to_h
actual.must_equal(hash)

actual.must_be_kind_of(::Hash)
actual['address'].must_be_kind_of(::Hash)
actual['address']['deep'].must_be_kind_of(::Hash)
end
end
end

describe '#to_hash' do
Expand Down

0 comments on commit 274a87e

Please sign in to comment.