Commit fc83a730 authored by Rajendra Kadam's avatar Rajendra Kadam Committed by Peter Leitzen

Use applogger in akismet service

parent 11271ac4
...@@ -27,7 +27,7 @@ module Spam ...@@ -27,7 +27,7 @@ module Spam
is_spam, is_blatant = akismet_client.check(options[:ip_address], options[:user_agent], params) is_spam, is_blatant = akismet_client.check(options[:ip_address], options[:user_agent], params)
is_spam || is_blatant is_spam || is_blatant
rescue => e rescue => e
Rails.logger.error("Unable to connect to Akismet: #{e}, skipping check") # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.error("Unable to connect to Akismet: #{e}, skipping check")
false false
end end
end end
...@@ -67,7 +67,7 @@ module Spam ...@@ -67,7 +67,7 @@ module Spam
akismet_client.public_send(type, options[:ip_address], options[:user_agent], params) # rubocop:disable GitlabSecurity/PublicSend akismet_client.public_send(type, options[:ip_address], options[:user_agent], params) # rubocop:disable GitlabSecurity/PublicSend
true true
rescue => e rescue => e
Rails.logger.error("Unable to connect to Akismet: #{e}, skipping!") # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.error("Unable to connect to Akismet: #{e}, skipping!")
false false
end end
end end
......
---
title: Use applogger in akismet service
merge_request: 32205
author: Rajendra Kadam
type: fixed
...@@ -45,9 +45,7 @@ describe Spam::AkismetService do ...@@ -45,9 +45,7 @@ describe Spam::AkismetService do
end end
it 'logs an error' do it 'logs an error' do
logger_spy = double(:logger) expect(Gitlab::AppLogger).to receive(:error).with(/skipping/)
expect(Rails).to receive(:logger).and_return(logger_spy)
expect(logger_spy).to receive(:error).with(/skipping/)
subject.send(method_call) subject.send(method_call)
end end
...@@ -98,9 +96,7 @@ describe Spam::AkismetService do ...@@ -98,9 +96,7 @@ describe Spam::AkismetService do
end end
it 'logs an error' do it 'logs an error' do
logger_spy = double(:logger) expect(Gitlab::AppLogger).to receive(:error).with(/skipping check/)
expect(Rails).to receive(:logger).and_return(logger_spy)
expect(logger_spy).to receive(:error).with(/skipping check/)
subject.spam? subject.spam?
end end
......
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