diff --git a/gemfiles/rails7.1.gemfile b/gemfiles/rails7.1.gemfile index e3d6774..15a3c65 100644 --- a/gemfiles/rails7.1.gemfile +++ b/gemfiles/rails7.1.gemfile @@ -9,6 +9,7 @@ platforms :ruby do gem "factory_bot" gem "minitest" gem "mysql2" + gem "trilogy" gem "pg" gem "rake" gem "rubocop" diff --git a/lib/search_cop/visitors/visitor.rb b/lib/search_cop/visitors/visitor.rb index c8e1341..5f4202f 100644 --- a/lib/search_cop/visitors/visitor.rb +++ b/lib/search_cop/visitors/visitor.rb @@ -8,7 +8,7 @@ class Visitor def initialize(connection) @connection = connection - extend(SearchCop::Visitors::Mysql) if @connection.adapter_name =~ /mysql/i + extend(SearchCop::Visitors::Mysql) if @connection.adapter_name =~ /mysql|trilogy/i extend(SearchCop::Visitors::Postgres) if @connection.adapter_name =~ /postgres|postgis/i extend(SearchCop::Visitors::Sqlite) if @connection.adapter_name =~ /sqlite/i end diff --git a/test/database.yml b/test/database.yml index ffca73f..85c3d61 100644 --- a/test/database.yml +++ b/test/database.yml @@ -4,7 +4,7 @@ sqlite: database: ":memory:" mysql: - adapter: mysql2 + adapter: <%= DATABASE == "mysql" && Rails.version.to_f >= 7.1 ? "trilogy" : "mysql2" %> database: search_cop host: 127.0.0.1 username: root diff --git a/test/test_helper.rb b/test/test_helper.rb index 5cea2f5..0496b0b 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -14,10 +14,11 @@ class SearchCop::TestCase < Minitest::Unit::TestCase; end require "active_record" require "factory_bot" require "yaml" +require "erb" DATABASE = ENV["DATABASE"] || "sqlite" -ActiveRecord::Base.establish_connection YAML.load_file(File.expand_path("database.yml", __dir__))[DATABASE] +ActiveRecord::Base.establish_connection YAML.load(ERB.new(File.read(File.expand_path("database.yml", __dir__))).result)[DATABASE] class User < ActiveRecord::Base; end