diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-08 12:09:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-08 12:09:42 +0300 |
commit | dca8df0c90d8727d69b3501b15b481546897f3cd (patch) | |
tree | b36be74c00e2664d7a7a92a230dee7db065f0301 /spec/models | |
parent | 208f195a9bc3614e3c720d6e485830d37c4f49df (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/user_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 0e3382b4c6f..d4c9df936d6 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -8117,4 +8117,48 @@ RSpec.describe User, feature_category: :user_profile do end end end + + describe '#arkose_global_score' do + let_it_be(:user1) { create(:user) } + let_it_be(:user2) { create(:user) } + + context 'when the user has an arkose global risk score' do + before do + create(:abuse_trust_score, user: user1, score: 12.0, source: :arkose_global_score) + create(:abuse_trust_score, user: user1, score: 24.0, source: :arkose_global_score) + end + + it 'returns the latest score' do + expect(user1.arkose_global_score).to be(24.0) + end + end + + context 'when the user does not have an arkose global risk score' do + it 'defaults to zero' do + expect(user2.arkose_global_score).to be(0.0) + end + end + end + + describe '#arkose_custom_score' do + let_it_be(:user1) { create(:user) } + let_it_be(:user2) { create(:user) } + + context 'when the user has an arkose custom risk score' do + before do + create(:abuse_trust_score, user: user1, score: 12.0, source: :arkose_custom_score) + create(:abuse_trust_score, user: user1, score: 24.0, source: :arkose_custom_score) + end + + it 'returns the latest score' do + expect(user1.arkose_custom_score).to be(24.0) + end + end + + context 'when the user does not have an arkose custom risk score' do + it 'defaults to zero' do + expect(user2.arkose_custom_score).to be(0.0) + end + end + end end |