From 7dc16ddd48f479f75ccd0200ea52c34708e99889 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Thu, 25 Feb 2021 13:07:29 +0900 Subject: [PATCH] Use `current_adapter?` over `ActiveRecord::Base.connection.adapter_name` in tests --- activerecord/test/cases/column_alias_test.rb | 10 ++-------- activerecord/test/cases/fixtures_test.rb | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/activerecord/test/cases/column_alias_test.rb b/activerecord/test/cases/column_alias_test.rb index a883d21fb8..58d23c08da 100644 --- a/activerecord/test/cases/column_alias_test.rb +++ b/activerecord/test/cases/column_alias_test.rb @@ -6,14 +6,8 @@ require "models/topic" class TestColumnAlias < ActiveRecord::TestCase fixtures :topics - QUERY = if "Oracle" == ActiveRecord::Base.connection.adapter_name - "SELECT id AS pk FROM topics WHERE ROWNUM < 2" - else - "SELECT id AS pk FROM topics" - end - def test_column_alias - records = Topic.connection.select_all(QUERY) - assert_equal "pk", records[0].keys[0] + records = Topic.connection.select_all("SELECT id AS pk FROM topics") + assert_equal ["pk"], records.columns end end diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb index 7f56fea4aa..3e62653e9a 100644 --- a/activerecord/test/cases/fixtures_test.rb +++ b/activerecord/test/cases/fixtures_test.rb @@ -1103,7 +1103,7 @@ class FoxyFixturesTest < ActiveRecord::TestCase fixtures :parrots, :parrots_pirates, :pirates, :treasures, :mateys, :ships, :computers, :developers, :"admin/accounts", :"admin/users", :live_parrots, :dead_parrots, :books - if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" + if current_adapter?(:PostgreSQLAdapter) require "models/uuid_parent" require "models/uuid_child" fixtures :uuid_parents, :uuid_children