Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 6.0 compatibility #10

Merged
merged 1 commit into from
Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,32 @@ sudo: false
cache: bundler
bundler_args: --no-deployment
language: ruby
services: mysql
rvm:
- 2.2
- 2.3
- 2.4
- 2.5
- 2.6
gemfile:
- gemfiles/rails3.2.gemfile
- gemfiles/rails4.2.gemfile
- gemfiles/rails5.0.gemfile
- gemfiles/rails5.1.gemfile
- gemfiles/rails5.2.gemfile
- gemfiles/rails6.0.gemfile
branches:
only: master
matrix:
exclude:
- rvm: 2.4
gemfile: gemfiles/rails6.0.gemfile
- rvm: 2.5
gemfile: gemfiles/rails4.2.gemfile
- rvm: 2.5
gemfile: gemfiles/rails5.0.gemfile
- rvm: 2.6
gemfile: gemfiles/rails4.2.gemfile
- rvm: 2.6
gemfile: gemfiles/rails5.0.gemfile
- rvm: 2.6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure why we wouldn’t test older versions of Rails on newer versions of Ruby. I understand that testing all possible combinations may be too time consuming.

gemfile: gemfiles/rails5.1.gemfile
- rvm: 2.6
gemfile: gemfiles/rails5.2.gemfile
3 changes: 1 addition & 2 deletions gemfiles/rails3.2.gemfile → gemfiles/rails6.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ source 'https://rubygems.org'

gemspec path: '../'

gem 'activerecord', '~> 3.2.22'
gem 'mysql2', '~> 0.3.20'
gem 'activerecord', '~> 6.0.0'

eval_gemfile 'common.rb'
2 changes: 1 addition & 1 deletion lib/phenix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def drop_databases
end

def for_each_database
ActiveRecord::Base.configurations.each do |name, conf|
ActiveRecord::Base.configurations.to_h.each do |name, conf|
next if conf['database'].nil?
next if Phenix.skip_database.call(name, conf)
yield(name, conf)
Expand Down
2 changes: 1 addition & 1 deletion phenix.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.require_paths = ['lib']

s.add_dependency 'bundler'
s.add_dependency 'activerecord', '>= 3.2', '< 6.0 '
s.add_dependency 'activerecord', '>= 4.2', '< 6.1'

s.add_development_dependency 'rake', '~> 10.5'
s.add_development_dependency 'rspec', '~> 3.4'
Expand Down
5 changes: 2 additions & 3 deletions spec/phenix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def with_bad_mysql
let(:complex_database_path) { File.join(test_directory, 'complex_database.yml') }

let(:exists_method) { (ActiveRecord::VERSION::MAJOR < 5 ? :table_exists? : :data_source_exists?) }
let(:database_error) { (ActiveRecord::VERSION::MAJOR < 4 ? Mysql2::Error : ActiveRecord::NoDatabaseError) }

before { Phenix.configure }

Expand Down Expand Up @@ -94,7 +93,7 @@ def with_bad_mysql

it 'creates the databases' do
ActiveRecord::Base.establish_connection(:database2)
expect { ActiveRecord::Base.connection }.to raise_error(database_error)
expect { ActiveRecord::Base.connection }.to raise_error(ActiveRecord::NoDatabaseError)

create_databases(false)

Expand Down Expand Up @@ -184,7 +183,7 @@ def with_bad_mysql
expect(current_database).to eq('phenix_database_2')

ActiveRecord::Base.establish_connection(:database3)
expect { ActiveRecord::Base.connection }.to raise_error(database_error)
expect { ActiveRecord::Base.connection }.to raise_error(ActiveRecord::NoDatabaseError)
end
end
end
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true
require 'bundler/setup'
require 'single_cov'
SingleCov.setup :rspec
SingleCov.setup :rspec, branches: false

require 'phenix'