Commit 9182f7d6 authored by Quang-Minh Nguyen's avatar Quang-Minh Nguyen

Remove dependency injection

parent 1533894a
......@@ -34,10 +34,6 @@ module Gitlab
}
end
def initialize(auth_logger: Gitlab::AuthLogger)
@auth_logger = auth_logger
end
def redis(event)
self.class.payload[:rack_attack_redis_count] += 1
self.class.payload[:rack_attack_redis_duration_s] += event.duration.to_f / 1000
......@@ -81,7 +77,11 @@ module Gitlab
rack_attack_info['meta.user'] = user.username unless user.nil?
end
@auth_logger.error(rack_attack_info)
logger.error(rack_attack_info)
end
def logger
Gitlab::AuthLogger
end
end
end
......
......@@ -3,8 +3,7 @@
require 'spec_helper'
RSpec.describe Gitlab::Metrics::Subscribers::RackAttack, :request_store do
let(:logger) { double(:logger) }
let(:subscriber) { described_class.new(auth_logger: logger) }
let(:subscriber) { described_class.new }
describe '.payload' do
context 'when the request store is empty' do
......@@ -78,7 +77,7 @@ RSpec.describe Gitlab::Metrics::Subscribers::RackAttack, :request_store do
end
it 'logs request information' do
expect(logger).to receive(:error).with(
expect(Gitlab::AuthLogger).to receive(:error).with(
message: 'Rack_Attack',
env: match_type,
remote_ip: '1.2.3.4',
......@@ -109,7 +108,7 @@ RSpec.describe Gitlab::Metrics::Subscribers::RackAttack, :request_store do
end
it 'logs request information and user id' do
expect(logger).to receive(:error).with(
expect(Gitlab::AuthLogger).to receive(:error).with(
message: 'Rack_Attack',
env: match_type,
remote_ip: '1.2.3.4',
......@@ -141,7 +140,7 @@ RSpec.describe Gitlab::Metrics::Subscribers::RackAttack, :request_store do
end
it 'logs request information and user meta' do
expect(logger).to receive(:error).with(
expect(Gitlab::AuthLogger).to receive(:error).with(
message: 'Rack_Attack',
env: match_type,
remote_ip: '1.2.3.4',
......
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