mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Fixed that calling HasOneProxy#build_model repeatedly would cause saving to happen (closes #4058) [anna@wota.jp]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3753 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Fixed that calling HasOneProxy#build_model repeatedly would cause saving to happen #4058 [anna@wota.jp]
|
||||
|
||||
* Added Sybase database adapter that relies on the Sybase Open Client bindings (see http://raa.ruby-lang.org/project/sybase-ctlib) #3765 [John Sheets]. It's almost completely Active Record compliant, but has the following caveats:
|
||||
|
||||
* Does not support DATE SQL column types; use DATETIME instead.
|
||||
|
||||
@@ -34,7 +34,7 @@ module ActiveRecord
|
||||
@owner.clear_association_cache
|
||||
else
|
||||
@target[@reflection.primary_key_name] = nil
|
||||
@target.save unless @owner.new_record?
|
||||
@target.save unless @owner.new_record? || @target.new_record?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -158,6 +158,15 @@ class HasOneAssociationsTest < Test::Unit::TestCase
|
||||
assert_equal "can't be empty", account.errors.on("credit_limit")
|
||||
end
|
||||
|
||||
def test_build_association_twice_without_saving_affects_nothing
|
||||
count_of_account = Account.count
|
||||
firm = Firm.find(:first)
|
||||
account1 = firm.build_account("credit_limit" => 1000)
|
||||
account2 = firm.build_account("credit_limit" => 2000)
|
||||
|
||||
assert_equal count_of_account, Account.count
|
||||
end
|
||||
|
||||
def test_create_association
|
||||
firm = Firm.new("name" => "GlobalMegaCorp")
|
||||
firm.save
|
||||
|
||||
Reference in New Issue
Block a user