aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-10-02 10:52:55 -0300
committerEmilio Tagua <miloops@gmail.com>2009-10-02 10:52:55 -0300
commit29457a21c0d4451f5dbc66f72b8256baa02a55bd (patch)
tree50aebb7b31b990b805871e816b852151df2833a1 /activerecord/test
parent5f9540e4830ace3459b4018006573bad7fb30b53 (diff)
parent420004e030e96f2ace6e27fd622c90ee9e986677 (diff)
downloadrails-29457a21c0d4451f5dbc66f72b8256baa02a55bd.tar.gz
rails-29457a21c0d4451f5dbc66f72b8256baa02a55bd.tar.bz2
rails-29457a21c0d4451f5dbc66f72b8256baa02a55bd.zip
Merge commit 'rails/master'
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/has_one_associations_test.rb18
-rw-r--r--activerecord/test/cases/reflection_test.rb4
-rw-r--r--activerecord/test/models/company.rb2
3 files changed, 22 insertions, 2 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
diff --git a/activerecord/test/cases/reflection_test.rb b/activerecord/test/cases/reflection_test.rb
index 0eb2da720e..f3ed8ccd8d 100644
--- a/activerecord/test/cases/reflection_test.rb
+++ b/activerecord/test/cases/reflection_test.rb
@@ -176,9 +176,9 @@ class ReflectionTest < ActiveRecord::TestCase
def test_reflection_of_all_associations
# FIXME these assertions bust a lot
- assert_equal 35, Firm.reflect_on_all_associations.size
+ assert_equal 36, Firm.reflect_on_all_associations.size
assert_equal 26, Firm.reflect_on_all_associations(:has_many).size
- assert_equal 9, Firm.reflect_on_all_associations(:has_one).size
+ assert_equal 10, Firm.reflect_on_all_associations(:has_one).size
assert_equal 0, Firm.reflect_on_all_associations(:belongs_to).size
end
diff --git a/activerecord/test/models/company.rb b/activerecord/test/models/company.rb
index b1a3930e4e..469f5399ae 100644
--- a/activerecord/test/models/company.rb
+++ b/activerecord/test/models/company.rb
@@ -81,6 +81,8 @@ class Firm < Company
has_one :account_using_foreign_and_primary_keys, :foreign_key => "firm_name", :primary_key => "name", :class_name => "Account"
has_one :deletable_account, :foreign_key => "firm_id", :class_name => "Account", :dependent => :delete
+ has_one :account_limit_500_with_hash_conditions, :foreign_key => "firm_id", :class_name => "Account", :conditions => { :credit_limit => 500 }
+
has_one :unautosaved_account, :foreign_key => "firm_id", :class_name => 'Account', :autosave => false
has_many :accounts
has_many :unautosaved_accounts, :foreign_key => "firm_id", :class_name => 'Account', :autosave => false