2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-03 08:07:09 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
RSpec.describe 'Dashboard Issues' do
|
2018-10-28 23:03:43 -04:00
|
|
|
include FilteredSearchHelpers
|
|
|
|
|
2017-02-03 08:07:09 -05:00
|
|
|
let(:current_user) { create :user }
|
2017-06-21 19:44:10 -04:00
|
|
|
let(:user) { current_user } # Shared examples depend on this being available
|
2017-08-02 15:55:11 -04:00
|
|
|
let!(:public_project) { create(:project, :public) }
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:project_with_issues_disabled) { create(:project, :issues_disabled) }
|
2017-02-03 08:07:09 -05:00
|
|
|
let!(:authored_issue) { create :issue, author: current_user, project: project }
|
|
|
|
let!(:authored_issue_on_public_project) { create :issue, author: current_user, project: public_project }
|
2017-05-04 08:11:15 -04:00
|
|
|
let!(:assigned_issue) { create :issue, assignees: [current_user], project: project }
|
2017-02-03 08:07:09 -05:00
|
|
|
let!(:other_issue) { create :issue, project: project }
|
|
|
|
|
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
[project, project_with_issues_disabled].each { |project| project.add_maintainer(current_user) }
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(current_user)
|
2018-10-28 23:03:43 -04:00
|
|
|
visit issues_dashboard_path(assignee_username: current_user.username)
|
2017-02-03 08:07:09 -05:00
|
|
|
end
|
|
|
|
|
2017-05-30 00:35:49 -04:00
|
|
|
describe 'issues' do
|
|
|
|
it 'shows issues assigned to current user' do
|
|
|
|
expect(page).to have_content(assigned_issue.title)
|
|
|
|
expect(page).not_to have_content(authored_issue.title)
|
|
|
|
expect(page).not_to have_content(other_issue.title)
|
|
|
|
end
|
2017-02-03 08:07:09 -05:00
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
it 'shows issues when current user is author', :js do
|
2018-10-28 23:03:43 -04:00
|
|
|
reset_filters
|
2020-03-04 04:08:20 -05:00
|
|
|
input_filtered_search("author:=#{current_user.to_reference}")
|
2017-05-04 08:11:15 -04:00
|
|
|
|
2017-05-30 00:35:49 -04:00
|
|
|
expect(page).to have_content(authored_issue.title)
|
|
|
|
expect(page).to have_content(authored_issue_on_public_project.title)
|
|
|
|
expect(page).not_to have_content(assigned_issue.title)
|
|
|
|
expect(page).not_to have_content(other_issue.title)
|
2017-05-04 08:11:15 -04:00
|
|
|
end
|
2017-02-03 08:07:09 -05:00
|
|
|
|
2017-06-21 15:45:50 -04:00
|
|
|
it 'state filter tabs work' do
|
|
|
|
find('#state-closed').click
|
2018-10-28 23:03:43 -04:00
|
|
|
expect(page).to have_current_path(issues_dashboard_url(assignee_username: current_user.username, state: 'closed'), url: true)
|
2017-06-21 15:45:50 -04:00
|
|
|
end
|
|
|
|
|
2018-05-31 10:01:04 -04:00
|
|
|
it_behaves_like "it has an RSS button with current_user's feed token"
|
|
|
|
it_behaves_like "an autodiscoverable RSS feed with current_user's feed token"
|
2017-02-03 08:07:09 -05:00
|
|
|
end
|
2017-02-28 15:50:57 -05:00
|
|
|
|
2017-05-30 00:35:49 -04:00
|
|
|
describe 'new issue dropdown' do
|
2017-10-03 04:35:01 -04:00
|
|
|
it 'shows projects only with issues feature enabled', :js do
|
2017-06-17 02:08:27 -04:00
|
|
|
find('.new-project-item-select-button').click
|
2017-05-30 00:35:49 -04:00
|
|
|
|
|
|
|
page.within('.select2-results') do
|
2018-03-05 09:15:26 -05:00
|
|
|
expect(page).to have_content(project.full_name)
|
|
|
|
expect(page).not_to have_content(project_with_issues_disabled.full_name)
|
2017-05-30 00:35:49 -04:00
|
|
|
end
|
|
|
|
end
|
2017-07-25 08:14:28 -04:00
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
it 'shows the new issue page', :js do
|
2017-08-03 01:13:46 -04:00
|
|
|
find('.new-project-item-select-button').click
|
2017-08-07 16:55:50 -04:00
|
|
|
|
2017-07-25 08:14:28 -04:00
|
|
|
wait_for_requests
|
|
|
|
|
2018-03-05 08:41:54 -05:00
|
|
|
project_path = "/#{project.full_path}"
|
2018-03-05 09:15:26 -05:00
|
|
|
project_json = { name: project.full_name, url: project_path }.to_json
|
2017-08-07 16:55:50 -04:00
|
|
|
|
2017-10-16 13:37:52 -04:00
|
|
|
# simulate selection, and prevent overlap by dropdown menu
|
|
|
|
first('.project-item-select', visible: false)
|
2017-08-07 16:55:50 -04:00
|
|
|
execute_script("$('.project-item-select').val('#{project_json}').trigger('change');")
|
2017-10-16 13:37:52 -04:00
|
|
|
find('#select2-drop-mask', visible: false)
|
2017-08-07 16:55:50 -04:00
|
|
|
execute_script("$('#select2-drop-mask').remove();")
|
|
|
|
|
2017-08-09 18:57:52 -04:00
|
|
|
find('.new-project-item-link').click
|
2017-08-07 16:55:50 -04:00
|
|
|
|
2020-04-23 14:09:46 -04:00
|
|
|
expect(page).to have_current_path("#{project_path}/-/issues/new")
|
2017-07-25 08:14:28 -04:00
|
|
|
|
|
|
|
page.within('#content-body') do
|
|
|
|
expect(page).to have_selector('.issue-form')
|
|
|
|
end
|
|
|
|
end
|
2017-05-30 00:35:49 -04:00
|
|
|
end
|
2017-02-03 08:07:09 -05:00
|
|
|
end
|