From 228401ea98be69d1470aeaa5d3a8c2b3b57a8b82 Mon Sep 17 00:00:00 2001 From: Rui Baltazar Date: Sun, 22 Mar 2020 21:03:03 +0800 Subject: [PATCH 1/6] [#11] Remove old ruby and rails versions from the supported versions --- .travis.yml | 5 +---- Appraisals | 21 ++++----------------- apartment.gemspec | 2 +- gemfiles/rails_5_0.gemfile | 21 ++++++++++----------- gemfiles/rails_5_1.gemfile | 21 ++++++++++----------- gemfiles/rails_5_2.gemfile | 19 +++++++++---------- gemfiles/rails_6_0.gemfile | 21 ++++++++++----------- gemfiles/rails_master.gemfile | 21 ++++++++++----------- 8 files changed, 55 insertions(+), 76 deletions(-) diff --git a/.travis.yml b/.travis.yml index a70df83d..48273b26 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 @@ -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 diff --git a/Appraisals b/Appraisals index 9a5ad27a..519e9767 100644 --- a/Appraisals +++ b/Appraisals @@ -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 @@ -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 diff --git a/apartment.gemspec b/apartment.gemspec index 885fd18e..5f623e4e 100644 --- a/apartment.gemspec +++ b/apartment.gemspec @@ -20,7 +20,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' diff --git a/gemfiles/rails_5_0.gemfile b/gemfiles/rails_5_0.gemfile index 3d1c50a4..a3d3a72c 100644 --- a/gemfiles/rails_5_0.gemfile +++ b/gemfiles/rails_5_0.gemfile @@ -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: "../" diff --git a/gemfiles/rails_5_1.gemfile b/gemfiles/rails_5_1.gemfile index fd285b95..7c75050b 100644 --- a/gemfiles/rails_5_1.gemfile +++ b/gemfiles/rails_5_1.gemfile @@ -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: "../" diff --git a/gemfiles/rails_5_2.gemfile b/gemfiles/rails_5_2.gemfile index fb42246f..09ae9502 100644 --- a/gemfiles/rails_5_2.gemfile +++ b/gemfiles/rails_5_2.gemfile @@ -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: "../" diff --git a/gemfiles/rails_6_0.gemfile b/gemfiles/rails_6_0.gemfile index ec151217..5559b2e8 100644 --- a/gemfiles/rails_6_0.gemfile +++ b/gemfiles/rails_6_0.gemfile @@ -1,24 +1,23 @@ -# frozen_string_literal: true - # This file was generated by Appraisal -source 'http://rubygems.org' +source "http://rubygems.org" -gem 'rails', '~> 6.0.0.rc1' +gem "rails", "~> 6.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 'sqlite3', '~> 1.4' + gem "sqlite3", "~> 1.4" end platforms :jruby do - gem 'activerecord-jdbc-adapter', '~> 60.0.rc1' - gem 'activerecord-jdbcmysql-adapter', '~> 60.0.rc1' - gem 'activerecord-jdbcpostgresql-adapter', '~> 60.0.rc1' + gem "activerecord-jdbc-adapter", "~> 60.0" + gem "activerecord-jdbcpostgresql-adapter", "~> 60.0" + gem "activerecord-jdbcmysql-adapter", "~> 60.0" end -gemspec path: '../' +gemspec path: "../" diff --git a/gemfiles/rails_master.gemfile b/gemfiles/rails_master.gemfile index af85bb04..dd8bccf6 100644 --- a/gemfiles/rails_master.gemfile +++ b/gemfiles/rails_master.gemfile @@ -1,24 +1,23 @@ -# frozen_string_literal: true - # This file was generated by Appraisal -source 'http://rubygems.org' +source "http://rubygems.org" -gem 'rails', git: 'https://github.com/rails/rails.git' +gem "rails", git: "https://github.com/rails/rails.git" +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 'sqlite3', '~> 1.4' + gem "sqlite3", "~> 1.4" 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: "../" From 9583bde5a957fa4839e02adfac5dc2425c6f26cd Mon Sep 17 00:00:00 2001 From: Rui Baltazar Date: Sun, 22 Mar 2020 22:27:42 +0800 Subject: [PATCH 2/6] Fixing rubocop vesion and ignoring gemfiles --- .rubocop.yml | 4 ++++ Gemfile | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index e8cc53e7..06ac8bf4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,6 +4,10 @@ inherit_gem: perx-rubocop: - default.yml +AllCops: + Exclude: + - 'gemfiles/**/*.gemfile' + Style/WordArray: Exclude: - spec/schemas/**/*.rb diff --git a/Gemfile b/Gemfile index 8bad8db6..45de0046 100644 --- a/Gemfile +++ b/Gemfile @@ -4,8 +4,9 @@ source 'http://rubygems.org' gemspec -gem 'rails', '>= 3.1.2' gem 'perx-rubocop', '~> 0.0.3' +gem 'rails', '>= 3.1.2' +gem 'rubocop', '=0.77.0' group :local do gem 'guard-rspec', '~> 4.2' From 1c96ff2149d6f904bfa83044eb5d923456a70fe7 Mon Sep 17 00:00:00 2001 From: Rui Baltazar Date: Thu, 2 Apr 2020 11:09:15 +0800 Subject: [PATCH 3/6] [CI] removed unused exclusions --- .travis.yml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 48273b26..14a51e2f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,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 From d00a354e8d7a3805b92ec18d17580eb917de84ec Mon Sep 17 00:00:00 2001 From: Rui Baltazar Date: Thu, 2 Apr 2020 11:21:40 +0800 Subject: [PATCH 4/6] [Chore] ran rubocop safe autocorrect --- Gemfile | 1 - Guardfile | 4 +- Rakefile | 56 ++++++++++------- spec/dummy/Rakefile | 4 +- .../20110613152810_create_dummy_models.rb | 36 +++++------ .../20111202022214_create_table_books.rb | 4 +- .../20180415260934_create_public_tokens.rb | 4 +- spec/dummy/db/schema.rb | 62 +++++++++---------- spec/dummy/db/seeds.rb | 6 +- spec/dummy_engine/Gemfile | 4 +- spec/dummy_engine/Rakefile | 7 +-- spec/dummy_engine/bin/rails | 8 ++- spec/dummy_engine/dummy_engine.gemspec | 30 ++++----- spec/dummy_engine/test/dummy/Rakefile | 4 +- 14 files changed, 129 insertions(+), 101 deletions(-) diff --git a/Gemfile b/Gemfile index 45de0046..b0f35aba 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,6 @@ gemspec gem 'perx-rubocop', '~> 0.0.3' gem 'rails', '>= 3.1.2' -gem 'rubocop', '=0.77.0' group :local do gem 'guard-rspec', '~> 4.2' diff --git a/Guardfile b/Guardfile index 5d3fa72d..ffec03ce 100644 --- a/Guardfile +++ b/Guardfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # A sample Guardfile # More info at https://github.com/guard/guard#readme @@ -5,7 +7,7 @@ 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" } diff --git a/Rakefile b/Rakefile index 956310f1..735d192c 100644 --- a/Rakefile +++ b/Rakefile @@ -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 @@ -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" @@ -40,29 +46,33 @@ 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 = [] @@ -70,14 +80,13 @@ namespace :postgres do 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 @@ -86,12 +95,16 @@ 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 = [] @@ -99,12 +112,11 @@ 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(' ')} 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 diff --git a/spec/dummy/Rakefile b/spec/dummy/Rakefile index 9724472e..d189df36 100644 --- a/spec/dummy/Rakefile +++ b/spec/dummy/Rakefile @@ -1,7 +1,9 @@ +# frozen_string_literal: true + # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require File.expand_path('../config/application', __FILE__) +require File.expand_path('config/application', __dir__) require 'rake' Dummy::Application.load_tasks diff --git a/spec/dummy/db/migrate/20110613152810_create_dummy_models.rb b/spec/dummy/db/migrate/20110613152810_create_dummy_models.rb index d1f620eb..1da7c0c7 100644 --- a/spec/dummy/db/migrate/20110613152810_create_dummy_models.rb +++ b/spec/dummy/db/migrate/20110613152810_create_dummy_models.rb @@ -1,4 +1,6 @@ -migration_class = (ActiveRecord::VERSION::MAJOR >= 5) ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration +# frozen_string_literal: true + +migration_class = ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration class CreateDummyModels < migration_class def self.up create_table :companies do |t| @@ -10,24 +12,23 @@ def self.up t.string :name t.datetime :birthdate t.string :sex - end - - create_table :delayed_jobs do |t| - t.integer :priority, :default => 0 - t.integer :attempts, :default => 0 - t.text :handler - t.text :last_error - t.datetime :run_at - t.datetime :locked_at - t.datetime :failed_at - t.string :locked_by - t.datetime :created_at - t.datetime :updated_at - t.string :queue - end + end - add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" + create_table :delayed_jobs do |t| + t.integer :priority, default: 0 + t.integer :attempts, default: 0 + t.text :handler + t.text :last_error + t.datetime :run_at + t.datetime :locked_at + t.datetime :failed_at + t.string :locked_by + t.datetime :created_at + t.datetime :updated_at + t.string :queue + end + add_index 'delayed_jobs', %w[priority run_at], name: 'delayed_jobs_priority' end def self.down @@ -35,5 +36,4 @@ def self.down drop_table :users drop_table :delayed_jobs end - end diff --git a/spec/dummy/db/migrate/20111202022214_create_table_books.rb b/spec/dummy/db/migrate/20111202022214_create_table_books.rb index e841e2dd..d525063d 100644 --- a/spec/dummy/db/migrate/20111202022214_create_table_books.rb +++ b/spec/dummy/db/migrate/20111202022214_create_table_books.rb @@ -1,4 +1,6 @@ -migration_class = (ActiveRecord::VERSION::MAJOR >= 5) ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration +# frozen_string_literal: true + +migration_class = ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration class CreateTableBooks < migration_class def up create_table :books do |t| diff --git a/spec/dummy/db/migrate/20180415260934_create_public_tokens.rb b/spec/dummy/db/migrate/20180415260934_create_public_tokens.rb index c24c45bf..24e27249 100644 --- a/spec/dummy/db/migrate/20180415260934_create_public_tokens.rb +++ b/spec/dummy/db/migrate/20180415260934_create_public_tokens.rb @@ -1,4 +1,6 @@ -migration_class = (ActiveRecord::VERSION::MAJOR >= 5) ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration +# frozen_string_literal: true + +migration_class = ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration class CreatePublicTokens < migration_class def up create_table :public_tokens do |t| diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb index 3fb281f7..ab0d1c00 100644 --- a/spec/dummy/db/schema.rb +++ b/spec/dummy/db/schema.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -10,46 +12,44 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_04_15_260934) do - +ActiveRecord::Schema.define(version: 20_180_415_260_934) do # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" + enable_extension 'plpgsql' - create_table "books", force: :cascade do |t| - t.string "name" - t.integer "pages" - t.datetime "published" + create_table 'books', force: :cascade do |t| + t.string 'name' + t.integer 'pages' + t.datetime 'published' end - create_table "companies", force: :cascade do |t| - t.boolean "dummy" - t.string "database" + create_table 'companies', force: :cascade do |t| + t.boolean 'dummy' + t.string 'database' end - create_table "delayed_jobs", force: :cascade do |t| - t.integer "priority", default: 0 - t.integer "attempts", default: 0 - t.text "handler" - t.text "last_error" - t.datetime "run_at" - t.datetime "locked_at" - t.datetime "failed_at" - t.string "locked_by" - t.datetime "created_at" - t.datetime "updated_at" - t.string "queue" - t.index ["priority", "run_at"], name: "delayed_jobs_priority" + create_table 'delayed_jobs', force: :cascade do |t| + t.integer 'priority', default: 0 + t.integer 'attempts', default: 0 + t.text 'handler' + t.text 'last_error' + t.datetime 'run_at' + t.datetime 'locked_at' + t.datetime 'failed_at' + t.string 'locked_by' + t.datetime 'created_at' + t.datetime 'updated_at' + t.string 'queue' + t.index %w[priority run_at], name: 'delayed_jobs_priority' end - create_table "public_tokens", id: :serial, force: :cascade do |t| - t.string "token" - t.integer "user_id" + create_table 'public_tokens', id: :serial, force: :cascade do |t| + t.string 'token' + t.integer 'user_id' end - create_table "users", force: :cascade do |t| - t.string "name" - t.datetime "birthdate" - t.string "sex" + create_table 'users', force: :cascade do |t| + t.string 'name' + t.datetime 'birthdate' + t.string 'sex' end - end diff --git a/spec/dummy/db/seeds.rb b/spec/dummy/db/seeds.rb index 4aa28df6..66ad2762 100644 --- a/spec/dummy/db/seeds.rb +++ b/spec/dummy/db/seeds.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + def create_users - 3.times {|x| User.where(name: "Some User #{x}").first_or_create! } + 3.times { |x| User.where(name: "Some User #{x}").first_or_create! } end -create_users \ No newline at end of file +create_users diff --git a/spec/dummy_engine/Gemfile b/spec/dummy_engine/Gemfile index 2ae66b0d..59f9baba 100644 --- a/spec/dummy_engine/Gemfile +++ b/spec/dummy_engine/Gemfile @@ -1,4 +1,6 @@ -source "https://rubygems.org" +# frozen_string_literal: true + +source 'https://rubygems.org' # Declare your gem's dependencies in dummy_engine.gemspec. # Bundler will treat runtime dependencies like base dependencies, and diff --git a/spec/dummy_engine/Rakefile b/spec/dummy_engine/Rakefile index 565abf87..72a61a74 100644 --- a/spec/dummy_engine/Rakefile +++ b/spec/dummy_engine/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require 'bundler/setup' rescue LoadError @@ -14,11 +16,9 @@ RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_files.include('lib/**/*.rb') end -APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) +APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__) load 'rails/tasks/engine.rake' - - Bundler::GemHelper.install_tasks require 'rake/testtask' @@ -30,5 +30,4 @@ Rake::TestTask.new(:test) do |t| t.verbose = false end - task default: :test diff --git a/spec/dummy_engine/bin/rails b/spec/dummy_engine/bin/rails index cb6a9e45..800e13a6 100755 --- a/spec/dummy_engine/bin/rails +++ b/spec/dummy_engine/bin/rails @@ -1,11 +1,13 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. -ENGINE_ROOT = File.expand_path('../..', __FILE__) -ENGINE_PATH = File.expand_path('../../lib/dummy_engine/engine', __FILE__) +ENGINE_ROOT = File.expand_path('..', __dir__) +ENGINE_PATH = File.expand_path('../lib/dummy_engine/engine', __dir__) # Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) require 'rails/all' diff --git a/spec/dummy_engine/dummy_engine.gemspec b/spec/dummy_engine/dummy_engine.gemspec index d17f9156..6bd6cca8 100644 --- a/spec/dummy_engine/dummy_engine.gemspec +++ b/spec/dummy_engine/dummy_engine.gemspec @@ -1,24 +1,26 @@ -$:.push File.expand_path("../lib", __FILE__) +# frozen_string_literal: true + +$:.push File.expand_path('lib', __dir__) # Maintain your gem's version: -require "dummy_engine/version" +require 'dummy_engine/version' # Describe your gem and declare its dependencies: Gem::Specification.new do |s| - s.name = "dummy_engine" + s.name = 'dummy_engine' s.version = DummyEngine::VERSION - s.authors = ["Your name"] - s.email = ["Your email"] - s.homepage = "" - s.summary = "Summary of DummyEngine." - s.description = "Description of DummyEngine." - s.license = "MIT" + s.authors = ['Your name'] + s.email = ['Your email'] + s.homepage = '' + s.summary = 'Summary of DummyEngine.' + s.description = 'Description of DummyEngine.' + s.license = 'MIT' - s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] - s.test_files = Dir["test/**/*"] + s.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.rdoc'] + s.test_files = Dir['test/**/*'] - s.add_dependency "rails", "~> 4.1.6" - s.add_dependency "apartment" + s.add_dependency 'apartment' + s.add_dependency 'rails', '~> 4.1.6' - s.add_development_dependency "sqlite3" + s.add_development_dependency 'sqlite3' end diff --git a/spec/dummy_engine/test/dummy/Rakefile b/spec/dummy_engine/test/dummy/Rakefile index ba6b733d..e51cf0e1 100644 --- a/spec/dummy_engine/test/dummy/Rakefile +++ b/spec/dummy_engine/test/dummy/Rakefile @@ -1,6 +1,8 @@ +# frozen_string_literal: true + # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require File.expand_path('../config/application', __FILE__) +require File.expand_path('config/application', __dir__) Rails.application.load_tasks From 9ace36f6cd30a595988e504048e3baa8a1481495 Mon Sep 17 00:00:00 2001 From: Rui Baltazar Date: Thu, 2 Apr 2020 11:27:32 +0800 Subject: [PATCH 5/6] Remove test related files from gem --- apartment.gemspec | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apartment.gemspec b/apartment.gemspec index 5f623e4e..4d8d1884 100644 --- a/apartment.gemspec +++ b/apartment.gemspec @@ -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 = ['ryan@influitive.com', 'brad@influitive.com', 'rui.p.baltazar@gmail.com'] - 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'] From 1970439e6131b39596fbe363e9ec712ef559ef67 Mon Sep 17 00:00:00 2001 From: Rui Baltazar Date: Thu, 2 Apr 2020 11:31:38 +0800 Subject: [PATCH 6/6] [Chore] fixed rubocop warning --- spec/dummy_engine/dummy_engine.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/dummy_engine/dummy_engine.gemspec b/spec/dummy_engine/dummy_engine.gemspec index 6bd6cca8..afb00e8f 100644 --- a/spec/dummy_engine/dummy_engine.gemspec +++ b/spec/dummy_engine/dummy_engine.gemspec @@ -1,6 +1,6 @@ # frozen_string_literal: true -$:.push File.expand_path('lib', __dir__) +$LOAD_PATH << File.expand_path('lib', __dir__) # Maintain your gem's version: require 'dummy_engine/version'