diff options
Diffstat (limited to 'activerecord/test/cases/relations_test.rb')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 65 |
1 files changed, 13 insertions, 52 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 316ea75e36..ae1dc35bff 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "cases/helper" require "models/tag" require "models/tagging" @@ -1592,7 +1594,11 @@ class RelationTest < ActiveRecord::TestCase assert_equal ["comments"], scope.references_values scope = Post.order("#{Comment.quoted_table_name}.#{Comment.quoted_primary_key}") - assert_equal ["comments"], scope.references_values + if current_adapter?(:OracleAdapter) + assert_equal ["COMMENTS"], scope.references_values + else + assert_equal ["comments"], scope.references_values + end scope = Post.order("comments.body", "yaks.body") assert_equal ["comments", "yaks"], scope.references_values @@ -1613,7 +1619,11 @@ class RelationTest < ActiveRecord::TestCase assert_equal %w(comments), scope.references_values scope = Post.reorder("#{Comment.quoted_table_name}.#{Comment.quoted_primary_key}") - assert_equal ["comments"], scope.references_values + if current_adapter?(:OracleAdapter) + assert_equal ["COMMENTS"], scope.references_values + else + assert_equal ["comments"], scope.references_values + end scope = Post.reorder("comments.body", "yaks.body") assert_equal %w(comments yaks), scope.references_values @@ -1751,7 +1761,7 @@ class RelationTest < ActiveRecord::TestCase test "relations with cached arel can't be mutated [internal API]" do relation = Post.all - relation.count + relation.arel assert_raises(ActiveRecord::ImmutableRelation) { relation.limit!(5) } assert_raises(ActiveRecord::ImmutableRelation) { relation.where!("1 = 2") } @@ -1850,37 +1860,6 @@ class RelationTest < ActiveRecord::TestCase assert_equal 1, posts.unscope(where: :body).count end - def test_unscope_removes_binds - left = Post.where(id: 20) - - binds = [bind_attribute("id", 20, Post.type_for_attribute("id"))] - assert_equal binds, left.bound_attributes - - relation = left.unscope(where: :id) - assert_equal [], relation.bound_attributes - end - - def test_merging_removes_rhs_binds - left = Post.where(id: 20) - right = Post.where(id: [1, 2, 3, 4]) - - binds = [bind_attribute("id", 20, Post.type_for_attribute("id"))] - assert_equal binds, left.bound_attributes - - merged = left.merge(right) - assert_equal [], merged.bound_attributes - end - - def test_merging_keeps_lhs_binds - binds = [bind_attribute("id", 20, Post.type_for_attribute("id"))] - - right = Post.where(id: 20) - left = Post.where(id: 10) - - merged = left.merge(right) - assert_equal binds, merged.bound_attributes - end - def test_locked_should_not_build_arel posts = Post.locked assert posts.locked? @@ -1891,24 +1870,6 @@ class RelationTest < ActiveRecord::TestCase assert_equal "Thank you for the welcome,Thank you again for the welcome", Post.first.comments.join(",") end - def test_connection_adapters_can_reorder_binds - posts = Post.limit(1).offset(2) - - stubbed_connection = Post.connection.dup - def stubbed_connection.combine_bind_parameters(**kwargs) - offset = kwargs[:offset] - kwargs[:offset] = kwargs[:limit] - kwargs[:limit] = offset - super(**kwargs) - end - - posts.define_singleton_method(:connection) do - stubbed_connection - end - - assert_equal 2, posts.to_a.length - end - test "#skip_query_cache!" do Post.cache do assert_queries(1) do |