aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/named_scope_test.rb
diff options
context:
space:
mode:
authorMatthew Rudy Jacobs <matthewrudyjacobs@gmail.com>2010-03-02 11:24:35 +0800
committerwycats <wycats@gmail.com>2010-03-28 13:53:20 -0700
commitb0967cc5cf5ce08e7fb0574692e3bb785e79973a (patch)
tree788b462e1bbbd198e7251e3f69637625d5ddbbe3 /activerecord/test/cases/named_scope_test.rb
parent77a2a3d9b3aa461437ced326ea4a70112a8c68ed (diff)
downloadrails-b0967cc5cf5ce08e7fb0574692e3bb785e79973a.tar.gz
rails-b0967cc5cf5ce08e7fb0574692e3bb785e79973a.tar.bz2
rails-b0967cc5cf5ce08e7fb0574692e3bb785e79973a.zip
defining a named_scope which overwrites an existing method is now allowed we just log a warning.
This was motivated by the fact that :open is defined on all classes as such the named_scope "open" can never be used, without hacking ActiveRecord with an "undef_method" [#4083 state:resolved] Signed-off-by: wycats <wycats@gmail.com>
Diffstat (limited to 'activerecord/test/cases/named_scope_test.rb')
-rw-r--r--activerecord/test/cases/named_scope_test.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb
index 6c2b4fa3a7..40c724b87e 100644
--- a/activerecord/test/cases/named_scope_test.rb
+++ b/activerecord/test/cases/named_scope_test.rb
@@ -371,8 +371,21 @@ class NamedScopeTest < ActiveRecord::TestCase
end
def test_named_scopes_with_reserved_names
- [:where, :with_scope].each do |protected_method|
- assert_raises(ArgumentError) { Topic.scope protected_method }
+ class << Topic
+ def public_method; end
+ public :public_method
+
+ def protected_method; end
+ protected :protected_method
+
+ def private_method; end
+ private :private_method
+ end
+
+ [:public_method, :protected_method, :private_method].each do |reserved_method|
+ assert Topic.respond_to?(reserved_method, true)
+ ActiveRecord::Base.logger.expects(:warn)
+ Topic.scope(reserved_method)
end
end