aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
diff options
context:
space:
mode:
authorLuciano G Panaro <contact@decodeuri.com>2009-09-26 10:33:50 -0300
committerMichael Koziarski <michael@koziarski.com>2009-09-28 14:50:33 +1300
commit4168f876238982d0d584006f50188071928a8b7f (patch)
tree93e22b323a8f3bf25c5e67697a347e1fb958b0a0 /activerecord/test/cases/associations
parentd48ebeade2d907573e3fb086495b57b10115066c (diff)
downloadrails-4168f876238982d0d584006f50188071928a8b7f.tar.gz
rails-4168f876238982d0d584006f50188071928a8b7f.tar.bz2
rails-4168f876238982d0d584006f50188071928a8b7f.zip
Make has_one with :conditions hash scope build or creation of the associated object with those conditions
Signed-off-by: Michael Koziarski <michael@koziarski.com> [#3088 state:committed]
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r--activerecord/test/cases/associations/has_one_associations_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb
index cdac86a3b9..289c89d1e2 100644
--- a/activerecord/test/cases/associations/has_one_associations_test.rb
+++ b/activerecord/test/cases/associations/has_one_associations_test.rb
@@ -315,4 +315,22 @@ class HasOneAssociationsTest < ActiveRecord::TestCase
Firm.find(@firm.id, :include => :account).save!
end
end
+
+ def test_build_respects_hash_condition
+ account = companies(:first_firm).build_account_limit_500_with_hash_conditions
+ assert account.save
+ assert_equal 500, account.credit_limit
+ end
+
+ def test_create_respects_hash_condition
+ account = companies(:first_firm).create_account_limit_500_with_hash_conditions
+ assert !account.new_record?
+ assert_equal 500, account.credit_limit
+ end
+
+ def test_create!_respects_hash_condition
+ account = companies(:first_firm).create_account_limit_500_with_hash_conditions!
+ assert !account.new_record?
+ assert_equal 500, account.credit_limit
+ end
end