debian-mirror-gitlab/spec/features/dashboard/issues_spec.rb

104 lines
4 KiB
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
RSpec.describe 'Dashboard Issues' do
2017-08-17 22:00:37 +05:30
let(:current_user) { create :user }
2017-09-10 17:25:29 +05:30
let(:user) { current_user } # Shared examples depend on this being available
let!(:public_project) { create(:project, :public) }
let(:project) { create(:project) }
let(:project_with_issues_disabled) { create(:project, :issues_disabled) }
2017-08-17 22:00:37 +05:30
let!(:authored_issue) { create :issue, author: current_user, project: project }
let!(:authored_issue_on_public_project) { create :issue, author: current_user, project: public_project }
let!(:assigned_issue) { create :issue, assignees: [current_user], project: project }
let!(:other_issue) { create :issue, project: project }
before do
2017-09-10 17:25:29 +05:30
[project, project_with_issues_disabled].each { |project| project.team << [current_user, :master] }
sign_in(current_user)
2017-08-17 22:00:37 +05:30
visit issues_dashboard_path(assignee_id: current_user.id)
end
2017-09-10 17:25:29 +05:30
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-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
it 'shows checkmark when unassigned is selected for assignee', js: true do
find('.js-assignee-search').click
find('li', text: 'Unassigned').click
find('.js-assignee-search').click
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(find('li[data-user-id="0"] a.is-active')).to be_visible
end
it 'shows issues when current user is author', js: true do
find('#assignee_id', visible: false).set('')
find('.js-author-search', match: :first).click
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(find('li[data-user-id="null"] a.is-active')).to be_visible
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
find('.dropdown-menu-author li a', match: :first, text: current_user.to_reference).click
find('.js-author-search', match: :first).click
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
page.within '.dropdown-menu-user' do
expect(find('.dropdown-menu-author li a.is-active', match: :first, text: current_user.to_reference)).to be_visible
end
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
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-08-17 22:00:37 +05:30
end
2017-09-10 17:25:29 +05:30
it 'shows all issues' do
click_link('Reset filters')
expect(page).to have_content(authored_issue.title)
expect(page).to have_content(authored_issue_on_public_project.title)
expect(page).to have_content(assigned_issue.title)
expect(page).to have_content(other_issue.title)
end
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
it 'state filter tabs work' do
find('#state-closed').click
expect(page).to have_current_path(issues_dashboard_url(assignee_id: current_user.id, state: 'closed'), url: true)
end
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
it_behaves_like "it has an RSS button with current_user's RSS token"
it_behaves_like "an autodiscoverable RSS feed with current_user's RSS token"
2017-08-17 22:00:37 +05:30
end
2017-09-10 17:25:29 +05:30
describe 'new issue dropdown' do
it 'shows projects only with issues feature enabled', js: true do
find('.new-project-item-select-button').trigger('click')
page.within('.select2-results') do
expect(page).to have_content(project.name_with_namespace)
expect(page).not_to have_content(project_with_issues_disabled.name_with_namespace)
end
end
it 'shows the new issue page', js: true do
find('.new-project-item-select-button').trigger('click')
wait_for_requests
project_path = "/#{project.path_with_namespace}"
project_json = { name: project.name_with_namespace, url: project_path }.to_json
# similate selection, and prevent overlap by dropdown menu
execute_script("$('.project-item-select').val('#{project_json}').trigger('change');")
execute_script("$('#select2-drop-mask').remove();")
find('.new-project-item-link').trigger('click')
expect(page).to have_current_path("#{project_path}/issues/new")
page.within('#content-body') do
expect(page).to have_selector('.issue-form')
end
end
end
2017-08-17 22:00:37 +05:30
end