public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
add failing test case for block-setting of attributes via association

Signed-off-by: Michael Koziarski <michael@koziarski.com>
trevorturk (author)
Fri May 23 13:51:56 -0700 2008
NZKoz (committer)
Fri May 23 23:25:33 -0700 2008
commit  b88ceb7dc8d31bdbea95ab4242bbdee17178cda9
tree    e7ddc9db32dea469c192d7703032cc221f5ad2ae
parent  8d0b4fa39fab6e5d1e3382b4b137cc47e559b0be
...
160
161
162
 
 
 
 
 
 
 
 
 
163
164
165
...
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
0
@@ -160,6 +160,15 @@ class AssociationProxyTest < ActiveRecord::TestCase
0
     assert_equal 1, developer.reload.audit_logs.size
0
   end
0
 
0
+  def test_create_via_association_with_block
0
+    post1 = Post.create(:title => "setting body with a block") {|p| p.body = "will work"}
0
+    assert_equal post1.body, "will work"
0
+    assert_nothing_raised do
0
+      post2 = authors(:david).posts.create(:title => "setting body with a block") {|p| p.body = "won't work"}
0
+    end
0
+    assert_equal post2.body, "won't work"
0
+  end
0
+
0
   def test_failed_reload_returns_nil
0
     p = setup_dangling_association
0
     assert_nil p.author.reload

Comments