Add Rails 6 to CI (#5009)

This commit is contained in:
Leonardo Tegon
2019-01-22 12:43:31 -02:00
committed by GitHub
parent 40e8812d75
commit c000b58c56
19 changed files with 361 additions and 87 deletions

View File

@@ -5,7 +5,7 @@ require 'shared_user'
class User < ActiveRecord::Base
include Shim
include SharedUser
include ActiveModel::Serializers::Xml if Devise::Test.rails5?
include ActiveModel::Serializers::Xml if Devise::Test.rails5_and_up?
validates :sign_in_count, presence: true

View File

@@ -22,7 +22,7 @@ class HomeController < ApplicationController
end
def unauthenticated
if Devise::Test.rails5?
if Devise::Test.rails5_and_up?
render body: "unauthenticated", status: :unauthorized
else
render text: "unauthenticated", status: :unauthorized

View File

@@ -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? ? :body : :text) => ""
render (Devise::Test.rails5_and_up? ? :body : :text) => ""
end
end

View File

@@ -15,7 +15,7 @@ class UsersController < ApplicationController
end
def update_form
render (Devise::Test.rails5? ? :body : :text) => 'Update'
render (Devise::Test.rails5_and_up? ? :body : :text) => 'Update'
end
def accept
@@ -23,11 +23,11 @@ class UsersController < ApplicationController
end
def exhibit
render (Devise::Test.rails5? ? :body : :text) => current_user ? "User is authenticated" : "User is not authenticated"
render (Devise::Test.rails5_and_up? ? :body : :text) => 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? ? :body : :text) => 'User will be expired on next request'
render (Devise::Test.rails5_and_up? ? :body : :text) => 'User will be expired on next request'
end
end

View File

@@ -8,6 +8,10 @@ module Devise
module Test
# Detection for minor differences between Rails 4 and 5, 5.1, and 5.2 in tests.
def self.rails52_and_up?
Rails::VERSION::MAJOR > 5 || rails52?
end
def self.rails52?
Rails.version.start_with? '5.2'
end
@@ -16,6 +20,10 @@ module Devise
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

View File

@@ -22,7 +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 Rails.version >= "5.0.0"
if Devise::Test.rails5_and_up?
config.public_file_server.enabled = false
elsif Rails.version >= "4.2.0"
config.serve_static_files = false

View File

@@ -16,7 +16,7 @@ RailsApp::Application.configure do
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
if Rails.version >= "5.0.0"
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"