mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-08 22:37:57 -05:00
Merge pull request #5600 from heartcombo/rm-drop-support-to-old-rubies-and-rails
Drop support to EOL rubies and Rails
This commit is contained in:
@@ -20,11 +20,7 @@ if DEVISE_ORM == :active_record
|
||||
Rails.application.config.paths.add "db/migrate", with: "db2/migrate"
|
||||
|
||||
run_generator %w(monster)
|
||||
if Rails.version >= '5.0.3'
|
||||
assert_migration "db2/migrate/devise_create_monsters.rb", /def change/
|
||||
else
|
||||
assert_migration "db/migrate/devise_create_monsters.rb", /def change/
|
||||
end
|
||||
assert_migration "db2/migrate/devise_create_monsters.rb", /def change/
|
||||
|
||||
Rails.application.config.paths["db/migrate"] = old_paths
|
||||
end
|
||||
@@ -49,11 +45,7 @@ if DEVISE_ORM == :active_record
|
||||
assert_file "app/models/monster.rb"
|
||||
run_generator %w(monster)
|
||||
|
||||
if Rails.version >= '5.0.3'
|
||||
assert_migration "db2/migrate/add_devise_to_monsters.rb"
|
||||
else
|
||||
assert_migration "db/migrate/add_devise_to_monsters.rb"
|
||||
end
|
||||
assert_migration "db2/migrate/add_devise_to_monsters.rb"
|
||||
|
||||
Rails.application.config.paths["db/migrate"] = old_paths
|
||||
end
|
||||
@@ -84,11 +76,7 @@ if DEVISE_ORM == :active_record
|
||||
|
||||
test "add primary key type with rails 5 when specified in rails generator" do
|
||||
run_generator ["monster", "--primary_key_type=uuid"]
|
||||
if Devise::Test.rails5_and_up?
|
||||
assert_migration "db/migrate/devise_create_monsters.rb", /create_table :monsters, id: :uuid do/
|
||||
else
|
||||
assert_migration "db/migrate/devise_create_monsters.rb", /create_table :monsters do/
|
||||
end
|
||||
assert_migration "db/migrate/devise_create_monsters.rb", /create_table :monsters, id: :uuid do/
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -12,13 +12,7 @@ class RememberMeTest < Devise::IntegrationTest
|
||||
end
|
||||
|
||||
def generate_signed_cookie(raw_cookie)
|
||||
request = if Devise::Test.rails51? || Devise::Test.rails52_and_up?
|
||||
ActionController::TestRequest.create(Class.new) # needs a "controller class"
|
||||
elsif Devise::Test.rails5?
|
||||
ActionController::TestRequest.create
|
||||
else
|
||||
ActionController::TestRequest.new
|
||||
end
|
||||
request = ActionController::TestRequest.create(Class.new) # needs a "controller class"
|
||||
request.cookie_jar.signed['raw_cookie'] = raw_cookie
|
||||
request.cookie_jar['raw_cookie']
|
||||
end
|
||||
|
||||
@@ -7,22 +7,11 @@ ActiveRecord::Base.include_root_in_json = true
|
||||
migrate_path = File.expand_path("../../rails_app/db/migrate/", __FILE__)
|
||||
if Devise::Test.rails71_and_up?
|
||||
ActiveRecord::MigrationContext.new(migrate_path).migrate
|
||||
elsif Devise::Test.rails6_and_up?
|
||||
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)
|
||||
ActiveRecord::MigrationContext.new(migrate_path, ActiveRecord::SchemaMigration).migrate
|
||||
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_transactional_tests = true
|
||||
self.use_instantiated_fixtures = false
|
||||
end
|
||||
|
||||
@@ -22,10 +22,6 @@ class HomeController < ApplicationController
|
||||
end
|
||||
|
||||
def unauthenticated
|
||||
if Devise::Test.rails5_and_up?
|
||||
render body: "unauthenticated", status: :unauthorized
|
||||
else
|
||||
render text: "unauthenticated", status: :unauthorized
|
||||
end
|
||||
render body: "unauthenticated", status: :unauthorized
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,18 +6,6 @@ class StreamingController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
|
||||
def index
|
||||
render (Devise::Test.rails5_and_up? ? :body : :text) => 'Index'
|
||||
end
|
||||
|
||||
# Work around https://github.com/heartcombo/devise/issues/2332, which affects
|
||||
# tests in Rails 4.x (and affects production in Rails >= 5)
|
||||
def process(name)
|
||||
super(name)
|
||||
rescue ArgumentError => e
|
||||
if e.message == 'uncaught throw :warden'
|
||||
throw :warden
|
||||
else
|
||||
raise e
|
||||
end
|
||||
render body: 'Index'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,6 +11,6 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||
user = User.to_adapter.find_first(email: 'user@test.com')
|
||||
user.remember_me = true
|
||||
sign_in user
|
||||
render (Devise::Test.rails5_and_up? ? :body : :text) => ""
|
||||
render body: ""
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
def update_form
|
||||
render (Devise::Test.rails5_and_up? ? :body : :text) => 'Update'
|
||||
render body: 'Update'
|
||||
end
|
||||
|
||||
def accept
|
||||
@@ -24,11 +24,11 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
def exhibit
|
||||
render (Devise::Test.rails5_and_up? ? :body : :text) => current_user ? "User is authenticated" : "User is not authenticated"
|
||||
render body: current_user ? "User is authenticated" : "User is not authenticated"
|
||||
end
|
||||
|
||||
def expire
|
||||
user_session['last_request_at'] = 31.minutes.ago.utc
|
||||
render (Devise::Test.rails5_and_up? ? :body : :text) => 'User will be expired on next request'
|
||||
render body: 'User will be expired on next request'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,23 +33,12 @@ module RailsApp
|
||||
# config.assets.enabled = false
|
||||
|
||||
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
|
||||
rails_version = Gem::Version.new(Rails.version)
|
||||
if DEVISE_ORM == :active_record &&
|
||||
rails_version >= Gem::Version.new('4.2.0') &&
|
||||
rails_version < Gem::Version.new('5.1.0')
|
||||
config.active_record.raise_in_transactional_callbacks = true
|
||||
end
|
||||
|
||||
# This was used to break devise in some situations
|
||||
config.to_prepare do
|
||||
Devise::SessionsController.layout "application"
|
||||
end
|
||||
|
||||
# Remove the first check once Rails 5.0 support is removed.
|
||||
if Devise::Test.rails52_and_up? && !Devise::Test.rails6_and_up?
|
||||
Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
|
||||
end
|
||||
|
||||
if Devise::Test.rails70?
|
||||
config.active_record.legacy_connection_handling = false
|
||||
end
|
||||
|
||||
@@ -19,30 +19,6 @@ module Devise
|
||||
def self.rails70?
|
||||
Rails.version.start_with? '7.0'
|
||||
end
|
||||
|
||||
def self.rails6_and_up?
|
||||
Rails::VERSION::MAJOR >= 6
|
||||
end
|
||||
|
||||
def self.rails52_and_up?
|
||||
Rails::VERSION::MAJOR > 5 || rails52?
|
||||
end
|
||||
|
||||
def self.rails52?
|
||||
Rails.version.start_with? '5.2'
|
||||
end
|
||||
|
||||
def self.rails51?
|
||||
Rails.version.start_with? '5.1'
|
||||
end
|
||||
|
||||
def self.rails5_and_up?
|
||||
Rails::VERSION::MAJOR >= 5
|
||||
end
|
||||
|
||||
def self.rails5?
|
||||
Rails.version.start_with? '5'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -22,13 +22,7 @@ RailsApp::Application.configure do
|
||||
# config.action_dispatch.rack_cache = true
|
||||
|
||||
# Disable Rails's static asset server (Apache or nginx will already do this).
|
||||
if Devise::Test.rails5_and_up?
|
||||
config.public_file_server.enabled = false
|
||||
elsif Rails.version >= "4.2.0"
|
||||
config.serve_static_files = false
|
||||
else
|
||||
config.serve_static_assets = false
|
||||
end
|
||||
config.public_file_server.enabled = false
|
||||
|
||||
# Compress JavaScripts and CSS.
|
||||
config.assets.js_compressor = :uglifier
|
||||
|
||||
@@ -16,16 +16,8 @@ RailsApp::Application.configure do
|
||||
|
||||
# Disable serving static files from the `/public` folder by default since
|
||||
# Apache or NGINX already handles this.
|
||||
if Devise::Test.rails5_and_up?
|
||||
config.public_file_server.enabled = true
|
||||
config.public_file_server.headers = {'Cache-Control' => 'public, max-age=3600'}
|
||||
elsif Rails.version >= "4.2.0"
|
||||
config.serve_static_files = true
|
||||
config.static_cache_control = "public, max-age=3600"
|
||||
else
|
||||
config.serve_static_assets = true
|
||||
config.static_cache_control = "public, max-age=3600"
|
||||
end
|
||||
config.public_file_server.enabled = true
|
||||
config.public_file_server.headers = {'Cache-Control' => 'public, max-age=3600'}
|
||||
|
||||
# Show full error reports and disable caching.
|
||||
config.consider_all_requests_local = true
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
superclass = ActiveRecord::Migration
|
||||
# TODO: Inherit from the 5.0 Migration class directly when we drop support for Rails 4.
|
||||
superclass = ActiveRecord::Migration[5.0] if superclass.respond_to?(:[])
|
||||
|
||||
class CreateTables < superclass
|
||||
class CreateTables < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
create_table :users do |t|
|
||||
t.string :username
|
||||
|
||||
@@ -205,7 +205,7 @@ class CustomizedRoutingTest < ActionController::TestCase
|
||||
|
||||
test 'map with format false for sessions' do
|
||||
expected_params = {controller: 'devise/sessions', action: 'new'}
|
||||
expected_params[:format] = false if Devise::Test.rails5_and_up?
|
||||
expected_params[:format] = false
|
||||
|
||||
assert_recognizes(expected_params, {path: '/htmlonly_admin/sign_in', method: :get})
|
||||
assert_raise ExpectedRoutingError do
|
||||
@@ -215,7 +215,7 @@ class CustomizedRoutingTest < ActionController::TestCase
|
||||
|
||||
test 'map with format false for passwords' do
|
||||
expected_params = {controller: 'devise/passwords', action: 'create'}
|
||||
expected_params[:format] = false if Devise::Test.rails5_and_up?
|
||||
expected_params[:format] = false
|
||||
|
||||
assert_recognizes(expected_params, {path: '/htmlonly_admin/password', method: :post})
|
||||
assert_raise ExpectedRoutingError do
|
||||
@@ -225,7 +225,7 @@ class CustomizedRoutingTest < ActionController::TestCase
|
||||
|
||||
test 'map with format false for registrations' do
|
||||
expected_params = {controller: 'devise/registrations', action: 'new'}
|
||||
expected_params[:format] = false if Devise::Test.rails5_and_up?
|
||||
expected_params[:format] = false
|
||||
|
||||
assert_recognizes(expected_params, {path: '/htmlonly_admin/sign_up', method: :get})
|
||||
assert_raise ExpectedRoutingError do
|
||||
@@ -235,7 +235,7 @@ class CustomizedRoutingTest < ActionController::TestCase
|
||||
|
||||
test 'map with format false for confirmations' do
|
||||
expected_params = {controller: 'devise/confirmations', action: 'show'}
|
||||
expected_params[:format] = false if Devise::Test.rails5_and_up?
|
||||
expected_params[:format] = false
|
||||
|
||||
assert_recognizes(expected_params, {path: '/htmlonly_users/confirmation', method: :get})
|
||||
assert_raise ExpectedRoutingError do
|
||||
@@ -245,7 +245,7 @@ class CustomizedRoutingTest < ActionController::TestCase
|
||||
|
||||
test 'map with format false for unlocks' do
|
||||
expected_params = {controller: 'devise/unlocks', action: 'show'}
|
||||
expected_params[:format] = false if Devise::Test.rails5_and_up?
|
||||
expected_params[:format] = false
|
||||
|
||||
assert_recognizes(expected_params, {path: '/htmlonly_users/unlock', method: :get})
|
||||
assert_raise ExpectedRoutingError do
|
||||
|
||||
@@ -2,36 +2,8 @@
|
||||
|
||||
module Devise
|
||||
class IntegrationTest < ActionDispatch::IntegrationTest
|
||||
# %w( get post patch put head delete xml_http_request
|
||||
# xhr get_via_redirect post_via_redirect
|
||||
# ).each do |method|
|
||||
unless Devise::Test.rails5_and_up?
|
||||
%w( get post put ).each do |method|
|
||||
define_method(method) do |url, options = {}|
|
||||
if options[:xhr] == true
|
||||
xml_http_request __method__, url, options[:params] || {}, options[:headers]
|
||||
else
|
||||
super url, options[:params] || {}, options[:headers]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class ControllerTestCase < ActionController::TestCase
|
||||
# %w( get post patch put head delete xml_http_request
|
||||
# xhr get_via_redirect post_via_redirect
|
||||
# ).each do |method|
|
||||
unless Devise::Test.rails5_and_up?
|
||||
%w( get post put ).each do |method|
|
||||
define_method(method) do |action, options = {}|
|
||||
if options[:xhr] == true
|
||||
xml_http_request __method__, action, options[:params] || {}, options[:headers]
|
||||
else
|
||||
super action, options[:params] || {}, options[:headers]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -108,11 +108,7 @@ class TestControllerHelpersTest < Devise::ControllerTestCase
|
||||
test "returns the content type of a failure app" do
|
||||
get :index, params: { format: :json }
|
||||
|
||||
if Devise::Test.rails6_and_up?
|
||||
assert_includes response.media_type, 'application/json'
|
||||
else
|
||||
assert_includes response.content_type, 'application/json'
|
||||
end
|
||||
assert_includes response.media_type, 'application/json'
|
||||
end
|
||||
|
||||
test "defined Warden after_authentication callback should not be called when sign_in is called" do
|
||||
@@ -181,13 +177,7 @@ class TestControllerHelpersTest < Devise::ControllerTestCase
|
||||
test "creates a new warden proxy if the request object has changed" do
|
||||
old_warden_proxy = warden
|
||||
|
||||
@request = if Devise::Test.rails51? || Devise::Test.rails52_and_up?
|
||||
ActionController::TestRequest.create(Class.new) # needs a "controller class"
|
||||
elsif Devise::Test.rails5?
|
||||
ActionController::TestRequest.create
|
||||
else
|
||||
ActionController::TestRequest.new
|
||||
end
|
||||
@request = ActionController::TestRequest.create(Class.new) # needs a "controller class"
|
||||
|
||||
new_warden_proxy = warden
|
||||
|
||||
|
||||
@@ -23,22 +23,6 @@ end
|
||||
if ActiveSupport.respond_to?(:test_order)
|
||||
ActiveSupport.test_order = :random
|
||||
end
|
||||
class ActiveSupport::TestCase
|
||||
if ActiveSupport.version < Gem::Version.new("5.0")
|
||||
def assert_deprecated(match, deprecator)
|
||||
super(match) do
|
||||
# TODO: remove extra begin..end when dropping support for Ruby <= 2.4
|
||||
begin
|
||||
behavior = deprecator.behavior
|
||||
deprecator.behavior = ActiveSupport::Deprecation.behavior
|
||||
yield
|
||||
ensure
|
||||
deprecator.behavior = behavior
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
OmniAuth.config.logger = Logger.new('/dev/null')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user