diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2016-01-25 11:25:11 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2016-01-25 11:25:11 -0800 |
commit | 6dfab475ca230dfcad7a603483431c8e7a8f908e (patch) | |
tree | 69ca8ade43b0e39e1d8cffa68390e9052e589acf /activerecord/test | |
parent | 14e92bac1a4c199e5e8936c6bdc64420293ea6d1 (diff) | |
parent | 908c011395cc9e3ea1bb195f9d1bd30a9d9df98f (diff) | |
download | rails-6dfab475ca230dfcad7a603483431c8e7a8f908e.tar.gz rails-6dfab475ca230dfcad7a603483431c8e7a8f908e.tar.bz2 rails-6dfab475ca230dfcad7a603483431c8e7a8f908e.zip |
Merge branch '5-0-beta-sec'
* 5-0-beta-sec:
bumping version
fix version update task to deal with .beta1.1
Eliminate instance level writers for class accessors
allow :file to be outside rails root, but anything else must be inside the rails view directory
Don't short-circuit reject_if proc
stop caching mime types globally
use secure string comparisons for basic auth username / password
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/nested_attributes_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/nested_attributes_test.rb b/activerecord/test/cases/nested_attributes_test.rb index 0b700afcb4..6fbc6196cc 100644 --- a/activerecord/test/cases/nested_attributes_test.rb +++ b/activerecord/test/cases/nested_attributes_test.rb @@ -146,6 +146,19 @@ class TestNestedAttributesInGeneral < ActiveRecord::TestCase assert man.reload.interests.empty? end + def test_reject_if_is_not_short_circuited_if_allow_destroy_is_false + Pirate.accepts_nested_attributes_for :ship, reject_if: ->(a) { a[:name] == "The Golden Hind" }, allow_destroy: false + + pirate = Pirate.create!(catchphrase: "Stop wastin' me time", ship_attributes: { name: "White Pearl", _destroy: "1" }) + assert_equal "White Pearl", pirate.reload.ship.name + + pirate.update!(ship_attributes: { id: pirate.ship.id, name: "The Golden Hind", _destroy: "1" }) + assert_equal "White Pearl", pirate.reload.ship.name + + pirate.update!(ship_attributes: { id: pirate.ship.id, name: "Black Pearl", _destroy: "1" }) + assert_equal "Black Pearl", pirate.reload.ship.name + end + def test_has_many_association_updating_a_single_record Man.accepts_nested_attributes_for(:interests) man = Man.create(name: 'John') |