diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2392eacc..bfb06b3f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,6 +16,20 @@ jobs: --health-interval 10s --health-timeout 5s --health-retries 5 + mysql: + image: mysql:5.7 + ports: + - 3306:3306 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_USER: github + MYSQL_PASSWORD: github + MYSQL_DATABASE: activerecord_import_test + options: >- + --health-cmd "mysqladmin ping -h localhost" + --health-interval 10s + --health-timeout 5s + --health-retries 5 strategy: fail-fast: false matrix: @@ -81,6 +95,7 @@ jobs: with: ruby-version: ${{ matrix.ruby }} bundler-cache: true + rubygems: latest - name: Set up databases run: | sudo /etc/init.d/mysql start @@ -110,6 +125,9 @@ jobs: run: | bundle exec rake test:spatialite bundle exec rake test:sqlite3 + - name: Run trilogy tests + if: ${{ matrix.env.AR_VERSION >= '7.0' && matrix.ruby != 'jruby' }} + run: bundle exec rake test:trilogy lint: runs-on: ubuntu-latest env: diff --git a/Gemfile b/Gemfile index 7a0c4d27..4338f338 100644 --- a/Gemfile +++ b/Gemfile @@ -26,6 +26,10 @@ platforms :ruby do gem "sqlite3", "~> #{sqlite3_version}" # seamless_database_pool requires Ruby ~> 2.0 gem "seamless_database_pool", "~> 1.0.20" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0.0') + gem "trilogy" if version >= 6.0 + if version >= 6.0 && version <= 7.0 + gem "activerecord-trilogy-adapter" + end end platforms :jruby do @@ -37,7 +41,11 @@ platforms :jruby do end # Support libs -gem "factory_bot" +if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.0.0") + gem "factory_bot" +else + gem "factory_bot", "~> 5", "< 6.4.5" +end gem "timecop" gem "chronic" gem "mocha", "~> 2.1.0" diff --git a/Rakefile b/Rakefile index fedcf810..4c5b5c99 100644 --- a/Rakefile +++ b/Rakefile @@ -29,6 +29,7 @@ ADAPTERS = %w( sqlite3 spatialite seamless_database_pool + trilogy ).freeze ADAPTERS.each do |adapter| namespace :test do diff --git a/lib/activerecord-import/active_record/adapters/trilogy_adapter.rb b/lib/activerecord-import/active_record/adapters/trilogy_adapter.rb new file mode 100644 index 00000000..201c2bb4 --- /dev/null +++ b/lib/activerecord-import/active_record/adapters/trilogy_adapter.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +require "active_record/connection_adapters/trilogy_adapter" +require "activerecord-import/adapters/trilogy_adapter" + +class ActiveRecord::ConnectionAdapters::TrilogyAdapter + include ActiveRecord::Import::TrilogyAdapter +end diff --git a/lib/activerecord-import/adapters/trilogy_adapter.rb b/lib/activerecord-import/adapters/trilogy_adapter.rb new file mode 100644 index 00000000..080c2db3 --- /dev/null +++ b/lib/activerecord-import/adapters/trilogy_adapter.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require "activerecord-import/adapters/mysql_adapter" + +module ActiveRecord::Import::TrilogyAdapter + include ActiveRecord::Import::MysqlAdapter +end diff --git a/test/adapters/trilogy.rb b/test/adapters/trilogy.rb new file mode 100644 index 00000000..2f47249b --- /dev/null +++ b/test/adapters/trilogy.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +ENV["ARE_DB"] = "trilogy" + +if ENV['AR_VERSION'].to_f <= 7.0 + require "activerecord-trilogy-adapter" + require "trilogy_adapter/connection" + ActiveRecord::Base.extend TrilogyAdapter::Connection +end diff --git a/test/database.yml.sample b/test/database.yml.sample index dc8d810a..34ee8ede 100644 --- a/test/database.yml.sample +++ b/test/database.yml.sample @@ -52,3 +52,8 @@ sqlite3: &sqlite3 spatialite: <<: *sqlite3 + +trilogy: + <<: *common + adapter: trilogy + host: mysql diff --git a/test/github/database.yml b/test/github/database.yml index a807c871..2d1fefe1 100644 --- a/test/github/database.yml +++ b/test/github/database.yml @@ -66,3 +66,7 @@ sqlite3: &sqlite3 spatialite: <<: *sqlite3 + +trilogy: + <<: *common + adapter: trilogy diff --git a/test/trilogy/import_test.rb b/test/trilogy/import_test.rb new file mode 100644 index 00000000..b256c2b7 --- /dev/null +++ b/test/trilogy/import_test.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require File.expand_path("#{File.dirname(__FILE__)}/../test_helper") +require File.expand_path("#{File.dirname(__FILE__)}/../support/assertions") +require File.expand_path("#{File.dirname(__FILE__)}/../support/mysql/import_examples") + +should_support_mysql_import_functionality