aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations_test.rb
diff options
context:
space:
mode:
authorRyan Bates <ryan@railscasts.com>2008-05-23 14:57:11 -0700
committerMichael Koziarski <michael@koziarski.com>2008-05-24 18:26:13 +1200
commit6cba97d2a449faf21aec9fe9d4434067e414226f (patch)
tree3c00a108230fe3471882678f362f4c138e6567df /activerecord/test/cases/associations_test.rb
parentb88ceb7dc8d31bdbea95ab4242bbdee17178cda9 (diff)
downloadrails-6cba97d2a449faf21aec9fe9d4434067e414226f.tar.gz
rails-6cba97d2a449faf21aec9fe9d4434067e414226f.tar.bz2
rails-6cba97d2a449faf21aec9fe9d4434067e414226f.zip
Create through associations can now work with blocks.
Signed-off-by: Michael Koziarski <michael@koziarski.com> [#248 state:resolved]
Diffstat (limited to 'activerecord/test/cases/associations_test.rb')
-rwxr-xr-xactiverecord/test/cases/associations_test.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/activerecord/test/cases/associations_test.rb b/activerecord/test/cases/associations_test.rb
index 034fe14996..59349dd7cf 100755
--- a/activerecord/test/cases/associations_test.rb
+++ b/activerecord/test/cases/associations_test.rb
@@ -161,12 +161,15 @@ class AssociationProxyTest < ActiveRecord::TestCase
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"
+ post = authors(:david).posts.create(:title => "New on Edge") {|p| p.body = "More cool stuff!"}
+ assert_equal post.title, "New on Edge"
+ assert_equal post.body, "More cool stuff!"
+ end
+
+ def test_create_with_bang_via_association_with_block
+ post = authors(:david).posts.create!(:title => "New on Edge") {|p| p.body = "More cool stuff!"}
+ assert_equal post.title, "New on Edge"
+ assert_equal post.body, "More cool stuff!"
end
def test_failed_reload_returns_nil