2016-07-18 08:23:45 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe 'New/edit issue', feature: true, js: true do
|
2017-03-08 19:14:16 -05:00
|
|
|
include GitlabRoutingHelper
|
|
|
|
|
2016-07-18 08:23:45 -04:00
|
|
|
let!(:project) { create(:project) }
|
|
|
|
let!(:user) { create(:user)}
|
2017-02-22 02:26:32 -05:00
|
|
|
let!(:user2) { create(:user)}
|
2016-07-18 08:23:45 -04:00
|
|
|
let!(:milestone) { create(:milestone, project: project) }
|
|
|
|
let!(:label) { create(:label, project: project) }
|
|
|
|
let!(:label2) { create(:label, project: project) }
|
|
|
|
let!(:issue) { create(:issue, project: project, assignee: user, milestone: milestone) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.team << [user, :master]
|
2017-02-22 02:26:32 -05:00
|
|
|
project.team << [user2, :master]
|
2016-07-18 08:23:45 -04:00
|
|
|
login_as(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'new issue' do
|
|
|
|
before do
|
|
|
|
visit new_namespace_project_issue_path(project.namespace, project)
|
|
|
|
end
|
|
|
|
|
2016-07-21 03:52:37 -04:00
|
|
|
it 'allows user to create new issue' do
|
2016-07-18 08:23:45 -04:00
|
|
|
fill_in 'issue_title', with: 'title'
|
|
|
|
fill_in 'issue_description', with: 'title'
|
|
|
|
|
2017-02-22 02:26:32 -05:00
|
|
|
expect(find('a', text: 'Assign to me')).to be_visible
|
2016-07-18 08:23:45 -04:00
|
|
|
click_button 'Assignee'
|
2016-07-19 05:05:38 -04:00
|
|
|
page.within '.dropdown-menu-user' do
|
2017-02-22 02:26:32 -05:00
|
|
|
click_link user2.name
|
2016-07-19 05:05:38 -04:00
|
|
|
end
|
2017-02-22 02:26:32 -05:00
|
|
|
expect(find('input[name="issue[assignee_id]"]', visible: false).value).to match(user2.id.to_s)
|
|
|
|
page.within '.js-assignee-search' do
|
|
|
|
expect(page).to have_content user2.name
|
|
|
|
end
|
|
|
|
expect(find('a', text: 'Assign to me')).to be_visible
|
|
|
|
|
|
|
|
click_link 'Assign to me'
|
2016-07-19 05:05:38 -04:00
|
|
|
expect(find('input[name="issue[assignee_id]"]', visible: false).value).to match(user.id.to_s)
|
|
|
|
page.within '.js-assignee-search' do
|
2016-07-18 08:23:45 -04:00
|
|
|
expect(page).to have_content user.name
|
|
|
|
end
|
2017-02-22 02:26:32 -05:00
|
|
|
expect(find('a', text: 'Assign to me', visible: false)).not_to be_visible
|
2016-07-18 08:23:45 -04:00
|
|
|
|
|
|
|
click_button 'Milestone'
|
2016-07-19 05:05:38 -04:00
|
|
|
page.within '.issue-milestone' do
|
|
|
|
click_link milestone.title
|
|
|
|
end
|
|
|
|
expect(find('input[name="issue[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
|
|
|
|
page.within '.js-milestone-select' do
|
2016-07-18 08:23:45 -04:00
|
|
|
expect(page).to have_content milestone.title
|
|
|
|
end
|
|
|
|
|
|
|
|
click_button 'Labels'
|
2016-07-19 05:05:38 -04:00
|
|
|
page.within '.dropdown-menu-labels' do
|
|
|
|
click_link label.title
|
|
|
|
click_link label2.title
|
|
|
|
end
|
|
|
|
page.within '.js-label-select' do
|
|
|
|
expect(page).to have_content label.title
|
2016-07-18 08:23:45 -04:00
|
|
|
end
|
2016-07-19 05:05:38 -04:00
|
|
|
expect(page.all('input[name="issue[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
|
|
|
|
expect(page.all('input[name="issue[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
|
2016-07-18 08:23:45 -04:00
|
|
|
|
|
|
|
click_button 'Submit issue'
|
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
page.within '.issuable-sidebar' do
|
|
|
|
page.within '.assignee' do
|
|
|
|
expect(page).to have_content user.name
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within '.milestone' do
|
|
|
|
expect(page).to have_content milestone.title
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within '.labels' do
|
|
|
|
expect(page).to have_content label.title
|
|
|
|
expect(page).to have_content label2.title
|
|
|
|
end
|
2016-07-18 08:23:45 -04:00
|
|
|
end
|
2017-03-08 19:14:16 -05:00
|
|
|
|
|
|
|
page.within '.issuable-meta' do
|
|
|
|
issue = Issue.find_by(title: 'title')
|
|
|
|
|
|
|
|
expect(page).to have_text("Issue #{issue.to_reference}")
|
|
|
|
# compare paths because the host differ in test
|
|
|
|
expect(find_link(issue.to_reference)[:href]).to end_with(issue_path(issue))
|
|
|
|
end
|
2016-07-18 08:23:45 -04:00
|
|
|
end
|
2017-01-16 16:56:53 -05:00
|
|
|
|
|
|
|
it 'correctly updates the dropdown toggle when removing a label' do
|
|
|
|
click_button 'Labels'
|
|
|
|
|
|
|
|
page.within '.dropdown-menu-labels' do
|
|
|
|
click_link label.title
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(find('.js-label-select')).to have_content(label.title)
|
|
|
|
|
|
|
|
page.within '.dropdown-menu-labels' do
|
|
|
|
click_link label.title
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(find('.js-label-select')).to have_content('Labels')
|
|
|
|
end
|
2016-07-18 08:23:45 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'edit issue' do
|
|
|
|
before do
|
|
|
|
visit edit_namespace_project_issue_path(project.namespace, project, issue)
|
|
|
|
end
|
|
|
|
|
2016-07-21 03:52:37 -04:00
|
|
|
it 'allows user to update issue' do
|
2016-07-19 05:05:38 -04:00
|
|
|
expect(find('input[name="issue[assignee_id]"]', visible: false).value).to match(user.id.to_s)
|
|
|
|
expect(find('input[name="issue[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
|
2017-02-22 02:26:32 -05:00
|
|
|
expect(find('a', text: 'Assign to me', visible: false)).not_to be_visible
|
2016-07-18 08:23:45 -04:00
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
page.within '.js-user-search' do
|
|
|
|
expect(page).to have_content user.name
|
|
|
|
end
|
2016-07-18 08:23:45 -04:00
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
page.within '.js-milestone-select' do
|
|
|
|
expect(page).to have_content milestone.title
|
2016-07-18 08:23:45 -04:00
|
|
|
end
|
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
click_button 'Labels'
|
|
|
|
page.within '.dropdown-menu-labels' do
|
|
|
|
click_link label.title
|
|
|
|
click_link label2.title
|
|
|
|
end
|
|
|
|
page.within '.js-label-select' do
|
|
|
|
expect(page).to have_content label.title
|
|
|
|
end
|
|
|
|
expect(page.all('input[name="issue[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
|
|
|
|
expect(page.all('input[name="issue[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
|
|
|
|
|
2016-07-18 08:23:45 -04:00
|
|
|
click_button 'Save changes'
|
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
page.within '.issuable-sidebar' do
|
|
|
|
page.within '.assignee' do
|
|
|
|
expect(page).to have_content user.name
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within '.milestone' do
|
|
|
|
expect(page).to have_content milestone.title
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within '.labels' do
|
|
|
|
expect(page).to have_content label.title
|
|
|
|
expect(page).to have_content label2.title
|
|
|
|
end
|
2016-07-18 08:23:45 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|