forked from Sorcery/sorcery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Rails 6 (Sorcery#238)
* Cache bundler on Travis * Add support for Rails 6 Since the usage of `MigrationContext` was changed in rails/rails#36439, adds a branch to MigrationHelper. We are loading 'rails/all' in our test code, it implicitly load action_text from Rails 6. ActionText requires ApplicationController, adds it. ref: https://github.com/rails/rails/blob/v6.0.3/actiontext/lib/action_text/engine.rb#L50 * Exclude Ruby 2.4 for Rails 6 Rails 6 does't support Ruby 2.4. ref: rails/rails#34754
- Loading branch information
Showing
7 changed files
with
40 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
language: ruby | ||
cache: bundler | ||
|
||
rvm: | ||
- 2.4.9 | ||
- 2.5.7 | ||
- 2.6.5 | ||
- 2.7.1 | ||
|
||
gemfile: | ||
- Gemfile | ||
- gemfiles/rails_52.gemfile | ||
- gemfiles/rails_60.gemfile | ||
|
||
jobs: | ||
exclude: | ||
- rvm: 2.4.9 | ||
gemfile: gemfiles/rails_60.gemfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'pry' | ||
gem 'rails', '~> 5.2.0' | ||
gem 'rails' | ||
gem 'rails-controller-testing' | ||
gem 'sqlite3', '~> 1.3.6' | ||
gem 'sqlite3' | ||
|
||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'rails', '~> 5.2.0' | ||
gem 'rails-controller-testing' | ||
gem 'sqlite3', '~> 1.3.6' | ||
|
||
gemspec path: '..' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'rails', '~> 6.0.0' | ||
gem 'rails-controller-testing' | ||
gem 'sqlite3', '~> 1.4' | ||
|
||
gemspec path: '..' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class ApplicationController < ActionController::Base | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
class MigrationHelper | ||
class << self | ||
def migrate(path) | ||
if ActiveRecord.version >= Gem::Version.new('5.2.0') | ||
if ActiveRecord.version >= Gem::Version.new('6.0.0') | ||
ActiveRecord::MigrationContext.new(path, schema_migration).migrate | ||
elsif ActiveRecord.version >= Gem::Version.new('5.2.0') | ||
ActiveRecord::MigrationContext.new(path).migrate | ||
else | ||
ActiveRecord::Migrator.migrate(path) | ||
end | ||
end | ||
|
||
def rollback(path) | ||
if ActiveRecord.version >= Gem::Version.new('5.2.0') | ||
if ActiveRecord.version >= Gem::Version.new('6.0.0') | ||
ActiveRecord::MigrationContext.new(path, schema_migration).rollback | ||
elsif ActiveRecord.version >= Gem::Version.new('5.2.0') | ||
ActiveRecord::MigrationContext.new(path).rollback | ||
else | ||
ActiveRecord::Migrator.rollback(path) | ||
end | ||
end | ||
|
||
private | ||
|
||
def schema_migration | ||
ActiveRecord::Base.connection.schema_migration | ||
end | ||
end | ||
end |