aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-01-06 19:54:23 +0000
committerAaron Patterson <aaron.patterson@gmail.com>2011-01-07 15:03:16 -0800
commit5b28e5254267c581ce6934408aaf458616e44e3f (patch)
tree2c6e793119db841e22443848fa03e8527dc6c1b4
parentd23c332e02932a6a06853193c79a21d70dbe139e (diff)
downloadrails-5b28e5254267c581ce6934408aaf458616e44e3f.tar.gz
rails-5b28e5254267c581ce6934408aaf458616e44e3f.tar.bz2
rails-5b28e5254267c581ce6934408aaf458616e44e3f.zip
Don't not remove double negatives
-rw-r--r--activerecord/lib/active_record/associations/has_one_association.rb8
-rw-r--r--activerecord/test/cases/associations/inverse_associations_test.rb2
2 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/has_one_association.rb b/activerecord/lib/active_record/associations/has_one_association.rb
index 158ae376e1..7503130e8c 100644
--- a/activerecord/lib/active_record/associations/has_one_association.rb
+++ b/activerecord/lib/active_record/associations/has_one_association.rb
@@ -14,11 +14,11 @@ module ActiveRecord
new_record(:build_association, attributes)
end
- def replace(obj, dont_save = false)
+ def replace(obj, save = true)
load_target
unless @target.nil? || @target == obj
- if @reflection.options[:dependent] && !dont_save
+ if @reflection.options[:dependent] && save
case @reflection.options[:dependent]
when :delete
@target.delete if @target.persisted?
@@ -45,7 +45,7 @@ module ActiveRecord
set_inverse_instance(obj)
loaded
- unless !@owner.persisted? || obj.nil? || dont_save
+ unless !@owner.persisted? || obj.nil? || !save
return (obj.save ? self : false)
else
return (obj.nil? ? nil : self)
@@ -65,7 +65,7 @@ module ActiveRecord
def new_record(method, attributes)
record = scoped.scoping { @reflection.send(method, attributes) }
- replace(record, true)
+ replace(record, false)
record
end
end
diff --git a/activerecord/test/cases/associations/inverse_associations_test.rb b/activerecord/test/cases/associations/inverse_associations_test.rb
index 4cca78da9d..e9a57a00a0 100644
--- a/activerecord/test/cases/associations/inverse_associations_test.rb
+++ b/activerecord/test/cases/associations/inverse_associations_test.rb
@@ -161,7 +161,7 @@ class InverseHasOneTests < ActiveRecord::TestCase
def test_parent_instance_should_be_shared_with_replaced_via_method_child
m = Man.find(:first)
f = Face.new(:description => 'haunted')
- m.face.replace(f, false)
+ m.face.replace(f)
assert_not_nil f.man
assert_equal m.name, f.man.name, "Name of man should be the same before changes to parent instance"
m.name = 'Bongo'