aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xactiverecord/lib/active_record/base.rb2
-rwxr-xr-xactiverecord/test/base_test.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 16554ffb55..e31987473e 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1187,7 +1187,7 @@ module ActiveRecord #:nodoc:
# Just freeze the attributes hash, such that associations are still accessible even on destroyed records.
def freeze
- @attributes.freeze
+ @attributes.freeze; self
end
def frozen?
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb
index b6e2b2f7b7..249c4116a6 100755
--- a/activerecord/test/base_test.rb
+++ b/activerecord/test/base_test.rb
@@ -223,6 +223,12 @@ class BasicsTest < Test::Unit::TestCase
assert_raise(ActiveRecord::RecordNotFound) { Topic.find(topic.id) }
end
+ def test_destroy_returns_self
+ topic = Topic.new("title" => "Yet Another Title")
+ assert topic.save
+ assert_equal topic, topic.destroy, "destroy did not return destroyed object"
+ end
+
def test_record_not_found_exception
assert_raises(ActiveRecord::RecordNotFound) { topicReloaded = Topic.find(99999) }
end