Commit 98e9f52c authored by Grzegorz Bizon's avatar Grzegorz Bizon

Improve blocked user tracking code readability

parent 5bbd3a93
......@@ -24,7 +24,6 @@ class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
before_action :require_email, unless: :devise_controller?
around_action :set_locale
after_action :set_page_title_header, if: -> { request.format == :json }
......
......@@ -40,7 +40,12 @@ Rails.application.configure do |config|
# multiple times during the request lifecycle. We want to increment
# metrics and write logs only once in that case.
#
next if (auth.env['warden.auth.trackers'] ||= {}).push(activity).many?
# 'warden.auth.trackers' is our custom hash key that follows usual
# convention of naming keys in the Rack env hash. If there is more
# than one tracker in the hash it means that we have already recorded
# an event.
#
next if (auth.env['warden.auth.trackers'] ||= []).push(activity).many?
if user.blocked?
activity.user_blocked!
......
......@@ -19,4 +19,4 @@ module Gitlab
end
end
end
end
\ No newline at end of file
end
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::Auth::BlockedUserTracker do
describe '#log_blocked_user_activity!' do
context 'when user is not blocked' do
it 'does not blocked user activity' do
it 'does not log blocked user activity' do
expect_any_instance_of(SystemHooksService)
.not_to receive(:execute_hooks_for)
expect(Gitlab::AppLogger).not_to receive(:info)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment