diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2016-01-25 11:23:48 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2016-01-25 11:23:48 -0800 |
commit | 3b4398bb605cc7b6f475bf76c19aa0702700a199 (patch) | |
tree | 13285c577d9b6aff2fde072a2030b0468a775423 /activerecord/test/cases | |
parent | d25e79fba6090d56769da6f0fbb401bb1afdb28a (diff) | |
parent | 8d86637fb64ae8ae81ab71a286ddba02cc3144a4 (diff) | |
download | rails-3b4398bb605cc7b6f475bf76c19aa0702700a199.tar.gz rails-3b4398bb605cc7b6f475bf76c19aa0702700a199.tar.bz2 rails-3b4398bb605cc7b6f475bf76c19aa0702700a199.zip |
Merge branch '3-2-sec' into 3-2-stable
* 3-2-sec:
bumping version
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/cases')
-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 85b9d3c1a1..f5f0517681 100644 --- a/activerecord/test/cases/nested_attributes_test.rb +++ b/activerecord/test/cases/nested_attributes_test.rb @@ -147,6 +147,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') |