summaryrefslogtreecommitdiff
path: root/spec/controllers/concerns
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-09 15:08:59 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-09 15:08:59 +0000
commit6f2b1c32f3ccf422575f591b42372534502dcd72 (patch)
tree2ed532687d73e290f07c760825c02a2ecbaa5416 /spec/controllers/concerns
parentb90d8b54a4d623e52cf1d4318023e3b18d13dd5b (diff)
downloadgitlab-ce-6f2b1c32f3ccf422575f591b42372534502dcd72.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers/concerns')
-rw-r--r--spec/controllers/concerns/spammable_actions_spec.rb33
1 files changed, 18 insertions, 15 deletions
diff --git a/spec/controllers/concerns/spammable_actions_spec.rb b/spec/controllers/concerns/spammable_actions_spec.rb
index 25d5398c9da..7bd5a76e60c 100644
--- a/spec/controllers/concerns/spammable_actions_spec.rb
+++ b/spec/controllers/concerns/spammable_actions_spec.rb
@@ -69,8 +69,11 @@ RSpec.describe SpammableActions do
end
context 'when spammable.render_recaptcha? is true' do
+ let(:spam_log) { instance_double(SpamLog, id: 123) }
+ let(:captcha_site_key) { 'abc123' }
+
before do
- expect(spammable).to receive(:render_recaptcha?) { true }
+ expect(spammable).to receive(:render_recaptcha?).at_least(:once) { true }
end
context 'when format is :html' do
@@ -83,24 +86,24 @@ RSpec.describe SpammableActions do
context 'when format is :json' do
let(:format) { :json }
- let(:recaptcha_html) { '<recaptcha-html/>' }
- it 'renders json with recaptcha_html' do
- expect(controller).to receive(:render_to_string).with(
- {
- partial: 'shared/recaptcha_form',
- formats: :html,
- locals: {
- spammable: spammable,
- script: false,
- has_submit: false
- }
- }
- ) { recaptcha_html }
+ before do
+ expect(spammable).to receive(:spam?) { false }
+ expect(spammable).to receive(:spam_log) { spam_log }
+ expect(Gitlab::CurrentSettings).to receive(:recaptcha_site_key) { captcha_site_key }
+ end
+ it 'renders json with spam_action_response_fields' do
subject
- expect(json_response).to eq({ 'recaptcha_html' => recaptcha_html })
+ expected_json_response = HashWithIndifferentAccess.new(
+ {
+ spam: false,
+ needs_captcha_response: true,
+ spam_log_id: spam_log.id,
+ captcha_site_key: captcha_site_key
+ })
+ expect(json_response).to eq(expected_json_response)
end
end
end