diff options
author | Stan Hu <stanhu@gmail.com> | 2018-06-22 09:25:00 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-07-03 21:39:00 +0300 |
commit | 7376ffc3a3f3d0f3bc294c4431370c5560c19a00 (patch) | |
tree | e9b79881a32ce9a4dba1658c0a9586b1e66c1b1b /spec/controllers | |
parent | cd5789415b6e561564073693243e890e79596ed2 (diff) |
Add Prometheus metrics to track reCAPTCHA success/failures
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/sessions_controller_spec.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index cdec26bd421..7c00652317b 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -93,6 +93,12 @@ describe SessionsController do it 'displays an error when the reCAPTCHA is not solved' do # Without this, `verify_recaptcha` arbitraily returns true in test env Recaptcha.configuration.skip_verify_env.delete('test') + counter = double(:counter) + + expect(counter).to receive(:increment) + expect(Gitlab::Metrics).to receive(:counter) + .with(:failed_login_captcha_total, anything) + .and_return(counter) post(:create, user: user_params) @@ -104,6 +110,13 @@ describe SessionsController do it 'successfully logs in a user when reCAPTCHA is solved' do # Avoid test ordering issue and ensure `verify_recaptcha` returns true Recaptcha.configuration.skip_verify_env << 'test' + counter = double(:counter) + + expect(counter).to receive(:increment) + expect(Gitlab::Metrics).to receive(:counter) + .with(:successful_login_captcha_total, anything) + .and_return(counter) + expect(Gitlab::Metrics).to receive(:counter).and_call_original post(:create, user: user_params) |