summaryrefslogtreecommitdiff
path: root/spec/models/concerns
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-24 18:07:55 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-24 18:07:55 +0000
commit603c7d4cac5e28bc1c75e50c23ed2cbe56f1aafc (patch)
tree907f5b8ee1b6f5aad396e95e3327a08400b9e8ea /spec/models/concerns
parent120f4aaedc8fe830a3f572491d240d8ee6addefb (diff)
downloadgitlab-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.rb19
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