From b88ceb7dc8d31bdbea95ab4242bbdee17178cda9 Mon Sep 17 00:00:00 2001 From: Trevor Turk Date: Fri, 23 May 2008 15:51:56 -0500 Subject: add failing test case for block-setting of attributes via association Signed-off-by: Michael Koziarski --- activerecord/test/cases/associations_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/associations_test.rb b/activerecord/test/cases/associations_test.rb index 3ad8c608e0..034fe14996 100755 --- a/activerecord/test/cases/associations_test.rb +++ b/activerecord/test/cases/associations_test.rb @@ -160,6 +160,15 @@ class AssociationProxyTest < ActiveRecord::TestCase assert_equal 1, developer.reload.audit_logs.size end + def test_create_via_association_with_block + post1 = Post.create(:title => "setting body with a block") {|p| p.body = "will work"} + assert_equal post1.body, "will work" + assert_nothing_raised do + post2 = authors(:david).posts.create(:title => "setting body with a block") {|p| p.body = "won't work"} + end + assert_equal post2.body, "won't work" + end + def test_failed_reload_returns_nil p = setup_dangling_association assert_nil p.author.reload -- cgit v1.2.3