diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /spec/models/issue_spec.rb | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) | |
download | gitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/models/issue_spec.rb')
-rw-r--r-- | spec/models/issue_spec.rb | 72 |
1 files changed, 60 insertions, 12 deletions
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index edb93ecf4b6..441446bae60 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -128,6 +128,24 @@ RSpec.describe Issue do end end + context 'order by upvotes' do + let!(:issue) { create(:issue) } + let!(:issue2) { create(:issue) } + let!(:award_emoji) { create(:award_emoji, :upvote, awardable: issue2) } + + describe '.order_upvotes_desc' do + it 'orders on upvotes' do + expect(described_class.order_upvotes_desc.to_a).to eq [issue2, issue] + end + end + + describe '.order_upvotes_asc' do + it 'orders on upvotes' do + expect(described_class.order_upvotes_asc.to_a).to eq [issue, issue2] + end + end + end + describe '.with_alert_management_alerts' do subject { described_class.with_alert_management_alerts } @@ -1051,23 +1069,53 @@ RSpec.describe Issue do describe '#check_for_spam?' do using RSpec::Parameterized::TableSyntax - - where(:visibility_level, :confidential, :new_attributes, :check_for_spam?) do - Gitlab::VisibilityLevel::PUBLIC | false | { description: 'woo' } | true - Gitlab::VisibilityLevel::PUBLIC | false | { title: 'woo' } | true - Gitlab::VisibilityLevel::PUBLIC | true | { confidential: false } | true - Gitlab::VisibilityLevel::PUBLIC | true | { description: 'woo' } | false - Gitlab::VisibilityLevel::PUBLIC | false | { title: 'woo', confidential: true } | false - Gitlab::VisibilityLevel::PUBLIC | false | { description: 'original description' } | false - Gitlab::VisibilityLevel::INTERNAL | false | { description: 'woo' } | false - Gitlab::VisibilityLevel::PRIVATE | false | { description: 'woo' } | false + let_it_be(:support_bot) { ::User.support_bot } + + where(:support_bot?, :visibility_level, :confidential, :new_attributes, :check_for_spam?) do + ### non-support-bot cases + # spammable attributes changing + false | Gitlab::VisibilityLevel::PUBLIC | false | { description: 'new' } | true + false | Gitlab::VisibilityLevel::PUBLIC | false | { title: 'new' } | true + # confidential to non-confidential + false | Gitlab::VisibilityLevel::PUBLIC | true | { confidential: false } | true + # non-confidential to confidential + false | Gitlab::VisibilityLevel::PUBLIC | false | { confidential: true } | false + # spammable attributes changing on confidential + false | Gitlab::VisibilityLevel::PUBLIC | true | { description: 'new' } | false + # spammable attributes changing while changing to confidential + false | Gitlab::VisibilityLevel::PUBLIC | false | { title: 'new', confidential: true } | false + # spammable attribute not changing + false | Gitlab::VisibilityLevel::PUBLIC | false | { description: 'original description' } | false + # non-spammable attribute changing + false | Gitlab::VisibilityLevel::PUBLIC | false | { weight: 3 } | false + # spammable attributes changing on non-public + false | Gitlab::VisibilityLevel::INTERNAL | false | { description: 'new' } | false + false | Gitlab::VisibilityLevel::PRIVATE | false | { description: 'new' } | false + + ### support-bot cases + # confidential to non-confidential + true | Gitlab::VisibilityLevel::PUBLIC | true | { confidential: false } | true + # non-confidential to confidential + true | Gitlab::VisibilityLevel::PUBLIC | false | { confidential: true } | false + # spammable attributes changing on confidential + true | Gitlab::VisibilityLevel::PUBLIC | true | { description: 'new' } | true + # spammable attributes changing while changing to confidential + true | Gitlab::VisibilityLevel::PUBLIC | false | { title: 'new', confidential: true } | true + # spammable attributes changing on non-public + true | Gitlab::VisibilityLevel::INTERNAL | false | { description: 'new' } | true + true | Gitlab::VisibilityLevel::PRIVATE | false | { title: 'new' } | true + # spammable attribute not changing + true | Gitlab::VisibilityLevel::PUBLIC | false | { description: 'original description' } | false + # non-spammable attribute changing + true | Gitlab::VisibilityLevel::PRIVATE | true | { weight: 3 } | false end with_them do - it 'checks for spam on issues that can be seen anonymously' do + it 'checks for spam when necessary' do + author = support_bot? ? support_bot : user project = reusable_project project.update!(visibility_level: visibility_level) - issue = create(:issue, project: project, confidential: confidential, description: 'original description') + issue = create(:issue, project: project, confidential: confidential, description: 'original description', author: author) issue.assign_attributes(new_attributes) |