aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorTrevor Turk <trevorturk@yahoo.com>2008-05-23 15:51:56 -0500
committerMichael Koziarski <michael@koziarski.com>2008-05-24 18:25:33 +1200
commitb88ceb7dc8d31bdbea95ab4242bbdee17178cda9 (patch)
treee7ddc9db32dea469c192d7703032cc221f5ad2ae /activerecord/test/cases
parent8d0b4fa39fab6e5d1e3382b4b137cc47e559b0be (diff)
downloadrails-b88ceb7dc8d31bdbea95ab4242bbdee17178cda9.tar.gz
rails-b88ceb7dc8d31bdbea95ab4242bbdee17178cda9.tar.bz2
rails-b88ceb7dc8d31bdbea95ab4242bbdee17178cda9.zip
add failing test case for block-setting of attributes via association
Signed-off-by: Michael Koziarski <michael@koziarski.com>
Diffstat (limited to 'activerecord/test/cases')
-rwxr-xr-xactiverecord/test/cases/associations_test.rb9
1 files changed, 9 insertions, 0 deletions
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