aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/associations_test.rb
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2007-11-29 02:19:10 +0000
committerMichael Koziarski <michael@koziarski.com>2007-11-29 02:19:10 +0000
commite302759451fbed36d7e8916d7b5c8377762e3efd (patch)
treeb81444c861a94fab84a87cc0a6b5a112635fe581 /activerecord/test/associations_test.rb
parent0a9bc591e78382b221ef5c2f463bac90564b9982 (diff)
downloadrails-e302759451fbed36d7e8916d7b5c8377762e3efd.tar.gz
rails-e302759451fbed36d7e8916d7b5c8377762e3efd.tar.bz2
rails-e302759451fbed36d7e8916d7b5c8377762e3efd.zip
Make reset return nil when using a dangling belongs_to association. Current behaviour is to return false which can be confusing. Closes #10293 [fcheung]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8236 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/associations_test.rb')
-rwxr-xr-xactiverecord/test/associations_test.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb
index 20224cbd42..f2a87eec49 100755
--- a/activerecord/test/associations_test.rb
+++ b/activerecord/test/associations_test.rb
@@ -122,6 +122,23 @@ class AssociationProxyTest < Test::Unit::TestCase
developer = Developer.create :name => "Bryan", :salary => 50_000
assert_equal 1, developer.reload.audit_logs.size
end
+
+ def test_failed_reload_returns_nil
+ p = setup_dangling_association
+ assert_nil p.author.reload
+ end
+
+ def test_failed_reset_returns_nil
+ p = setup_dangling_association
+ assert_nil p.author.reset
+ end
+
+ def setup_dangling_association
+ josh = Author.create(:name => "Josh")
+ p = Post.create(:title => "New on Edge", :body => "More cool stuff!", :author => josh)
+ josh.destroy
+ p
+ end
end
class HasOneAssociationsTest < Test::Unit::TestCase