blob: 4d5f8d9d4311d7a7c07d65027d72713c946bee8a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# 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
result = subject.send(:with_spam_action_response_fields, spammable) do
{ other_field: true }
end
expect(result)
.to eq({
spam: true,
needs_captcha_response: true,
spam_log_id: 1,
captcha_site_key: recaptcha_site_key,
other_field: true
})
end
end
end
|