diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-17 21:34:26 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-17 21:34:41 +0530 |
commit | f0cde5be541e1f3877a15fb5d39c87a487a14381 (patch) | |
tree | 6abf7fcf3f868e3ad827f6b5ca9f6e1f3618d4bf /activerecord/test/cases | |
parent | 5a6596787b9489c62d149b61935057cee3dcf61a (diff) | |
download | rails-f0cde5be541e1f3877a15fb5d39c87a487a14381.tar.gz rails-f0cde5be541e1f3877a15fb5d39c87a487a14381.tar.bz2 rails-f0cde5be541e1f3877a15fb5d39c87a487a14381.zip |
Make sure named_scope names are not used as method names already
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/named_scope_test.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb index 5d9232bc52..6f84e12a49 100644 --- a/activerecord/test/cases/named_scope_test.rb +++ b/activerecord/test/cases/named_scope_test.rb @@ -150,13 +150,13 @@ class NamedScopeTest < ActiveRecord::TestCase end def test_named_scopes_honor_current_scopes_from_when_defined - assert !Post.ranked_by_comments.limit(5).empty? - assert !authors(:david).posts.ranked_by_comments.limit(5).empty? - assert_not_equal Post.ranked_by_comments.limit(5), authors(:david).posts.ranked_by_comments.limit(5) + assert !Post.ranked_by_comments.limit_by(5).empty? + assert !authors(:david).posts.ranked_by_comments.limit_by(5).empty? + assert_not_equal Post.ranked_by_comments.limit_by(5), authors(:david).posts.ranked_by_comments.limit_by(5) assert_not_equal Post.top(5), authors(:david).posts.top(5) # Oracle sometimes sorts differently if WHERE condition is changed - assert_equal authors(:david).posts.ranked_by_comments.limit(5).sort_by(&:id), authors(:david).posts.top(5).sort_by(&:id) - assert_equal Post.ranked_by_comments.limit(5), Post.top(5) + assert_equal authors(:david).posts.ranked_by_comments.limit_by(5).sort_by(&:id), authors(:david).posts.top(5).sort_by(&:id) + assert_equal Post.ranked_by_comments.limit_by(5), Post.top(5) end def test_active_records_have_scope_named__all__ @@ -374,6 +374,12 @@ class NamedScopeTest < ActiveRecord::TestCase Comment.for_first_post.for_first_author.all end end + + def test_named_scopes_with_reserved_names + [:where, :with_scope].each do |protected_method| + assert_raises(ArgumentError) { Topic.named_scope protected_method } + end + end end class DynamicScopeMatchTest < ActiveRecord::TestCase |