2021-02-25 09:10:45 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe Spam::Concerns::HasSpamActionResponseFields do
|
|
|
|
subject do
|
|
|
|
klazz = Class.new
|
|
|
|
klazz.include described_class
|
|
|
|
klazz.new
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#with_spam_action_response_fields' do
|
|
|
|
let(:spam_log) { double(:spam_log, id: 1) }
|
|
|
|
let(:spammable) { double(:spammable, spam?: true, render_recaptcha?: true, spam_log: spam_log) }
|
|
|
|
let(:recaptcha_site_key) { 'abc123' }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(Gitlab::CurrentSettings).to receive(:recaptcha_site_key) { recaptcha_site_key }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'merges in spam action fields from spammable' do
|
2021-04-09 18:09:24 +00:00
|
|
|
expect(subject.spam_action_response_fields(spammable))
|
2021-02-25 09:10:45 +00:00
|
|
|
.to eq({
|
|
|
|
spam: true,
|
|
|
|
needs_captcha_response: true,
|
|
|
|
spam_log_id: 1,
|
2021-04-09 18:09:24 +00:00
|
|
|
captcha_site_key: recaptcha_site_key
|
2021-02-25 09:10:45 +00:00
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|