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

[Resolves #11] Remove old ruby and rails versions from the supported versions #20

Merged
merged 6 commits into from
Apr 2, 2020
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
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ inherit_gem:
perx-rubocop:
- default.yml

AllCops:
Exclude:
- 'gemfiles/**/*.gemfile'

Style/WordArray:
Exclude:
- spec/schemas/**/*.rb
Expand Down
24 changes: 1 addition & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ services:
- docker
rvm:
- jruby-9.2.11.0
- 2.1.9
- 2.2.9
- 2.3.6
- 2.4.3
- 2.5.0
- 2.6.2
Expand All @@ -19,12 +16,12 @@ branches:
- development

gemfile:
- gemfiles/rails_4_2.gemfile
- gemfiles/rails_5_0.gemfile
- gemfiles/rails_5_1.gemfile
- gemfiles/rails_5_2.gemfile
- gemfiles/rails_6_0.gemfile
- gemfiles/rails_master.gemfile

bundler_args: --without local
before_install:
- sudo /etc/init.d/mysql stop
Expand All @@ -40,26 +37,7 @@ jobs:
allow_failures:
- rvm: ruby-head
- gemfile: gemfiles/rails_master.gemfile
- rvm: 2.2.9
gemfile: gemfiles/rails_5_2.gemfile
# JRuby does not provide support for anything below rails 5
- rvm: jruby-9.2.11.0
gemfile: gemfiles/rails_4_2.gemfile
exclude:
- rvm: 2.1.9
gemfile: gemfiles/rails_5_0.gemfile
- rvm: 2.1.9
gemfile: gemfiles/rails_5_1.gemfile
- rvm: 2.1.9
gemfile: gemfiles/rails_5_2.gemfile
- rvm: 2.1.9
gemfile: gemfiles/rails_6_0.gemfile
- rvm: 2.1.9
gemfile: gemfiles/rails_master.gemfile
- rvm: 2.2.9
gemfile: gemfiles/rails_6_0.gemfile
- rvm: 2.3.6
gemfile: gemfiles/rails_6_0.gemfile
- rvm: 2.4.3
gemfile: gemfiles/rails_6_0.gemfile
fast_finish: true
Expand Down
21 changes: 4 additions & 17 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
# frozen_string_literal: true

appraise 'rails-4-2' do
gem 'rails', '~> 4.2.0'
platforms :ruby do
gem 'pg', '< 1.0.0'
gem 'mysql2', '~> 0.4.0'
end
platforms :jruby do
gem 'activerecord-jdbc-adapter', '~> 1.3'
gem 'activerecord-jdbcpostgresql-adapter', '~> 1.3'
gem 'activerecord-jdbcmysql-adapter', '~> 1.3'
end
end

appraise 'rails-5-0' do
gem 'rails', '~> 5.0.0'
platforms :ruby do
Expand Down Expand Up @@ -47,14 +34,14 @@ appraise 'rails-5-2' do
end

appraise 'rails-6-0' do
gem 'rails', '~> 6.0.0.rc1'
gem 'rails', '~> 6.0.0'
platforms :ruby do
gem 'sqlite3', '~> 1.4'
end
platforms :jruby do
gem 'activerecord-jdbc-adapter', '~> 60.0.rc1'
gem 'activerecord-jdbcpostgresql-adapter', '~> 60.0.rc1'
gem 'activerecord-jdbcmysql-adapter', '~> 60.0.rc1'
gem 'activerecord-jdbc-adapter', '~> 60.0'
gem 'activerecord-jdbcpostgresql-adapter', '~> 60.0'
gem 'activerecord-jdbcmysql-adapter', '~> 60.0'
end
end

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ source 'http://rubygems.org'

gemspec

gem 'rails', '>= 3.1.2'
gem 'perx-rubocop', '~> 0.0.3'
gem 'rails', '>= 3.1.2'

group :local do
gem 'guard-rspec', '~> 4.2'
Expand Down
4 changes: 3 additions & 1 deletion Guardfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# frozen_string_literal: true

# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard :rspec do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/apartment/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
watch(%r{^lib/apartment/(.+)\.rb$}) { |m| "spec/integration/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
watch('spec/spec_helper.rb') { 'spec' }

# # Rails example
# watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
Expand Down
56 changes: 34 additions & 22 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
require 'bundler' rescue 'You must `gem install bundler` and `bundle install` to run rake tasks'
# frozen_string_literal: true

begin
require 'bundler'
rescue StandardError
'You must `gem install bundler` and `bundle install` to run rake tasks'
end
Bundler.setup
Bundler::GemHelper.install_tasks

require 'appraisal'

require "rspec"
require "rspec/core/rake_task"
require 'rspec'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec => %w{ db:copy_credentials db:test:prepare }) do |spec|
spec.pattern = "spec/**/*_spec.rb"
RSpec::Core::RakeTask.new(spec: %w[db:copy_credentials db:test:prepare]) do |spec|
spec.pattern = 'spec/**/*_spec.rb'
# spec.rspec_opts = '--order rand:47078'
end

namespace :spec do
[:tasks, :unit, :adapters, :integration].each do |type|
%i[tasks unit adapters integration].each do |type|
RSpec::Core::RakeTask.new(type => :spec) do |spec|
spec.pattern = "spec/#{type}/**/*_spec.rb"
end
Expand All @@ -27,11 +33,11 @@ task :console do
Pry.start
end

task :default => :spec
task default: :spec

namespace :db do
namespace :test do
task :prepare => %w{postgres:drop_db postgres:build_db mysql:drop_db mysql:build_db}
task prepare: %w[postgres:drop_db postgres:build_db mysql:drop_db mysql:build_db]
end

desc "copy sample database credential files over if real files don't exist"
Expand All @@ -40,44 +46,47 @@ namespace :db do
apartment_db_file = 'spec/config/database.yml'
rails_db_file = 'spec/dummy/config/database.yml'

FileUtils.copy(apartment_db_file + '.sample', apartment_db_file, :verbose => true) unless File.exists?(apartment_db_file)
FileUtils.copy(rails_db_file + '.sample', rails_db_file, :verbose => true) unless File.exists?(rails_db_file)
FileUtils.copy(apartment_db_file + '.sample', apartment_db_file, verbose: true) unless File.exist?(apartment_db_file)
FileUtils.copy(rails_db_file + '.sample', rails_db_file, verbose: true) unless File.exist?(rails_db_file)
end
end

namespace :postgres do
require 'active_record'
require "#{File.join(File.dirname(__FILE__), 'spec', 'support', 'config')}"
require File.join(File.dirname(__FILE__), 'spec', 'support', 'config').to_s

desc 'Build the PostgreSQL test databases'
task :build_db do
params = []
params << "-E UTF8"
params << '-E UTF8'
params << pg_config['database']
params << "-U#{pg_config['username']}"
params << "-h#{pg_config['host']}" if pg_config['host']
params << "-p#{pg_config['port']}" if pg_config['port']
%x{ createdb #{params.join(' ')} } rescue "test db already exists"
begin
`createdb #{params.join(' ')}`
rescue StandardError
'test db already exists'
end
ActiveRecord::Base.establish_connection pg_config
migrate
end

desc "drop the PostgreSQL test database"
desc 'drop the PostgreSQL test database'
task :drop_db do
puts "dropping database #{pg_config['database']}"
params = []
params << pg_config['database']
params << "-U#{pg_config['username']}"
params << "-h#{pg_config['host']}" if pg_config['host']
params << "-p#{pg_config['port']}" if pg_config['port']
%x{ dropdb #{params.join(' ')} }
`dropdb #{params.join(' ')}`
end

end

namespace :mysql do
require 'active_record'
require "#{File.join(File.dirname(__FILE__), 'spec', 'support', 'config')}"
require File.join(File.dirname(__FILE__), 'spec', 'support', 'config').to_s

desc 'Build the MySQL test databases'
task :build_db do
Expand All @@ -86,25 +95,28 @@ namespace :mysql do
params << "-u #{my_config['username']}" if my_config['username']
params << "-p#{my_config['password']}" if my_config['password']
params << "--port #{my_config['port']}" if my_config['port']
%x{ mysqladmin #{params.join(' ')} create #{my_config['database']} } rescue "test db already exists"
begin
`mysqladmin #{params.join(' ')} create #{my_config['database']}`
rescue StandardError
'test db already exists'
end
ActiveRecord::Base.establish_connection my_config
migrate
end

desc "drop the MySQL test database"
desc 'drop the MySQL test database'
task :drop_db do
puts "dropping database #{my_config['database']}"
params = []
params << "-h #{my_config['host']}" if my_config['host']
params << "-u #{my_config['username']}" if my_config['username']
params << "-p#{my_config['password']}" if my_config['password']
params << "--port #{my_config['port']}" if my_config['port']
%x{ mysqladmin #{params.join(' ')} drop #{my_config['database']} --force}
`mysqladmin #{params.join(' ')} drop #{my_config['database']} --force`
end

end

# TODO clean this up
# TODO: clean this up
def config
Apartment::Test.config['connections']
end
Expand Down
12 changes: 10 additions & 2 deletions apartment.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ Gem::Specification.new do |s|
s.summary = 'A Ruby gem for managing database multitenancy. Apartment Gem drop in replacement'
s.description = 'Apartment allows Rack applications to deal with database multitenancy through ActiveRecord'
s.email = ['[email protected]', '[email protected]', '[email protected]']
s.files = `git ls-files`.split($/)
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been
# added into git.
s.files = Dir.chdir(File.expand_path(__dir__)) do
`git ls-files -z`.split("\x0").reject do |f|
# NOTE: ignore all test related
f.match(%r{^(test|spec|features)/})
end
end
s.executables = s.files.grep(%r{^bin/}).map { |f| File.basename(f) }
s.test_files = s.files.grep(%r{^(test|spec|features)/})
s.require_paths = ['lib']
Expand All @@ -20,7 +28,7 @@ Gem::Specification.new do |s|
s.licenses = ['MIT']

# must be >= 3.1.2 due to bug in prepared_statements
s.add_dependency 'activerecord', '>= 3.1.2', '< 6.1'
s.add_dependency 'activerecord', '>= 5.0.0', '< 6.1'
s.add_dependency 'parallel', '< 2.0'
s.add_dependency 'public_suffix', '>= 2.0.5', '< 5.0'
s.add_dependency 'rack', '>= 1.3.6', '< 3.0'
Expand Down
21 changes: 10 additions & 11 deletions gemfiles/rails_5_0.gemfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source 'http://rubygems.org'
source "http://rubygems.org"

gem 'rails', '~> 5.0.0'
gem "rails", "~> 5.0.0"
gem "perx-rubocop", "~> 0.0.3"

group :local do
gem 'guard-rspec', '~> 4.2'
gem 'pry'
gem "guard-rspec", "~> 4.2"
gem "pry"
end

platforms :ruby do
gem 'pg', '< 1.0.0'
gem "pg", "< 1.0.0"
end

platforms :jruby do
gem 'activerecord-jdbc-adapter', '~> 50.0'
gem 'activerecord-jdbcmysql-adapter', '~> 50.0'
gem 'activerecord-jdbcpostgresql-adapter', '~> 50.0'
gem "activerecord-jdbc-adapter", "~> 50.0"
gem "activerecord-jdbcpostgresql-adapter", "~> 50.0"
gem "activerecord-jdbcmysql-adapter", "~> 50.0"
end

gemspec path: '../'
gemspec path: "../"
21 changes: 10 additions & 11 deletions gemfiles/rails_5_1.gemfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source 'http://rubygems.org'
source "http://rubygems.org"

gem 'rails', '~> 5.1.0'
gem "rails", "~> 5.1.0"
gem "perx-rubocop", "~> 0.0.3"

group :local do
gem 'guard-rspec', '~> 4.2'
gem 'pry'
gem "guard-rspec", "~> 4.2"
gem "pry"
end

platforms :ruby do
gem 'pg', '< 1.0.0'
gem "pg", "< 1.0.0"
end

platforms :jruby do
gem 'activerecord-jdbc-adapter', '~> 51.0'
gem 'activerecord-jdbcmysql-adapter', '~> 51.0'
gem 'activerecord-jdbcpostgresql-adapter', '~> 51.0'
gem "activerecord-jdbc-adapter", "~> 51.0"
gem "activerecord-jdbcpostgresql-adapter", "~> 51.0"
gem "activerecord-jdbcmysql-adapter", "~> 51.0"
end

gemspec path: '../'
gemspec path: "../"
19 changes: 9 additions & 10 deletions gemfiles/rails_5_2.gemfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source 'http://rubygems.org'
source "http://rubygems.org"

gem 'rails', '~> 5.2.0'
gem "rails", "~> 5.2.0"
gem "perx-rubocop", "~> 0.0.3"

group :local do
gem 'guard-rspec', '~> 4.2'
gem 'pry'
gem "guard-rspec", "~> 4.2"
gem "pry"
end

platforms :jruby do
gem 'activerecord-jdbc-adapter', '~> 52.0'
gem 'activerecord-jdbcmysql-adapter', '~> 52.0'
gem 'activerecord-jdbcpostgresql-adapter', '~> 52.0'
gem "activerecord-jdbc-adapter", "~> 52.0"
gem "activerecord-jdbcpostgresql-adapter", "~> 52.0"
gem "activerecord-jdbcmysql-adapter", "~> 52.0"
end

gemspec path: '../'
gemspec path: "../"
Loading