diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-08-03 13:58:00 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-08-03 13:58:00 +0300 |
commit | 98e9f52cf4e02562055f9106a155184e7b55012f (patch) | |
tree | ba2b9b0deeb3fb3ff92bb844ae67cc6edb8251a2 | |
parent | 5bbd3a93e963addfa2f1bbfa96c6a3c231e66d09 (diff) |
Improve blocked user tracking code readability
-rw-r--r-- | app/controllers/application_controller.rb | 1 | ||||
-rw-r--r-- | config/initializers/warden.rb | 7 | ||||
-rw-r--r-- | lib/gitlab/auth/blocked_user_tracker.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/auth/blocked_user_tracker_spec.rb | 2 |
4 files changed, 8 insertions, 4 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3c9ad05ef86..783831748a7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 } diff --git a/config/initializers/warden.rb b/config/initializers/warden.rb index c06cedf473d..632fdc59dd1 100644 --- a/config/initializers/warden.rb +++ b/config/initializers/warden.rb @@ -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! diff --git a/lib/gitlab/auth/blocked_user_tracker.rb b/lib/gitlab/auth/blocked_user_tracker.rb index 654b9f69684..50712d7eac2 100644 --- a/lib/gitlab/auth/blocked_user_tracker.rb +++ b/lib/gitlab/auth/blocked_user_tracker.rb @@ -19,4 +19,4 @@ module Gitlab end end end -end
\ No newline at end of file +end diff --git a/spec/lib/gitlab/auth/blocked_user_tracker_spec.rb b/spec/lib/gitlab/auth/blocked_user_tracker_spec.rb index c0b56b5665e..f39863fdda1 100644 --- a/spec/lib/gitlab/auth/blocked_user_tracker_spec.rb +++ b/spec/lib/gitlab/auth/blocked_user_tracker_spec.rb @@ -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) |