aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/scoping
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2014-10-27 09:18:06 +0100
committerYves Senn <yves.senn@gmail.com>2014-10-27 09:49:50 +0100
commitd616fec8117ac25753ee23e15ac14261d298ee51 (patch)
tree4d9f0e788f43518c483f25059fbbf3f59af6fb16 /activerecord/test/cases/scoping
parentffed7acd8eed3bc3219aad7828a54b1f2c03bfaf (diff)
parentb570b6b1768f4e89b4f21526763cae77c2ff03fe (diff)
downloadrails-d616fec8117ac25753ee23e15ac14261d298ee51.tar.gz
rails-d616fec8117ac25753ee23e15ac14261d298ee51.tar.bz2
rails-d616fec8117ac25753ee23e15ac14261d298ee51.zip
Merge pull request #17374 from maurogeorge/scope-exception
Raises ArgumentError when try to define a scope without a callable
Diffstat (limited to 'activerecord/test/cases/scoping')
-rw-r--r--activerecord/test/cases/scoping/named_scoping_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/scoping/named_scoping_test.rb b/activerecord/test/cases/scoping/named_scoping_test.rb
index d3546bd471..c2816c3670 100644
--- a/activerecord/test/cases/scoping/named_scoping_test.rb
+++ b/activerecord/test/cases/scoping/named_scoping_test.rb
@@ -132,6 +132,13 @@ class NamedScopingTest < ActiveRecord::TestCase
assert_equal Post.ranked_by_comments.limit_by(5), Post.top(5)
end
+ def test_scopes_body_is_a_callable
+ e = assert_raises ArgumentError do
+ Class.new(Post).class_eval { scope :containing_the_letter_z, where("body LIKE '%z%'") }
+ end
+ assert_equal "The scope body needs to be callable.", e.message
+ end
+
def test_active_records_have_scope_named__all__
assert !Topic.all.empty?