diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 18:07:55 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 18:07:55 +0000 |
commit | 603c7d4cac5e28bc1c75e50c23ed2cbe56f1aafc (patch) | |
tree | 907f5b8ee1b6f5aad396e95e3327a08400b9e8ea /spec/models/concerns | |
parent | 120f4aaedc8fe830a3f572491d240d8ee6addefb (diff) | |
download | gitlab-ce-603c7d4cac5e28bc1c75e50c23ed2cbe56f1aafc.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/concerns')
-rw-r--r-- | spec/models/concerns/milestoneish_spec.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/spec/models/concerns/milestoneish_spec.rb b/spec/models/concerns/milestoneish_spec.rb index cff607a4731..5808d6e37e5 100644 --- a/spec/models/concerns/milestoneish_spec.rb +++ b/spec/models/concerns/milestoneish_spec.rb @@ -33,17 +33,34 @@ describe Milestone, 'Milestoneish' do end describe '#sorted_issues' do - it 'sorts issues by label priority' do + before do issue.labels << label_1 security_issue_1.labels << label_2 closed_issue_1.labels << label_3 + end + it 'sorts issues by label priority' do issues = milestone.sorted_issues(member) expect(issues.first).to eq(issue) expect(issues.second).to eq(security_issue_1) expect(issues.third).not_to eq(closed_issue_1) end + + it 'limits issue count and keeps the ordering' do + stub_const('Milestoneish::DISPLAY_ISSUES_LIMIT', 4) + + issues = milestone.sorted_issues(member) + # Cannot use issues.count here because it is sorting + # by a virtual column 'highest_priority' and it will break + # the query. + total_issues_count = issues.opened.unassigned.length + issues.opened.assigned.length + issues.closed.length + expect(issues.length).to eq(4) + expect(total_issues_count).to eq(4) + expect(issues.first).to eq(issue) + expect(issues.second).to eq(security_issue_1) + expect(issues.third).not_to eq(closed_issue_1) + end end context 'attributes visibility' do |