diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-10-08 00:14:37 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-10-08 00:15:36 +0100 |
commit | 0c27d0886e880f90240ad2004f1600c1b1c4bfed (patch) | |
tree | 2950c22f1c5dd6386794334a24af11d2b69087c7 /activerecord/test | |
parent | c352ec060ceddc43f63863c5d16ae31c3a72e42f (diff) | |
download | rails-0c27d0886e880f90240ad2004f1600c1b1c4bfed.tar.gz rails-0c27d0886e880f90240ad2004f1600c1b1c4bfed.tar.bz2 rails-0c27d0886e880f90240ad2004f1600c1b1c4bfed.zip |
Use indifferent access attributes instead of stringifying them
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/nested_attributes_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/nested_attributes_test.rb b/activerecord/test/cases/nested_attributes_test.rb index bf9aa4e65f..e57e361520 100644 --- a/activerecord/test/cases/nested_attributes_test.rb +++ b/activerecord/test/cases/nested_attributes_test.rb @@ -104,6 +104,14 @@ class TestNestedAttributesInGeneral < ActiveRecord::TestCase pirate.ship_attributes = { :name => 'Red Pearl', :_reject_me_if_new => true } assert_difference('Ship.count') { pirate.save! } end + + def test_reject_if_with_indifferent_keys + Pirate.accepts_nested_attributes_for :ship, :reject_if => proc {|attributes| attributes[:name].blank? } + + pirate = Pirate.new(:catchphrase => "Stop wastin' me time") + pirate.ship_attributes = { :name => 'Hello Pearl' } + assert_difference('Ship.count') { pirate.save! } + end end class TestNestedAttributesOnAHasOneAssociation < ActiveRecord::TestCase |