mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-15 01:38:07 -05:00
Fix infinite loop in authenticated engine routes in Rails 5 https://github.com/plataformatec/devise/issues/3705
37 lines
1.0 KiB
Ruby
37 lines
1.0 KiB
Ruby
require 'test_helper'
|
|
|
|
class MyMountableEngine
|
|
def self.call(env)
|
|
['200', { 'Content-Type' => 'text/html' }, ['Rendered content of MyMountableEngine']]
|
|
end
|
|
end
|
|
|
|
# If disable_clear_and_finalize is set to true, Rails will not clear other routes when calling
|
|
# again the draw method. Look at the source code at:
|
|
# http://www.rubydoc.info/docs/rails/ActionDispatch/Routing/RouteSet:draw
|
|
Rails.application.routes.disable_clear_and_finalize = true
|
|
|
|
Rails.application.routes.draw do
|
|
authenticate(:user) do
|
|
mount MyMountableEngine, at: '/mountable_engine'
|
|
end
|
|
end
|
|
|
|
class AuthenticatedMountedEngineTest < Devise::IntegrationTest
|
|
test 'redirects to the sign in page when not authenticated' do
|
|
get '/mountable_engine'
|
|
follow_redirect!
|
|
|
|
assert_response :ok
|
|
assert_contain 'You need to sign in or sign up before continuing.'
|
|
end
|
|
|
|
test 'renders the mounted engine when authenticated' do
|
|
sign_in_as_user
|
|
get '/mountable_engine'
|
|
|
|
assert_response :success
|
|
assert_contain 'Rendered content of MyMountableEngine'
|
|
end
|
|
end
|