Permalink
Browse files

add failing test case for block-setting of attributes via association

Signed-off-by: Michael Koziarski <michael@koziarski.com>
  • Loading branch information...
1 parent 8d0b4fa commit b88ceb7dc8d31bdbea95ab4242bbdee17178cda9 Trevor Turk committed with NZKoz May 23, 2008
Showing with 9 additions and 0 deletions.
  1. +9 −0 activerecord/test/cases/associations_test.rb
View
9 activerecord/test/cases/associations_test.rb
@@ -160,6 +160,15 @@ def test_save_on_parent_saves_children
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

0 comments on commit b88ceb7

Please sign in to comment.