diff options
author | Mauro George <maurogot@gmail.com> | 2014-10-23 19:48:12 -0200 |
---|---|---|
committer | Mauro George <maurogot@gmail.com> | 2014-10-23 19:48:12 -0200 |
commit | b570b6b1768f4e89b4f21526763cae77c2ff03fe (patch) | |
tree | 9afbb1a60ff5c6426d00da6bf09e31766a2271ca /activerecord/test | |
parent | be49ec4b1f4256146b963a781a02748a342c6b6e (diff) | |
download | rails-b570b6b1768f4e89b4f21526763cae77c2ff03fe.tar.gz rails-b570b6b1768f4e89b4f21526763cae77c2ff03fe.tar.bz2 rails-b570b6b1768f4e89b4f21526763cae77c2ff03fe.zip |
Raises ArgumentError when try to define a scope without a callable
This changes the actual exception `NoMethodError: undefined method `call'
for #<ActiveRecord::Relation []>` to a `ArgumentError` when try to define
a scope without a callable.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/scoping/named_scoping_test.rb | 6 |
1 files changed, 6 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..d8906b2299 100644 --- a/activerecord/test/cases/scoping/named_scoping_test.rb +++ b/activerecord/test/cases/scoping/named_scoping_test.rb @@ -132,6 +132,12 @@ class NamedScopingTest < ActiveRecord::TestCase assert_equal Post.ranked_by_comments.limit_by(5), Post.top(5) end + def test_scopes_body_is_a_callable + assert_raises(ArgumentError, 'You need to suply a callable as scope body') do + Post.class_eval { scope :containing_the_letter_z, where("body LIKE '%z%'") } + end + end + def test_active_records_have_scope_named__all__ assert !Topic.all.empty? |