From 9caae5033944e4ba6668d812703e004aaa14fc7e Mon Sep 17 00:00:00 2001 From: Felipe Bergamo Date: Sat, 10 Dec 2016 17:44:51 -0200 Subject: [PATCH] Replace log_process_action to append_info_to_payload --- lib/devise/controllers/helpers.rb | 10 +++++----- test/integration/authenticatable_test.rb | 12 ++++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/devise/controllers/helpers.rb b/lib/devise/controllers/helpers.rb index 3f7cc29c..81d5e385 100644 --- a/lib/devise/controllers/helpers.rb +++ b/lib/devise/controllers/helpers.rb @@ -10,6 +10,11 @@ module Devise if respond_to?(:helper_method) helper_method :warden, :signed_in?, :devise_controller? end + + def append_info_to_payload(payload) + super + payload[:status] ||= 401 unless payload[:exception] + end end module ClassMethods @@ -76,11 +81,6 @@ module Devise end METHODS end - - def log_process_action(payload) - payload[:status] ||= 401 unless payload[:exception] - super - end end # Define authentication filters and accessor helpers based on mappings. diff --git a/test/integration/authenticatable_test.rb b/test/integration/authenticatable_test.rb index 57b29aa9..fed62b04 100644 --- a/test/integration/authenticatable_test.rb +++ b/test/integration/authenticatable_test.rb @@ -543,6 +543,18 @@ class AuthenticationOthersTest < Devise::IntegrationTest refute warden.authenticated?(:user) end end + + test 'not signed in should returns 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