aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/belongs_to_associations_test.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2011-05-17 22:15:47 +0100
committerAndrew White <andyw@pixeltrix.co.uk>2011-05-17 22:16:24 +0100
commit3773aa4fbba86184a1f45feebaf72ed4f2702fe7 (patch)
treeb56d9dc07d96e4d085667a98f53c3878509412c0 /activerecord/test/cases/associations/belongs_to_associations_test.rb
parentbe199a1d53f9ceae5cfaac185bfd0d9c2a28f9d4 (diff)
downloadrails-3773aa4fbba86184a1f45feebaf72ed4f2702fe7.tar.gz
rails-3773aa4fbba86184a1f45feebaf72ed4f2702fe7.tar.bz2
rails-3773aa4fbba86184a1f45feebaf72ed4f2702fe7.zip
Add block setting of attributes to singular associations
Diffstat (limited to 'activerecord/test/cases/associations/belongs_to_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/belongs_to_associations_test.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb
index ddcc36c841..b993bf6e90 100644
--- a/activerecord/test/cases/associations/belongs_to_associations_test.rb
+++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb
@@ -626,4 +626,25 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
assert_equal "Bob", firm.name
end
+
+ def test_build_with_block
+ client = Client.create(:name => 'Client Company')
+
+ firm = client.build_firm{ |f| f.name = 'Agency Company' }
+ assert_equal 'Agency Company', firm.name
+ end
+
+ def test_create_with_block
+ client = Client.create(:name => 'Client Company')
+
+ firm = client.create_firm{ |f| f.name = 'Agency Company' }
+ assert_equal 'Agency Company', firm.name
+ end
+
+ def test_create_bang_with_block
+ client = Client.create(:name => 'Client Company')
+
+ firm = client.create_firm!{ |f| f.name = 'Agency Company' }
+ assert_equal 'Agency Company', firm.name
+ end
end