1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00
heartcombo--devise/test/orm/active_record.rb
Leonardo Tegon ad5892391d
Fix specs on Rails 6 RC2 (#5109)
* Fix specs on Rails 6 RC2

`ActiveRecord::MigrationContext` now has a `schema_migration` attribute.
Ref: https://github.com/rails/rails/pull/36439/files#diff-8d3c44120f7b67ff79e2fbe6a40d0ad6R1018

* Use `media_type` instead of `content_type`

Before Rails 6 RC2, the `ActionDispatch::Response#content_type` method
would return only the media part of the `Content-Type` header, without any
other parts. Now the `#content_type` method returns the entire header -
as it is - and `#media_type` should be used instead to get the previous
behavior.

Ref:
- https://github.com/rails/rails/pull/36034
- https://github.com/rails/rails/pull/36854

* Use render template instead of render file

Render file will need the full path in order to avoid security breaches.
In this particular case, there's no need to use render file, it's ok to
use render template.

Ref: https://github.com/rails/rails/pull/35688

* Don't set `represent_boolean_as_integer` on Rails 6

* Update comments [ci skip]
2019-08-07 12:32:01 -03:00

26 lines
838 B
Ruby

# frozen_string_literal: true
ActiveRecord::Migration.verbose = false
ActiveRecord::Base.logger = Logger.new(nil)
ActiveRecord::Base.include_root_in_json = true
migrate_path = File.expand_path("../../rails_app/db/migrate/", __FILE__)
if Devise::Test.rails6?
ActiveRecord::MigrationContext.new(migrate_path, ActiveRecord::SchemaMigration).migrate
elsif Devise::Test.rails52_and_up?
ActiveRecord::MigrationContext.new(migrate_path).migrate
else
ActiveRecord::Migrator.migrate(migrate_path)
end
class ActiveSupport::TestCase
if Devise::Test.rails5_and_up?
self.use_transactional_tests = true
else
# Let `after_commit` work with transactional fixtures, however this is not needed for Rails 5.
require 'test_after_commit'
self.use_transactional_fixtures = true
end
self.use_instantiated_fixtures = false
end