test/integration/authenticatable_test.rb in devise-4.3.0 vs test/integration/authenticatable_test.rb in devise-4.4.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'test_helper'
class AuthenticationSanityTest < Devise::IntegrationTest
test 'home should be accessible without sign in' do
visit '/'
@@ -367,11 +369,11 @@
end
assert_match %r{Special user view}, response.body
end
end
- test 'renders the scoped view if turned on in an specific controller' do
+ test 'renders the scoped view if turned on in a specific controller' do
begin
Devise::SessionsController.scoped_views = true
assert_raise Webrat::NotFoundError do
sign_in_as_user
end
@@ -539,9 +541,21 @@
swap Devise, navigational_formats: ['*/*', :html] do
sign_in_as_user
delete destroy_user_session_path, xhr: true, headers: { "HTTP_ACCEPT" => "text/html,*/*" }
assert_response :redirect
refute warden.authenticated?(:user)
+ end
+ end
+
+ test 'not signed in should return notification payload with 401 status' do
+ begin
+ subscriber = ActiveSupport::Notifications.subscribe /process_action.action_controller/ do |_name, _start, _finish, _id, payload|
+ assert_equal 401, payload[:status]
+ end
+
+ get admins_path
+ ensure
+ ActiveSupport::Notifications.unsubscribe(subscriber)
end
end
end
class AuthenticationKeysTest < Devise::IntegrationTest