aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorDurran Jordan <durran@gmail.com>2011-04-05 11:01:04 +0200
committerSantiago Pastorino <santiago@wyeworks.com>2011-04-05 10:38:54 -0300
commita9b4b5da7c216e4464eeb9dbd0a39ea258d64325 (patch)
tree5af4723bd3ce6d4351d1c10b49e2f54b58c18731 /activerecord/test
parent284ca810c17a89d15d809ba203289487044fcff9 (diff)
downloadrails-a9b4b5da7c216e4464eeb9dbd0a39ea258d64325.tar.gz
rails-a9b4b5da7c216e4464eeb9dbd0a39ea258d64325.tar.bz2
rails-a9b4b5da7c216e4464eeb9dbd0a39ea258d64325.zip
Destroying records via nested attributes works independent of reject_if:
- When a :_destroy truthiness is provided in the attributes hash, the record should get destroyed regardless of the result of the proc or method supplied to :reject_if. (If :allow_destroy is true) [#6006 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activerecord/test')
-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 c57ab7ed28..6568eb1d18 100644
--- a/activerecord/test/cases/nested_attributes_test.rb
+++ b/activerecord/test/cases/nested_attributes_test.rb
@@ -131,6 +131,14 @@ class TestNestedAttributesInGeneral < ActiveRecord::TestCase
assert_equal 'photography', interest.reload.topic
end
+ def test_destroy_works_independent_of_reject_if
+ Man.accepts_nested_attributes_for :interests, :reject_if => proc {|attributes| true }, :allow_destroy => true
+ man = Man.create(:name => "Jon")
+ interest = man.interests.create(:topic => 'the ladies')
+ man.update_attributes({:interests_attributes => { :_destroy => "1", :id => interest.id } })
+ assert man.reload.interests.empty?
+ end
+
def test_has_many_association_updating_a_single_record
Man.accepts_nested_attributes_for(:interests)
man = Man.create(:name => 'John')