Skip to content

Commit

Permalink
Change
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkamel committed May 29, 2024
1 parent 977f59a commit 40aa4fb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions gemfiles/rails7.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ platforms :ruby do
gem "factory_bot"
gem "minitest"
gem "mysql2"
gem "trilogy"
gem "pg"
gem "rake"
gem "rubocop"
Expand Down
2 changes: 1 addition & 1 deletion lib/search_cop/visitors/visitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 40aa4fb

Please sign in to comment.