aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relations_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-02-20 08:38:50 -0800
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-02-20 08:38:50 -0800
commit7bae72c69f2352fd7e02f2d08adf873e4354aea0 (patch)
tree2c5de64f57e26a874f311c975a785b01ade9a884 /activerecord/test/cases/relations_test.rb
parenta5bf96ab9b6918af77e8cde5be6e1202e33ac021 (diff)
parentd49f862b9a6877f02d6fbf90f276a345abfa4372 (diff)
downloadrails-7bae72c69f2352fd7e02f2d08adf873e4354aea0.tar.gz
rails-7bae72c69f2352fd7e02f2d08adf873e4354aea0.tar.bz2
rails-7bae72c69f2352fd7e02f2d08adf873e4354aea0.zip
Merge pull request #9332 from wangjohn/adding_documentation_to_error_raising_in_query_methods
Tests to make sure empty arguments in WhereChain raise errors
Diffstat (limited to 'activerecord/test/cases/relations_test.rb')
-rw-r--r--activerecord/test/cases/relations_test.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index 379c0c0758..8298d7534c 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -321,6 +321,22 @@ class RelationTest < ActiveRecord::TestCase
assert_equal 1, person_with_reader_and_post.size
end
+ def test_no_arguments_to_query_methods_raise_errors
+ assert_raises(ArgumentError) { Topic.references() }
+ assert_raises(ArgumentError) { Topic.includes() }
+ assert_raises(ArgumentError) { Topic.preload() }
+ assert_raises(ArgumentError) { Topic.group() }
+ assert_raises(ArgumentError) { Topic.reorder() }
+ end
+
+ def test_blank_like_arguments_to_query_methods_dont_raise_errors
+ assert_nothing_raised { Topic.references([]) }
+ assert_nothing_raised { Topic.includes([]) }
+ assert_nothing_raised { Topic.preload([]) }
+ assert_nothing_raised { Topic.group([]) }
+ assert_nothing_raised { Topic.reorder([]) }
+ end
+
def test_scoped_responds_to_delegated_methods
relation = Topic.all