diff options
Diffstat (limited to 'spec/models/concerns/milestoneish_spec.rb')
-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 |