summaryrefslogtreecommitdiff
path: root/spec/models/concerns/milestoneish_spec.rb
diff options
context:
space:
mode:
authorFelipe Artur <felipefac@gmail.com>2017-06-09 12:54:20 -0300
committerFelipe Artur <felipefac@gmail.com>2017-06-16 12:02:20 -0300
commit2e3f0b08fbc0387d3f7985bf61c16e8ec9821750 (patch)
tree32e5d96bbfb20ec79f5dbf5a9448ab40f0ff4a04 /spec/models/concerns/milestoneish_spec.rb
parent673bc07c0f6cb936fbc2037440634133ad32afaf (diff)
downloadgitlab-ce-2e3f0b08fbc0387d3f7985bf61c16e8ec9821750.tar.gz
Remove old specs and add new ones
Diffstat (limited to 'spec/models/concerns/milestoneish_spec.rb')
-rw-r--r--spec/models/concerns/milestoneish_spec.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/models/concerns/milestoneish_spec.rb b/spec/models/concerns/milestoneish_spec.rb
index 675b730c557..7616123b486 100644
--- a/spec/models/concerns/milestoneish_spec.rb
+++ b/spec/models/concerns/milestoneish_spec.rb
@@ -19,12 +19,47 @@ describe Milestone, 'Milestoneish' do
let!(:closed_security_issue_3) { create(:issue, :confidential, :closed, project: project, author: author, milestone: milestone) }
let!(:closed_security_issue_4) { create(:issue, :confidential, :closed, project: project, assignees: [assignee], milestone: milestone) }
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project, milestone: milestone) }
+ let(:label_1) { create(:label, title: 'label_1', project: project, priority: 1) }
+ let(:label_2) { create(:label, title: 'label_2', project: project, priority: 2) }
+ let(:label_3) { create(:label, title: 'label_3', project: project) }
before do
project.team << [member, :developer]
project.team << [guest, :guest]
end
+ describe '#issues_visible_to_user' do
+ it 'sorts issues by label priority' do
+ issue.labels << label_1
+ security_issue_1.labels << label_2
+ closed_issue_1.labels << label_3
+
+ issues = milestone.issues_visible_to_user(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
+ end
+
+ describe '#sorted_merge_requests' do
+ let(:merge_request_1) { create(:merge_request, :simple, source_project: project, source_branch: 'branch_1', milestone: milestone) }
+ let(:merge_request_2) { create(:merge_request, :simple, source_project: project, source_branch: 'branch_2', milestone: milestone) }
+ let(:merge_request_3) { create(:merge_request, :simple, source_project: project, source_branch: 'branch_3', milestone: milestone) }
+
+ it 'sorts merge requests by label priority' do
+ merge_request_2.labels << label_1
+ merge_request_1.labels << label_2
+ merge_request_3.labels << label_3
+
+ merge_requests = milestone.sorted_merge_requests
+
+ expect(merge_requests.first).to eq(merge_request_2)
+ expect(merge_requests.second).to eq(merge_request_1)
+ expect(merge_requests.third).to eq(merge_request_3)
+ end
+ end
+
describe '#closed_items_count' do
it 'does not count confidential issues for non project members' do
expect(milestone.closed_items_count(non_member)).to eq 2