2016-04-22 16:32:08 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'Projects > Merge requests > User lists merge requests', feature: true do
|
2016-07-23 23:28:12 +00:00
|
|
|
include MergeRequestHelpers
|
2016-04-22 16:32:08 +00:00
|
|
|
include SortingHelper
|
|
|
|
|
|
|
|
let(:project) { create(:project, :public) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
@fix = create(:merge_request,
|
|
|
|
title: 'fix',
|
|
|
|
source_project: project,
|
|
|
|
source_branch: 'fix',
|
|
|
|
assignee: user,
|
|
|
|
milestone: create(:milestone, due_date: '2013-12-11'),
|
|
|
|
created_at: 1.minute.ago,
|
|
|
|
updated_at: 1.minute.ago)
|
|
|
|
create(:merge_request,
|
|
|
|
title: 'markdown',
|
|
|
|
source_project: project,
|
|
|
|
source_branch: 'markdown',
|
|
|
|
assignee: user,
|
|
|
|
milestone: create(:milestone, due_date: '2013-12-12'),
|
|
|
|
created_at: 2.minutes.ago,
|
|
|
|
updated_at: 2.minutes.ago)
|
2016-07-23 23:28:12 +00:00
|
|
|
# lfs in itself is not a great choice for the title if one wants to match the whole body content later on
|
|
|
|
# just think about the scenario when faker generates 'Chester Runolfsson' as the user's name
|
2016-04-22 16:32:08 +00:00
|
|
|
create(:merge_request,
|
2016-07-23 23:28:12 +00:00
|
|
|
title: 'merge_lfs',
|
2016-04-22 16:32:08 +00:00
|
|
|
source_project: project,
|
2016-07-23 23:28:12 +00:00
|
|
|
source_branch: 'merge_lfs',
|
2016-04-22 16:32:08 +00:00
|
|
|
created_at: 3.minutes.ago,
|
|
|
|
updated_at: 10.seconds.ago)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters on no assignee' do
|
|
|
|
visit_merge_requests(project, assignee_id: IssuableFinder::NONE)
|
|
|
|
|
|
|
|
expect(current_path).to eq(namespace_project_merge_requests_path(project.namespace, project))
|
2016-07-23 23:28:12 +00:00
|
|
|
expect(page).to have_content 'merge_lfs'
|
2016-04-22 16:32:08 +00:00
|
|
|
expect(page).not_to have_content 'fix'
|
|
|
|
expect(page).not_to have_content 'markdown'
|
2016-05-14 14:14:25 +00:00
|
|
|
expect(count_merge_requests).to eq(1)
|
2016-04-22 16:32:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters on a specific assignee' do
|
|
|
|
visit_merge_requests(project, assignee_id: user.id)
|
|
|
|
|
2016-07-23 23:28:12 +00:00
|
|
|
expect(page).not_to have_content 'merge_lfs'
|
2016-04-22 16:32:08 +00:00
|
|
|
expect(page).to have_content 'fix'
|
|
|
|
expect(page).to have_content 'markdown'
|
2016-05-14 14:14:25 +00:00
|
|
|
expect(count_merge_requests).to eq(2)
|
2016-04-22 16:32:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'sorts by newest' do
|
|
|
|
visit_merge_requests(project, sort: sort_value_recently_created)
|
|
|
|
|
2016-07-23 23:28:12 +00:00
|
|
|
expect(first_merge_request).to include('fix')
|
|
|
|
expect(last_merge_request).to include('merge_lfs')
|
2016-05-14 14:14:25 +00:00
|
|
|
expect(count_merge_requests).to eq(3)
|
2016-04-22 16:32:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'sorts by oldest' do
|
|
|
|
visit_merge_requests(project, sort: sort_value_oldest_created)
|
|
|
|
|
2016-07-23 23:28:12 +00:00
|
|
|
expect(first_merge_request).to include('merge_lfs')
|
|
|
|
expect(last_merge_request).to include('fix')
|
2016-05-14 14:14:25 +00:00
|
|
|
expect(count_merge_requests).to eq(3)
|
2016-04-22 16:32:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'sorts by last updated' do
|
|
|
|
visit_merge_requests(project, sort: sort_value_recently_updated)
|
|
|
|
|
2016-07-23 23:28:12 +00:00
|
|
|
expect(first_merge_request).to include('merge_lfs')
|
2016-05-14 14:14:25 +00:00
|
|
|
expect(count_merge_requests).to eq(3)
|
2016-04-22 16:32:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'sorts by oldest updated' do
|
|
|
|
visit_merge_requests(project, sort: sort_value_oldest_updated)
|
|
|
|
|
|
|
|
expect(first_merge_request).to include('markdown')
|
2016-05-14 14:14:25 +00:00
|
|
|
expect(count_merge_requests).to eq(3)
|
2016-04-22 16:32:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'sorts by milestone due soon' do
|
|
|
|
visit_merge_requests(project, sort: sort_value_milestone_soon)
|
|
|
|
|
|
|
|
expect(first_merge_request).to include('fix')
|
2016-05-14 14:14:25 +00:00
|
|
|
expect(count_merge_requests).to eq(3)
|
2016-04-22 16:32:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'sorts by milestone due later' do
|
|
|
|
visit_merge_requests(project, sort: sort_value_milestone_later)
|
|
|
|
|
|
|
|
expect(first_merge_request).to include('markdown')
|
2016-05-14 14:14:25 +00:00
|
|
|
expect(count_merge_requests).to eq(3)
|
2016-04-22 16:32:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters on one label and sorts by due soon' do
|
|
|
|
label = create(:label, project: project)
|
|
|
|
create(:label_link, label: label, target: @fix)
|
|
|
|
|
|
|
|
visit_merge_requests(project, label_name: [label.name],
|
|
|
|
sort: sort_value_due_date_soon)
|
|
|
|
|
|
|
|
expect(first_merge_request).to include('fix')
|
2016-05-14 14:14:25 +00:00
|
|
|
expect(count_merge_requests).to eq(1)
|
2016-04-22 16:32:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'while filtering on two labels' do
|
|
|
|
let(:label) { create(:label, project: project) }
|
|
|
|
let(:label2) { create(:label, project: project) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
create(:label_link, label: label, target: @fix)
|
|
|
|
create(:label_link, label: label2, target: @fix)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sorts by due soon' do
|
|
|
|
visit_merge_requests(project, label_name: [label.name, label2.name],
|
|
|
|
sort: sort_value_due_date_soon)
|
|
|
|
|
|
|
|
expect(first_merge_request).to include('fix')
|
2016-05-14 14:14:25 +00:00
|
|
|
expect(count_merge_requests).to eq(1)
|
2016-04-22 16:32:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'filter on assignee and' do
|
|
|
|
it 'sorts by due soon' do
|
|
|
|
visit_merge_requests(project, label_name: [label.name, label2.name],
|
|
|
|
assignee_id: user.id,
|
|
|
|
sort: sort_value_due_date_soon)
|
|
|
|
|
|
|
|
expect(first_merge_request).to include('fix')
|
2016-05-14 14:14:25 +00:00
|
|
|
expect(count_merge_requests).to eq(1)
|
2016-04-22 16:32:08 +00:00
|
|
|
end
|
2016-05-27 19:53:20 +00:00
|
|
|
|
|
|
|
it 'sorts by recently due milestone' do
|
|
|
|
visit namespace_project_merge_requests_path(project.namespace, project,
|
|
|
|
label_name: [label.name, label2.name],
|
|
|
|
assignee_id: user.id,
|
|
|
|
sort: sort_value_milestone_soon)
|
|
|
|
|
|
|
|
expect(first_merge_request).to include('fix')
|
|
|
|
end
|
2016-04-22 16:32:08 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-05-14 14:14:25 +00:00
|
|
|
def count_merge_requests
|
|
|
|
page.all('ul.mr-list > li').count
|
|
|
|
end
|
2016-04-22 16:32:08 +00:00
|
|
|
end
|