2015-07-08 19:49:37 +00:00
|
|
|
require 'rails_helper'
|
2015-06-24 22:07:29 +00:00
|
|
|
|
2015-06-28 20:19:52 +00:00
|
|
|
feature 'Merge Request filtering by Milestone', feature: true do
|
2015-07-08 15:28:37 +00:00
|
|
|
let(:project) { create(:project, :public) }
|
2016-04-15 17:18:31 +00:00
|
|
|
let!(:user) { create(:user)}
|
2015-07-08 15:28:37 +00:00
|
|
|
let(:milestone) { create(:milestone, project: project) }
|
|
|
|
|
2016-04-15 17:18:31 +00:00
|
|
|
before do
|
|
|
|
project.team << [user, :master]
|
|
|
|
login_as(user)
|
|
|
|
end
|
|
|
|
|
2015-07-08 19:49:37 +00:00
|
|
|
scenario 'filters by no Milestone', js: true do
|
|
|
|
create(:merge_request, :with_diffs, source_project: project)
|
2015-07-08 15:28:37 +00:00
|
|
|
create(:merge_request, :simple, source_project: project, milestone: milestone)
|
2015-06-24 22:07:29 +00:00
|
|
|
|
2015-07-08 19:49:37 +00:00
|
|
|
visit_merge_requests(project)
|
2015-06-28 20:12:32 +00:00
|
|
|
filter_by_milestone(Milestone::None.title)
|
2015-06-24 22:07:29 +00:00
|
|
|
|
2016-09-29 14:55:55 +00:00
|
|
|
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
|
2016-03-29 14:26:12 +00:00
|
|
|
expect(page).to have_css('.merge-request', count: 1)
|
2015-06-24 22:07:29 +00:00
|
|
|
end
|
|
|
|
|
2016-03-23 16:56:16 +00:00
|
|
|
context 'filters by upcoming milestone', js: true do
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'does not show issues with no expiry' do
|
2016-03-23 16:56:16 +00:00
|
|
|
create(:merge_request, :with_diffs, source_project: project)
|
|
|
|
create(:merge_request, :simple, source_project: project, milestone: milestone)
|
|
|
|
|
|
|
|
visit_merge_requests(project)
|
|
|
|
filter_by_milestone(Milestone::Upcoming.title)
|
|
|
|
|
2016-03-29 14:26:12 +00:00
|
|
|
expect(page).to have_css('.merge-request', count: 0)
|
2016-03-23 16:56:16 +00:00
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'shows issues in future' do
|
2016-03-23 16:56:16 +00:00
|
|
|
milestone = create(:milestone, project: project, due_date: Date.tomorrow)
|
|
|
|
create(:merge_request, :with_diffs, source_project: project)
|
|
|
|
create(:merge_request, :simple, source_project: project, milestone: milestone)
|
|
|
|
|
|
|
|
visit_merge_requests(project)
|
|
|
|
filter_by_milestone(Milestone::Upcoming.title)
|
|
|
|
|
2016-09-29 14:55:55 +00:00
|
|
|
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
|
2016-03-29 17:20:10 +00:00
|
|
|
expect(page).to have_css('.merge-request', count: 1)
|
2016-03-23 16:56:16 +00:00
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'does not show issues in past' do
|
2016-03-23 16:56:16 +00:00
|
|
|
milestone = create(:milestone, project: project, due_date: Date.yesterday)
|
|
|
|
create(:merge_request, :with_diffs, source_project: project)
|
|
|
|
create(:merge_request, :simple, source_project: project, milestone: milestone)
|
|
|
|
|
|
|
|
visit_merge_requests(project)
|
|
|
|
filter_by_milestone(Milestone::Upcoming.title)
|
|
|
|
|
2016-03-29 17:20:10 +00:00
|
|
|
expect(page).to have_css('.merge-request', count: 0)
|
2016-03-23 16:56:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-07-08 19:49:37 +00:00
|
|
|
scenario 'filters by a specific Milestone', js: true do
|
|
|
|
create(:merge_request, :with_diffs, source_project: project, milestone: milestone)
|
2015-07-08 15:28:37 +00:00
|
|
|
create(:merge_request, :simple, source_project: project)
|
2015-06-24 22:07:29 +00:00
|
|
|
|
2015-07-08 19:49:37 +00:00
|
|
|
visit_merge_requests(project)
|
2015-06-24 22:07:29 +00:00
|
|
|
filter_by_milestone(milestone.title)
|
|
|
|
|
2016-09-29 14:55:55 +00:00
|
|
|
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
|
2016-03-29 17:20:10 +00:00
|
|
|
expect(page).to have_css('.merge-request', count: 1)
|
2015-06-24 22:07:29 +00:00
|
|
|
end
|
|
|
|
|
2016-10-14 17:52:10 +00:00
|
|
|
context 'when milestone has single quotes in title' do
|
|
|
|
background do
|
|
|
|
milestone.update(name: "rock 'n' roll")
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'filters by a specific Milestone', js: true do
|
|
|
|
create(:merge_request, :with_diffs, source_project: project, milestone: milestone)
|
|
|
|
create(:merge_request, :simple, source_project: project)
|
|
|
|
|
|
|
|
visit_merge_requests(project)
|
|
|
|
filter_by_milestone(milestone.title)
|
|
|
|
|
|
|
|
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
|
|
|
|
expect(page).to have_css('.merge-request', count: 1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-07-08 19:49:37 +00:00
|
|
|
def visit_merge_requests(project)
|
2015-06-24 22:07:29 +00:00
|
|
|
visit namespace_project_merge_requests_path(project.namespace, project)
|
|
|
|
end
|
|
|
|
|
|
|
|
def filter_by_milestone(title)
|
2016-03-10 09:51:39 +00:00
|
|
|
find(".js-milestone-select").click
|
|
|
|
find(".milestone-filter a", text: title).click
|
2015-06-24 22:07:29 +00:00
|
|
|
end
|
|
|
|
end
|