From c9aec36fead11a66b12c6b685830076232e90470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Fija=C5=82kowski?= Date: Thu, 5 Dec 2019 16:36:58 +0100 Subject: [PATCH 1/8] Add rails 6.0 config to travis --- .travis.yml | 1 + gemfiles/rails_6_0.gemfile | 45 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 gemfiles/rails_6_0.gemfile diff --git a/.travis.yml b/.travis.yml index a583f5574..51e28b0ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ gemfile: - gemfiles/rails_5_0.gemfile - gemfiles/rails_5_1.gemfile - gemfiles/rails_5_2.gemfile + - gemfiles/rails_6_0.gemfile env: global: diff --git a/gemfiles/rails_6_0.gemfile b/gemfiles/rails_6_0.gemfile new file mode 100644 index 000000000..b3eda7788 --- /dev/null +++ b/gemfiles/rails_6_0.gemfile @@ -0,0 +1,45 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "~> 6.0" +gem "sqlite3", "~> 1.4.1" +gem "mysql2" +gem "pg" + +group :development, :test do + gem "attr_encrypted" + gem "figaro", git: "https://github.com/laserlemon/figaro" + gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook" + gem "omniauth-github", git: "https://github.com/intridea/omniauth-github" + gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2" + gem 'omniauth-apple' + gem "rack-cors", require: "rack/cors" + gem "thor" + gem "database_cleaner" + gem "factory_bot_rails" + gem "faker" + gem "fuzz_ball" + gem "guard" + gem "guard-minitest" + gem "minitest" + gem "minitest-focus" + gem "minitest-rails" + gem "minitest-reporters" + gem "mocha", ">= 1.5" + gem "pry" + gem "pry-byebug" + gem "pry-remote" + gem "rubocop", require: false +end + +group :test do + gem "rails-controller-testing" + gem "simplecov", require: false +end + +group :development do + gem "github_changelog_generator" +end + +gemspec path: "../" From 4868bed3df6f051478e211c90795a10e3b6f4c35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Fija=C5=82kowski?= Date: Thu, 5 Dec 2019 17:00:32 +0100 Subject: [PATCH 2/8] Exclude Travis Rails 6.0 checks for Ruby below 2.5 --- .travis.yml | 84 ++++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/.travis.yml b/.travis.yml index 51e28b0ae..9882e4df0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,51 +29,55 @@ env: matrix: include: - - rvm: 2.3.8 - gemfile: gemfiles/rails_4_2_mongoid_5.gemfile - env: DEVISE_TOKEN_AUTH_ORM=mongoid - - rvm: 2.3.8 - gemfile: gemfiles/rails_5_1_mongoid_6.gemfile - env: DEVISE_TOKEN_AUTH_ORM=mongoid - - rvm: 2.4.7 - gemfile: gemfiles/rails_5_1_mongoid_7.gemfile - env: DEVISE_TOKEN_AUTH_ORM=mongoid - - rvm: 2.5.6 - gemfile: gemfiles/rails_5_2_mongoid_6.gemfile - env: DEVISE_TOKEN_AUTH_ORM=mongoid - - rvm: 2.5.6 - gemfile: gemfiles/rails_5_2_mongoid_7.gemfile - env: DEVISE_TOKEN_AUTH_ORM=mongoid - - rvm: 2.6.4 - gemfile: gemfiles/rails_5_2_mongoid_7.gemfile - env: DEVISE_TOKEN_AUTH_ORM=mongoid - - name: Code Climate Test Coverage - rmv: 2.5.6 - env: - - CC_TEST_REPORTER_ID=44d7688de8e1b567b4af25ec5083c2cc0a355ab911192a7cbefd1ea25b2ffd3d - - GEMFILE_AR=gemfiles/rails_5_1.gemfile - - GEMFILE_MONGOID=gemfiles/rails_5_1_mongoid_7.gemfile - script: - - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - - chmod +x ./cc-test-reporter - - ./cc-test-reporter before-build - # with ActiveRecord - - bundle install --jobs=3 --retry=3 --gemfile $GEMFILE_AR - - BUNDLE_GEMFILE=$GEMFILE_AR bundle exec rake --trace db:migrate - - BUNDLE_GEMFILE=$GEMFILE_AR bundle exec rake - - ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.active_record.json coverage/.resultset.json - # with Mongoid - - bundle install --jobs=3 --retry=3 --gemfile $GEMFILE_MONGOID - - BUNDLE_GEMFILE=$GEMFILE_MONGOID DEVISE_TOKEN_AUTH_ORM=mongoid bundle exec rake - - ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.mongoid.json coverage/.resultset.json - # merge test results - - if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then + - rvm: 2.3.8 + gemfile: gemfiles/rails_4_2_mongoid_5.gemfile + env: DEVISE_TOKEN_AUTH_ORM=mongoid + - rvm: 2.3.8 + gemfile: gemfiles/rails_5_1_mongoid_6.gemfile + env: DEVISE_TOKEN_AUTH_ORM=mongoid + - rvm: 2.4.7 + gemfile: gemfiles/rails_5_1_mongoid_7.gemfile + env: DEVISE_TOKEN_AUTH_ORM=mongoid + - rvm: 2.5.6 + gemfile: gemfiles/rails_5_2_mongoid_6.gemfile + env: DEVISE_TOKEN_AUTH_ORM=mongoid + - rvm: 2.5.6 + gemfile: gemfiles/rails_5_2_mongoid_7.gemfile + env: DEVISE_TOKEN_AUTH_ORM=mongoid + - rvm: 2.6.4 + gemfile: gemfiles/rails_5_2_mongoid_7.gemfile + env: DEVISE_TOKEN_AUTH_ORM=mongoid + - name: Code Climate Test Coverage + rmv: 2.5.6 + env: + - CC_TEST_REPORTER_ID=44d7688de8e1b567b4af25ec5083c2cc0a355ab911192a7cbefd1ea25b2ffd3d + - GEMFILE_AR=gemfiles/rails_5_1.gemfile + - GEMFILE_MONGOID=gemfiles/rails_5_1_mongoid_7.gemfile + script: + - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + - chmod +x ./cc-test-reporter + - ./cc-test-reporter before-build + # with ActiveRecord + - bundle install --jobs=3 --retry=3 --gemfile $GEMFILE_AR + - BUNDLE_GEMFILE=$GEMFILE_AR bundle exec rake --trace db:migrate + - BUNDLE_GEMFILE=$GEMFILE_AR bundle exec rake + - ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.active_record.json coverage/.resultset.json + # with Mongoid + - bundle install --jobs=3 --retry=3 --gemfile $GEMFILE_MONGOID + - BUNDLE_GEMFILE=$GEMFILE_MONGOID DEVISE_TOKEN_AUTH_ORM=mongoid bundle exec rake + - ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.mongoid.json coverage/.resultset.json + # merge test results + - if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then ./cc-test-reporter sum-coverage coverage/codeclimate.active_record.json coverage/codeclimate.mongoid.json; ./cc-test-reporter upload-coverage; - fi + fi exclude: - rvm: 2.6.4 gemfile: gemfiles/rails_4_2.gemfile + - rvm: 2.3.8 + gemfile: gemfiles/rails_6_0.gemfile + - rvm: 2.4.7 + gemfile: gemfiles/rails_6_0.gemfile fast_finish: true before_install: From 0d47e1f8e5c37485d022dee6b5b9981d0ace9e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Fija=C5=82kowski?= Date: Fri, 6 Dec 2019 17:15:56 +0100 Subject: [PATCH 3/8] Updates tests to be compatible with Rails 6 Rails 6 no longer generates migration with id: :uuid, so I changed the range of two ifs in tests and everything goes well now. --- test/lib/generators/devise_token_auth/install_generator_test.rb | 2 +- .../devise_token_auth/install_generator_with_namespace_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/lib/generators/devise_token_auth/install_generator_test.rb b/test/lib/generators/devise_token_auth/install_generator_test.rb index c58c92faf..dedbe9e05 100644 --- a/test/lib/generators/devise_token_auth/install_generator_test.rb +++ b/test/lib/generators/devise_token_auth/install_generator_test.rb @@ -47,7 +47,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase test 'add primary key type with rails 5 when specified in rails generator' do run_generator %w[--primary_key_type=uuid --force] - if Rails::VERSION::MAJOR >= 5 + if Rails::VERSION::MAJOR == 5 assert_migration 'db/migrate/devise_token_auth_create_users.rb', /create_table\(:users, id: :uuid\) do/ else assert_migration 'db/migrate/devise_token_auth_create_users.rb', /create_table\(:users\) do/ diff --git a/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb b/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb index f407fb052..8b9464f1d 100644 --- a/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +++ b/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb @@ -52,7 +52,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase test 'add primary key type with rails 5 when specified in rails generator' do run_generator %W[#{user_class} auth --primary_key_type=uuid --force] - if Rails::VERSION::MAJOR >= 5 + if Rails::VERSION::MAJOR == 5 assert_migration "db/migrate/devise_token_auth_create_#{table_name}.rb", /create_table\(:#{table_name}, id: :uuid\) do/ else assert_migration "db/migrate/devise_token_auth_create_#{table_name}.rb", /create_table\(:#{table_name}\) do/ From a53911c9d7a40f15069ed6cd6f895162288827d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Fija=C5=82kowski?= Date: Thu, 2 Jan 2020 10:57:04 +0100 Subject: [PATCH 4/8] Add Ruby 2.7.0 to Travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 9882e4df0..0b70a7c4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ rvm: - 2.4.7 - 2.5.6 - 2.6.4 + - 2.7.0 gemfile: - gemfiles/rails_4_2.gemfile From 04f4b9fe793ce2f4d2339bf15df26d1a7c960d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Fija=C5=82kowski?= Date: Thu, 2 Jan 2020 11:48:24 +0100 Subject: [PATCH 5/8] Exclude travis test for Ruby 2.7.0 with Rails 4.2 Ruby 2.7 comes with Bundler 2 which is not compatible with Rails 4 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0b70a7c4d..a4c4ad208 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,6 +75,8 @@ matrix: exclude: - rvm: 2.6.4 gemfile: gemfiles/rails_4_2.gemfile + - rvm: 2.7.0 + gemfile: gemfiles/rails_4_2.gemfile - rvm: 2.3.8 gemfile: gemfiles/rails_6_0.gemfile - rvm: 2.4.7 From 5c0eb170c7af34e225ae2752be714dd337e42814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Fija=C5=82kowski?= Date: Tue, 7 Jan 2020 12:09:07 +0100 Subject: [PATCH 6/8] Add to Travis test for rails 6 + mongoid 7 --- .travis.yml | 5 +++- gemfiles/rails_6_0_mongoid_7.gemfile | 44 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 gemfiles/rails_6_0_mongoid_7.gemfile diff --git a/.travis.yml b/.travis.yml index a4c4ad208..9a8e24341 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,8 +48,11 @@ matrix: - rvm: 2.6.4 gemfile: gemfiles/rails_5_2_mongoid_7.gemfile env: DEVISE_TOKEN_AUTH_ORM=mongoid + - rvm: 2.7.0 + gemfile: gemfiles/rails_6_0_mongoid_7.gemfile + env: DEVISE_TOKEN_AUTH_ORM=mongoid - name: Code Climate Test Coverage - rmv: 2.5.6 + rvm: 2.5.6 env: - CC_TEST_REPORTER_ID=44d7688de8e1b567b4af25ec5083c2cc0a355ab911192a7cbefd1ea25b2ffd3d - GEMFILE_AR=gemfiles/rails_5_1.gemfile diff --git a/gemfiles/rails_6_0_mongoid_7.gemfile b/gemfiles/rails_6_0_mongoid_7.gemfile new file mode 100644 index 000000000..17113954d --- /dev/null +++ b/gemfiles/rails_6_0_mongoid_7.gemfile @@ -0,0 +1,44 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "~> 6.0" +gem "mongoid", "~> 7.0" +gem "mongoid-locker", "~> 2.0" + +group :development, :test do + gem "attr_encrypted" + gem "figaro", git: "https://github.com/laserlemon/figaro" + gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook" + gem "omniauth-github", git: "https://github.com/intridea/omniauth-github" + gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2" + gem "omniauth-apple" + gem "rack-cors", require: "rack/cors" + gem "thor" + gem "database_cleaner" + gem "factory_bot_rails" + gem "faker" + gem "fuzz_ball" + gem "guard" + gem "guard-minitest" + gem "minitest" + gem "minitest-focus" + gem "minitest-rails" + gem "minitest-reporters" + gem "mocha", ">= 1.5" + gem "pry" + gem "pry-byebug" + gem "pry-remote" + gem "rubocop", require: false +end + +group :test do + gem "rails-controller-testing" + gem "simplecov", require: false +end + +group :development do + gem "github_changelog_generator" +end + +gemspec path: "../" From cfc95d0a6a94883351cb0f33650177bc5e3608f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Fija=C5=82kowski?= Date: Tue, 7 Jan 2020 16:52:53 +0100 Subject: [PATCH 7/8] Downgrade mongoid-locker for rails 6 gemfile --- Appraisals | 3 ++- gemfiles/rails_6_0_mongoid_7.gemfile | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Appraisals b/Appraisals index 0a5fd61b8..dfb2bb1e1 100644 --- a/Appraisals +++ b/Appraisals @@ -32,7 +32,8 @@ end { name: '5-1', ruby: '2.4.5', rails: '5.1', mongoid: '7.0' }, { name: '5-2', ruby: '2.5.5', rails: '5.2', mongoid: '6.4' }, { name: '5-2', ruby: '2.5.5', rails: '5.2', mongoid: '7.0' }, - { name: '5-2', ruby: '2.6.2', rails: '5.2', mongoid: '7.0' } + { name: '5-2', ruby: '2.6.2', rails: '5.2', mongoid: '7.0' }, + { name: '6-0', ruby: '2.7.0', rails: '6.0', mongoid: '7.0' } ].each do |set| appraise "rails-#{set[:name]}-mongoid-#{set[:mongoid][0]}" do gem 'rails', "~> #{set[:rails]}" diff --git a/gemfiles/rails_6_0_mongoid_7.gemfile b/gemfiles/rails_6_0_mongoid_7.gemfile index 17113954d..3086df630 100644 --- a/gemfiles/rails_6_0_mongoid_7.gemfile +++ b/gemfiles/rails_6_0_mongoid_7.gemfile @@ -4,7 +4,7 @@ source "https://rubygems.org" gem "rails", "~> 6.0" gem "mongoid", "~> 7.0" -gem "mongoid-locker", "~> 2.0" +gem "mongoid-locker", "~> 1.0" group :development, :test do gem "attr_encrypted" From 8ef113c2c952af40a923712fb90e59596c35c76b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Fija=C5=82kowski?= Date: Thu, 9 Jan 2020 17:12:36 +0100 Subject: [PATCH 8/8] Allow to change primary key type for Rails 6 --- lib/generators/devise_token_auth/install_generator.rb | 6 +++--- .../generators/devise_token_auth/install_generator_test.rb | 2 +- .../install_generator_with_namespace_test.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/generators/devise_token_auth/install_generator.rb b/lib/generators/devise_token_auth/install_generator.rb index 14e7d0ba9..e99b36a61 100644 --- a/lib/generators/devise_token_auth/install_generator.rb +++ b/lib/generators/devise_token_auth/install_generator.rb @@ -75,12 +75,12 @@ def database_version ActiveRecord::Base.connection.select_value('SELECT VERSION()') end - def rails5? - Rails.version.start_with? '5' + def rails_5_or_newer? + Rails::VERSION::MAJOR >= 5 end def primary_key_type - primary_key_string if rails5? + primary_key_string if rails_5_or_newer? end def primary_key_string diff --git a/test/lib/generators/devise_token_auth/install_generator_test.rb b/test/lib/generators/devise_token_auth/install_generator_test.rb index dedbe9e05..c58c92faf 100644 --- a/test/lib/generators/devise_token_auth/install_generator_test.rb +++ b/test/lib/generators/devise_token_auth/install_generator_test.rb @@ -47,7 +47,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase test 'add primary key type with rails 5 when specified in rails generator' do run_generator %w[--primary_key_type=uuid --force] - if Rails::VERSION::MAJOR == 5 + if Rails::VERSION::MAJOR >= 5 assert_migration 'db/migrate/devise_token_auth_create_users.rb', /create_table\(:users, id: :uuid\) do/ else assert_migration 'db/migrate/devise_token_auth_create_users.rb', /create_table\(:users\) do/ diff --git a/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb b/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb index 8b9464f1d..f407fb052 100644 --- a/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +++ b/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb @@ -52,7 +52,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase test 'add primary key type with rails 5 when specified in rails generator' do run_generator %W[#{user_class} auth --primary_key_type=uuid --force] - if Rails::VERSION::MAJOR == 5 + if Rails::VERSION::MAJOR >= 5 assert_migration "db/migrate/devise_token_auth_create_#{table_name}.rb", /create_table\(:#{table_name}, id: :uuid\) do/ else assert_migration "db/migrate/devise_token_auth_create_#{table_name}.rb", /create_table\(:#{table_name}\) do/