diff options
author | Akira Matsuda <ronnie@dio.jp> | 2016-01-28 17:13:47 +0900 |
---|---|---|
committer | Akira Matsuda <ronnie@dio.jp> | 2016-01-28 18:37:39 +0900 |
commit | dc925119a3912ecfe0df400007163f33b99d6385 (patch) | |
tree | b43c5b89f30504ac028b62bdde9f638b1775fbff /activerecord/test/cases | |
parent | a69281614a7ed6c134d9a799419dd34dd5293a81 (diff) | |
download | rails-dc925119a3912ecfe0df400007163f33b99d6385.tar.gz rails-dc925119a3912ecfe0df400007163f33b99d6385.tar.bz2 rails-dc925119a3912ecfe0df400007163f33b99d6385.zip |
Revert "Remove valid_scope_name? check - use ruby"
This reverts commit f6db31ec16e42ee7713029f7120f0b011d1ddc6c.
Reason:
Scope names can very easily conflict, particularly when sharing Concerns
within the team, or using multiple gems that extend AR models.
It is true that Ruby has the ability to detect this with the -w option, but the
reality is that we are depending on too many gems that do not care about Ruby
warnings, therefore it might not be a realistic solution to turn this switch on
in our real-world apps.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/scoping/named_scoping_test.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/cases/scoping/named_scoping_test.rb b/activerecord/test/cases/scoping/named_scoping_test.rb index 7a8eaeccb7..db1e42fcc2 100644 --- a/activerecord/test/cases/scoping/named_scoping_test.rb +++ b/activerecord/test/cases/scoping/named_scoping_test.rb @@ -440,6 +440,25 @@ class NamedScopingTest < ActiveRecord::TestCase end end + def test_scopes_with_reserved_names + 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 + def test_scopes_on_relations # Topic.replied approved_topics = Topic.all.approved.order('id DESC') |