2016-06-02 11:05:42 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
describe 'Dashboard Issues filtering', :js do
|
2018-05-09 12:01:36 +05:30
|
|
|
include Spec::Support::Helpers::Features::SortingHelpers
|
2019-02-15 15:39:39 +05:30
|
|
|
include FilteredSearchHelpers
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
let(:user) { create(:user) }
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project) { create(:project) }
|
2016-06-02 11:05:42 +05:30
|
|
|
let(:milestone) { create(:milestone, project: project) }
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
let!(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
|
|
|
|
let!(:issue2) { create(:issue, project: project, author: user, assignees: [user], milestone: milestone) }
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
before do
|
2018-11-18 11:00:15 +05:30
|
|
|
project.add_maintainer(user)
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(user)
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
visit_issues
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
context 'without any filter' do
|
|
|
|
it 'shows error message' do
|
|
|
|
expect(page).to have_content 'Please select at least one filter to see results'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
context 'filtering by milestone' do
|
2016-09-13 17:45:13 +05:30
|
|
|
it 'shows all issues with no milestone' do
|
2019-02-15 15:39:39 +05:30
|
|
|
input_filtered_search("milestone:none")
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
|
2016-06-02 11:05:42 +05:30
|
|
|
expect(page).to have_selector('.issue', count: 1)
|
|
|
|
end
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
it 'shows all issues with the selected milestone' do
|
2019-02-15 15:39:39 +05:30
|
|
|
input_filtered_search("milestone:%\"#{milestone.title}\"")
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
|
2016-06-02 11:05:42 +05:30
|
|
|
expect(page).to have_selector('.issue', count: 1)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
it 'updates atom feed link' do
|
2019-02-15 15:39:39 +05:30
|
|
|
visit_issues(milestone_title: '', assignee_username: user.username)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
link = find('.nav-controls a[title="Subscribe to RSS feed"]')
|
2017-08-17 22:00:37 +05:30
|
|
|
params = CGI.parse(URI.parse(link[:href]).query)
|
|
|
|
auto_discovery_link = find('link[type="application/atom+xml"]', visible: false)
|
|
|
|
auto_discovery_params = CGI.parse(URI.parse(auto_discovery_link[:href]).query)
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(params).to include('feed_token' => [user.feed_token])
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(params).to include('milestone_title' => [''])
|
2019-02-15 15:39:39 +05:30
|
|
|
expect(params).to include('assignee_username' => [user.username.to_s])
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(auto_discovery_params).to include('feed_token' => [user.feed_token])
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(auto_discovery_params).to include('milestone_title' => [''])
|
2019-02-15 15:39:39 +05:30
|
|
|
expect(auto_discovery_params).to include('assignee_username' => [user.username.to_s])
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
context 'filtering by label' do
|
|
|
|
let(:label) { create(:label, project: project) }
|
|
|
|
let!(:label_link) { create(:label_link, label: label, target: issue) }
|
|
|
|
|
|
|
|
it 'shows all issues with the selected label' do
|
2019-02-15 15:39:39 +05:30
|
|
|
input_filtered_search("label:~#{label.title}")
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
page.within 'ul.content-list' do
|
|
|
|
expect(page).to have_content issue.title
|
|
|
|
expect(page).not_to have_content issue2.title
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'sorting' do
|
2018-05-09 12:01:36 +05:30
|
|
|
before do
|
2019-02-15 15:39:39 +05:30
|
|
|
visit_issues(assignee_username: user.username)
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'remembers last sorting value' do
|
|
|
|
sort_by('Created date')
|
2019-02-15 15:39:39 +05:30
|
|
|
visit_issues(assignee_username: user.username)
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(find('.issues-filters')).to have_content('Created date')
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'keeps sorting issues after visiting Projects Issues page' do
|
2018-05-09 12:01:36 +05:30
|
|
|
sort_by('Created date')
|
2017-09-10 17:25:29 +05:30
|
|
|
visit project_issues_path(project)
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(find('.issues-filters')).to have_content('Created date')
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def visit_issues(*args)
|
|
|
|
visit issues_dashboard_path(*args)
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
end
|