diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /spec/services/captcha | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/services/captcha')
-rw-r--r-- | spec/services/captcha/captcha_verification_service_spec.rb | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/spec/services/captcha/captcha_verification_service_spec.rb b/spec/services/captcha/captcha_verification_service_spec.rb index 245e06703f5..fe2199fb53e 100644 --- a/spec/services/captcha/captcha_verification_service_spec.rb +++ b/spec/services/captcha/captcha_verification_service_spec.rb @@ -4,21 +4,31 @@ require 'spec_helper' RSpec.describe Captcha::CaptchaVerificationService do describe '#execute' do - let(:captcha_response) { nil } - let(:request) { double(:request) } - let(:service) { described_class.new } + let(:captcha_response) { 'abc123' } + let(:fake_ip) { '1.2.3.4' } + let(:spam_params) do + ::Spam::SpamParams.new( + captcha_response: captcha_response, + spam_log_id: double, + ip_address: fake_ip, + user_agent: double, + referer: double + ) + end + + let(:service) { described_class.new(spam_params: spam_params) } - subject { service.execute(captcha_response: captcha_response, request: request) } + subject { service.execute } context 'when there is no captcha_response' do + let(:captcha_response) { nil } + it 'returns false' do expect(subject).to eq(false) end end context 'when there is a captcha_response' do - let(:captcha_response) { 'abc123' } - before do expect(Gitlab::Recaptcha).to receive(:load_configurations!) end @@ -29,10 +39,12 @@ RSpec.describe Captcha::CaptchaVerificationService do expect(subject).to eq(true) end - it 'has a request method which returns the request' do + it 'has a request method which returns an object with the ip address #remote_ip' do subject - expect(service.send(:request)).to eq(request) + request_struct = service.send(:request) + expect(request_struct).to respond_to(:remote_ip) + expect(request_struct.remote_ip).to eq(fake_ip) end end end |