1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Fix hanging tests for streaming controllers using Devise

Fixes #5285.
This commit is contained in:
Tony Novak 2020-08-25 20:45:30 -04:00
parent 2c844b0649
commit 23fbc35b2d
4 changed files with 24 additions and 1 deletions

View file

@ -143,7 +143,7 @@ module Devise
@controller.response.headers.merge!(headers)
@controller.response.content_type = headers["Content-Type"] unless Rails::VERSION::MAJOR >= 5
@controller.status = status
@controller.response.body = response.body
@controller.response_body = response.body
nil # causes process return @response
end

View file

@ -0,0 +1,11 @@
# frozen_string_literal: true
class StreamingController < ApplicationController
include ActionController::Live
before_action :authenticate_user!
def index
render (Devise::Test.rails5_and_up? ? :body : :text) => 'Index'
end
end

View file

@ -17,6 +17,8 @@ Rails.application.routes.draw do
resources :admins, only: [:index]
resources :streaming, only: [:index]
# Users scope
devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" }

View file

@ -196,3 +196,13 @@ class TestControllerHelpersTest < Devise::ControllerTestCase
assert_equal old_warden_proxy, new_warden_proxy
end
end
class TestControllerHelpersForStreamingControllerTest < Devise::ControllerTestCase
tests StreamingController
include Devise::Test::ControllerHelpers
test "doesn't hang when sending an authentication error response body" do
get :index
assert_equal "<html><body>You are being <a href=\"http://test.host/users/sign_in\">redirected</a>.</body></html>", response.body
end
end