aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2010-11-11 15:23:37 -0200
committerSantiago Pastorino <santiago@wyeworks.com>2010-11-11 15:23:40 -0200
commit894fd288596b005148c3882e6431f6453d198101 (patch)
treee31487682b149e22e529a30cb8bd9505fae69679 /activerecord/test/cases
parentceef719924b566a519465de96bd29344ee4d2fed (diff)
downloadrails-894fd288596b005148c3882e6431f6453d198101.tar.gz
rails-894fd288596b005148c3882e6431f6453d198101.tar.bz2
rails-894fd288596b005148c3882e6431f6453d198101.zip
Fixed bug in active_record/nested_attributes where an empty string id caused an ActiveRecord::RecordNotFound error. Found by [Ben Tillman]
[#5638 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/nested_attributes_test.rb8
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 765f59e0ac..92af53d56f 100644
--- a/activerecord/test/cases/nested_attributes_test.rb
+++ b/activerecord/test/cases/nested_attributes_test.rb
@@ -139,6 +139,14 @@ class TestNestedAttributesInGeneral < ActiveRecord::TestCase
assert_equal 'gardening', interest.reload.topic
end
+ def test_reject_if_with_blank_nested_attributes_id
+ # When using a select list to choose an existing 'ship' id, with :include_blank => true
+ Pirate.accepts_nested_attributes_for :ship, :reject_if => proc {|attributes| attributes[:id].blank? }
+
+ pirate = Pirate.new(:catchphrase => "Stop wastin' me time")
+ pirate.ship_attributes = { :id => "" }
+ assert_nothing_raised(ActiveRecord::RecordNotFound) { pirate.save! }
+ end
end
class TestNestedAttributesOnAHasOneAssociation < ActiveRecord::TestCase