diff options
author | Tobias Bielohlawek <tobiasb@qype.com> | 2009-09-08 15:51:56 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-02-26 11:14:16 +0100 |
commit | 4db72b702f7faca7da30a64e45daeee13733762a (patch) | |
tree | 61688e6610078ed0e5044b17573b6c7459c52c8d /activerecord/test/cases | |
parent | b56b9ee7d6807d8ea9e1575afb7a28e89980b348 (diff) | |
download | rails-4db72b702f7faca7da30a64e45daeee13733762a.tar.gz rails-4db72b702f7faca7da30a64e45daeee13733762a.tar.bz2 rails-4db72b702f7faca7da30a64e45daeee13733762a.zip |
fixed a 'RecordNotFound' bug when calling 'reload' on a object which doesn't met the default_scope conditions, added test [#3166 status:resolved]
The reload method didn't made use of 'with_exclusive_scope' when reloading the object. This lead to a RecordNotFound exception, in case the object doesn't met the default_scope condition (anymore) - which is obviously a bug. This quick fix makes use of with_exclusive_scope in the reload method as well. See test for full example.
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/test/cases')
-rwxr-xr-x | activerecord/test/cases/base_test.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 2c4e1a3c0f..e3047fe873 100755 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1723,6 +1723,12 @@ class BasicsTest < ActiveRecord::TestCase assert_equal t1.title, t2.title end + def test_reload_with_exclusive_scope + dev = DeveloperCalledDavid.first + dev.update_attributes!( :name => "NotDavid" ) + assert_equal dev, dev.reload + end + def test_define_attr_method_with_value k = Class.new( ActiveRecord::Base ) k.send(:define_attr_method, :table_name, "foo") |