Commit 8cef97d0 authored by Thong Kuah's avatar Thong Kuah

Merge branch 'cablett-spam-tidy-spam-service-init' into 'master'

Modify SpamService initializer

See merge request gitlab-org/gitlab!22874
parents b9a726c7 0546f692
......@@ -11,7 +11,7 @@ module SpammableActions
end
def mark_as_spam
if SpamService.new(spammable).mark_as_spam!
if SpamService.new(spammable: spammable).mark_as_spam!
redirect_to spammable_path, notice: _("%{spammable_titlecase} was submitted to Akismet successfully.") % { spammable_titlecase: spammable.spammable_entity_type.titlecase }
else
redirect_to spammable_path, alert: _('Error with Akismet. Please check the logs for more info.')
......
......@@ -24,7 +24,7 @@ module Mutations
private
def mark_as_spam(snippet)
SpamService.new(snippet).mark_as_spam!
SpamService.new(spammable: snippet).mark_as_spam!
end
def authorized_resource?(snippet)
......
......@@ -24,7 +24,7 @@ module SpamCheckMethods
# rubocop:disable Gitlab/ModuleWithInstanceVariables
# rubocop: disable CodeReuse/ActiveRecord
def spam_check(spammable, user)
spam_service = SpamService.new(spammable, @request)
spam_service = SpamService.new(spammable: spammable, request: @request)
spam_service.when_recaptcha_verified(@recaptcha_verified, @api) do
user.spam_logs.find_by(id: @spam_log_id)&.update!(recaptcha_verified: true)
......
......@@ -4,7 +4,7 @@ class SpamService
attr_accessor :spammable, :request, :options
attr_reader :spam_log
def initialize(spammable, request = nil)
def initialize(spammable:, request: nil)
@spammable = spammable
@request = request
@options = {}
......
......@@ -5,7 +5,7 @@ require 'spec_helper'
describe SpamService do
describe '#when_recaptcha_verified' do
def check_spam(issue, request, recaptcha_verified)
described_class.new(issue, request).when_recaptcha_verified(recaptcha_verified) do
described_class.new(spammable: issue, request: request).when_recaptcha_verified(recaptcha_verified) do
'yielded'
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