aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relation
diff options
context:
space:
mode:
authorBen Toews <mastahyeti@gmail.com>2017-09-25 10:58:08 -0600
committerMatthew Draper <matthew@trebex.net>2017-11-09 22:39:48 +1030
commit02a17492a937d4b423590644ad1481b82facd394 (patch)
treefe6a27b94d8e2ae46f9f4f1bd1a53b3c0f7f1ff5 /activerecord/test/cases/relation
parent40d302d880f247ef9547708b1d26a390945b6fe9 (diff)
downloadrails-02a17492a937d4b423590644ad1481b82facd394.tar.gz
rails-02a17492a937d4b423590644ad1481b82facd394.tar.bz2
rails-02a17492a937d4b423590644ad1481b82facd394.zip
work around deprecation warnings in a bunch of tests
Diffstat (limited to 'activerecord/test/cases/relation')
-rw-r--r--activerecord/test/cases/relation/merging_test.rb14
-rw-r--r--activerecord/test/cases/relation/mutation_test.rb2
-rw-r--r--activerecord/test/cases/relation/or_test.rb14
3 files changed, 15 insertions, 15 deletions
diff --git a/activerecord/test/cases/relation/merging_test.rb b/activerecord/test/cases/relation/merging_test.rb
index 953e0fee76..3b35df526f 100644
--- a/activerecord/test/cases/relation/merging_test.rb
+++ b/activerecord/test/cases/relation/merging_test.rb
@@ -13,10 +13,10 @@ class RelationMergingTest < ActiveRecord::TestCase
fixtures :developers, :comments, :authors, :author_addresses, :posts
def test_relation_merging
- devs = Developer.where("salary >= 80000").merge(Developer.limit(2)).merge(Developer.order("id ASC").where("id < 3"))
+ devs = Developer.where("salary >= 80000").merge(Developer.limit(2)).merge(Developer.order(Arel.sql("id ASC")).where("id < 3"))
assert_equal [developers(:david), developers(:jamis)], devs.to_a
- dev_with_count = Developer.limit(1).merge(Developer.order("id DESC")).merge(Developer.select("developers.*"))
+ dev_with_count = Developer.limit(1).merge(Developer.order(Arel.sql("id DESC"))).merge(Developer.select("developers.*"))
assert_equal [developers(:poor_jamis)], dev_with_count.to_a
end
@@ -47,8 +47,8 @@ class RelationMergingTest < ActiveRecord::TestCase
def test_relation_merging_with_eager_load
relations = []
- relations << Post.order("comments.id DESC").merge(Post.eager_load(:last_comment)).merge(Post.all)
- relations << Post.eager_load(:last_comment).merge(Post.order("comments.id DESC")).merge(Post.all)
+ relations << Post.order(Arel.sql("comments.id DESC")).merge(Post.eager_load(:last_comment)).merge(Post.all)
+ relations << Post.eager_load(:last_comment).merge(Post.order(Arel.sql("comments.id DESC"))).merge(Post.all)
relations.each do |posts|
post = posts.find { |p| p.id == 1 }
@@ -57,7 +57,7 @@ class RelationMergingTest < ActiveRecord::TestCase
end
def test_relation_merging_with_locks
- devs = Developer.lock.where("salary >= 80000").order("id DESC").merge(Developer.limit(2))
+ devs = Developer.lock.where("salary >= 80000").order(Arel.sql("id DESC")).merge(Developer.limit(2))
assert devs.locked?
end
@@ -118,7 +118,7 @@ class MergingDifferentRelationsTest < ActiveRecord::TestCase
test "merging where relations" do
hello_by_bob = Post.where(body: "hello").joins(:author).
- merge(Author.where(name: "Bob")).order("posts.id").pluck(Arel.sql("posts.id"))
+ merge(Author.where(name: "Bob")).order(Arel.sql("posts.id")).pluck(Arel.sql("posts.id"))
assert_equal [posts(:misc_by_bob).id,
posts(:other_by_bob).id], hello_by_bob
@@ -131,7 +131,7 @@ class MergingDifferentRelationsTest < ActiveRecord::TestCase
assert_equal ["Bob", "Bob", "David"], posts_by_author_name
posts_by_author_name = Post.limit(3).joins(:author).
- merge(Author.order("name")).pluck(Arel.sql("authors.name"))
+ merge(Author.order(Arel.sql("name"))).pluck(Arel.sql("authors.name"))
assert_equal ["Bob", "Bob", "David"], posts_by_author_name
end
diff --git a/activerecord/test/cases/relation/mutation_test.rb b/activerecord/test/cases/relation/mutation_test.rb
index ad3700b73a..d845c07a50 100644
--- a/activerecord/test/cases/relation/mutation_test.rb
+++ b/activerecord/test/cases/relation/mutation_test.rb
@@ -94,7 +94,7 @@ module ActiveRecord
end
test "reverse_order!" do
- @relation = Post.order("title ASC, comments_count DESC")
+ @relation = Post.order(Arel.sql("title ASC, comments_count DESC"))
relation.reverse_order!
diff --git a/activerecord/test/cases/relation/or_test.rb b/activerecord/test/cases/relation/or_test.rb
index 7e418f9c7d..2abc3b7fe8 100644
--- a/activerecord/test/cases/relation/or_test.rb
+++ b/activerecord/test/cases/relation/or_test.rb
@@ -50,15 +50,15 @@ module ActiveRecord
end
def test_or_preserves_other_querying_methods
- expected = Post.where("id = 1 or id = 2 or id = 3").order("body asc").to_a
- partial = Post.order("body asc")
+ expected = Post.where("id = 1 or id = 2 or id = 3").order(Arel.sql("body asc")).to_a
+ partial = Post.order(Arel.sql("body asc"))
assert_equal expected, partial.where("id = 1").or(partial.where(id: [2, 3])).to_a
- assert_equal expected, Post.order("body asc").where("id = 1").or(Post.order("body asc").where(id: [2, 3])).to_a
+ assert_equal expected, Post.order(Arel.sql("body asc")).where("id = 1").or(Post.order(Arel.sql("body asc")).where(id: [2, 3])).to_a
end
def test_or_with_incompatible_relations
error = assert_raises ArgumentError do
- Post.order("body asc").where("id = 1").or(Post.order("id desc").where(id: [2, 3])).to_a
+ Post.order(Arel.sql("body asc")).where("id = 1").or(Post.order(Arel.sql("id desc")).where(id: [2, 3])).to_a
end
assert_equal "Relation passed to #or must be structurally compatible. Incompatible values: [:order]", error.message
@@ -78,12 +78,12 @@ module ActiveRecord
def test_or_with_unscope_order
expected = Post.where("id = 1 or id = 2")
- assert_equal expected, Post.order("body asc").where("id = 1").unscope(:order).or(Post.where("id = 2")).to_a
+ assert_equal expected, Post.order(Arel.sql("body asc")).where("id = 1").unscope(:order).or(Post.where("id = 2")).to_a
end
def test_or_with_incompatible_unscope
error = assert_raises ArgumentError do
- Post.order("body asc").where("id = 1").or(Post.order("body asc").where("id = 2").unscope(:order)).to_a
+ Post.order(Arel.sql("body asc")).where("id = 1").or(Post.order(Arel.sql("body asc")).where("id = 2").unscope(:order)).to_a
end
assert_equal "Relation passed to #or must be structurally compatible. Incompatible values: [:order]", error.message
@@ -101,7 +101,7 @@ module ActiveRecord
end
def test_or_inside_named_scope
- expected = Post.where("body LIKE '\%a\%' OR title LIKE ?", "%'%").order("id DESC").to_a
+ expected = Post.where("body LIKE '\%a\%' OR title LIKE ?", "%'%").order(Arel.sql("id DESC")).to_a
assert_equal expected, Post.order(id: :desc).typographically_interesting
end