diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-23 18:08:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-23 18:08:46 +0300 |
commit | 3f9e1b261121f4dbd045341241f81b47356c99cf (patch) | |
tree | 32be23bd7fda0c3f891182f220f6d0399a1b41dd /spec/models/spam_log_spec.rb | |
parent | 5ad0cf26551baff8f08af8562a8d45e6ec14d71a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/spam_log_spec.rb')
-rw-r--r-- | spec/models/spam_log_spec.rb | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/spec/models/spam_log_spec.rb b/spec/models/spam_log_spec.rb index f4e073dc38f..8ebd97de9ff 100644 --- a/spec/models/spam_log_spec.rb +++ b/spec/models/spam_log_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe SpamLog do - let(:admin) { create(:admin) } + let_it_be(:admin) { create(:admin) } describe 'associations' do it { is_expected.to belong_to(:user) } @@ -31,4 +31,29 @@ describe SpamLog do expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound) end end + + describe '.verify_recaptcha!' do + let_it_be(:spam_log) { create(:spam_log, user: admin, recaptcha_verified: false) } + + context 'the record cannot be found' do + it 'updates nothing' do + expect(instance_of(described_class)).not_to receive(:update!) + + described_class.verify_recaptcha!(id: spam_log.id, user_id: admin.id) + + expect(spam_log.recaptcha_verified).to be_falsey + end + + it 'does not error despite not finding a record' do + expect { described_class.verify_recaptcha!(id: -1, user_id: admin.id) }.not_to raise_error + end + end + + context 'the record exists' do + it 'updates recaptcha_verified' do + expect { described_class.verify_recaptcha!(id: spam_log.id, user_id: admin.id) } + .to change { spam_log.reload.recaptcha_verified }.from(false).to(true) + end + end + end end |