Merge pull request #1068 from airblade/add-support-for-rails-5.2
Add support for rails 5.2
This commit is contained in:
commit
9c99efeef5
|
@ -32,6 +32,7 @@ gemfile:
|
|||
- gemfiles/ar_4.2.gemfile
|
||||
- gemfiles/ar_5.0.gemfile
|
||||
- gemfiles/ar_5.1.gemfile
|
||||
- gemfiles/ar_5.2.gemfile
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
|
13
Appraisals
13
Appraisals
|
@ -23,3 +23,16 @@ appraise "ar-5.1" do
|
|||
gem "activerecord", "~> 5.1.4"
|
||||
gem "rails-controller-testing"
|
||||
end
|
||||
|
||||
appraise "ar-5.2" do
|
||||
gem "activerecord", "~> 5.2.0.rc1"
|
||||
gem "rails-controller-testing"
|
||||
|
||||
# bundler does not handle rc versions well
|
||||
# https://github.com/airblade/paper_trail/pull/1067
|
||||
# so we specify activesupport, actionpack, and railties, which we
|
||||
# would not normally do, as you can see with other rails versions above.
|
||||
gem "activesupport", "~> 5.2.0.rc1"
|
||||
gem "actionpack", "~> 5.2.0.rc1"
|
||||
gem "railties", "~> 5.2.0.rc1"
|
||||
end
|
||||
|
|
|
@ -36,6 +36,8 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/).
|
|||
|
||||
### Added
|
||||
|
||||
- [#1067](https://github.com/airblade/paper_trail/pull/1033) -
|
||||
Add support to Rails 5.2.
|
||||
- [#1033](https://github.com/airblade/paper_trail/pull/1033) -
|
||||
Set request variables temporarily using a block, eg.
|
||||
`PaperTrail.request(whodunnit: 'Jared') do .. end`
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
# This file was generated by Appraisal
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "activerecord", "~> 5.2.0.rc1"
|
||||
gem "rails-controller-testing"
|
||||
gem "activesupport", "~> 5.2.0.rc1"
|
||||
gem "actionpack", "~> 5.2.0.rc1"
|
||||
gem "railties", "~> 5.2.0.rc1"
|
||||
|
||||
gemspec path: "../"
|
|
@ -28,7 +28,7 @@ has been destroyed.
|
|||
s.required_ruby_version = ">= 2.3.0"
|
||||
|
||||
# Rails does not follow semver, makes breaking changes in minor versions.
|
||||
s.add_dependency "activerecord", [">= 4.2", "< 5.2"]
|
||||
s.add_dependency "activerecord", [">= 4.2", "< 5.3"]
|
||||
s.add_dependency "request_store", "~> 1.1"
|
||||
|
||||
s.add_development_dependency "appraisal", "~> 2.2"
|
||||
|
|
|
@ -61,8 +61,11 @@ require "paper_trail/frameworks/rspec"
|
|||
require "ffaker"
|
||||
require "timecop"
|
||||
|
||||
# Run any available migration
|
||||
ActiveRecord::Migrator.migrate File.expand_path("dummy_app/db/migrate/", __dir__)
|
||||
# Migrate
|
||||
require_relative "support/paper_trail_spec_migrator"
|
||||
::PaperTrailSpecMigrator.
|
||||
new(::File.expand_path("dummy_app/db/migrate/", __dir__)).
|
||||
migrate
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_relative "paper_trail_spec_migrator"
|
||||
|
||||
# This file copies the test database into locations for the `Foo` and `Bar`
|
||||
# namespace, then defines those namespaces, then establishes the sqlite3
|
||||
# connection for the namespaces to simulate an application with multiple
|
||||
|
@ -34,7 +36,8 @@ end
|
|||
Foo::Base.configurations = configs
|
||||
Foo::Base.establish_connection(:foo)
|
||||
ActiveRecord::Base.establish_connection(:foo)
|
||||
ActiveRecord::Migrator.migrate File.expand_path("#{db_directory}/migrate/", __FILE__)
|
||||
paper_trail_migrations_path = File.expand_path("#{db_directory}/migrate/", __FILE__)
|
||||
::PaperTrailSpecMigrator.new(paper_trail_migrations_path).migrate
|
||||
|
||||
module Bar
|
||||
class Base < ActiveRecord::Base
|
||||
|
@ -53,5 +56,4 @@ end
|
|||
Bar::Base.configurations = configs
|
||||
Bar::Base.establish_connection(:bar)
|
||||
ActiveRecord::Base.establish_connection(:bar)
|
||||
|
||||
ActiveRecord::Migrator.migrate File.expand_path("#{db_directory}/migrate/", __FILE__)
|
||||
::PaperTrailSpecMigrator.new(paper_trail_migrations_path).migrate
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Looks like the API for programatically running migrations will change
|
||||
# in rails 5.2. This is an undocumented change, AFAICT. Then again,
|
||||
# how many people use the programmatic interface? Most people probably
|
||||
# just use rake. Maybe we're doing it wrong.
|
||||
class PaperTrailSpecMigrator
|
||||
def initialize(migrations_path)
|
||||
@migrations_path = migrations_path
|
||||
end
|
||||
|
||||
def migrate
|
||||
if ::ActiveRecord.gem_version >= ::Gem::Version.new("5.2.0.rc1")
|
||||
::ActiveRecord::MigrationContext.new(@migrations_path).migrate
|
||||
else
|
||||
::ActiveRecord::Migrator.migrate(@migrations_path)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue