2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 03:56:52 -04:00
|
|
|
require 'spec_helper'
|
2016-03-23 06:36:30 -04:00
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Multiple issue updating from issues#index', :js do
|
2017-08-02 15:55:11 -04:00
|
|
|
let!(:project) { create(:project) }
|
2016-03-23 06:36:30 -04:00
|
|
|
let!(:issue) { create(:issue, project: project) }
|
2022-07-29 17:08:53 -04:00
|
|
|
let!(:user) { create(:user) }
|
2016-03-23 06:36:30 -04:00
|
|
|
|
2016-03-23 07:45:24 -04:00
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2017-07-03 06:55:15 -04:00
|
|
|
sign_in(user)
|
2016-03-23 07:45:24 -04:00
|
|
|
end
|
2016-03-23 06:36:30 -04:00
|
|
|
|
2017-07-03 06:55:15 -04:00
|
|
|
context 'status' do
|
2021-06-18 11:10:16 -04:00
|
|
|
it 'sets to closed', :js do
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_issues_path(project)
|
2016-03-23 06:36:30 -04:00
|
|
|
|
2017-08-15 04:07:41 -04:00
|
|
|
click_button 'Edit issues'
|
2021-05-18 23:10:31 -04:00
|
|
|
check 'Select all'
|
|
|
|
click_button 'Select status'
|
2021-06-18 11:10:16 -04:00
|
|
|
click_button 'Closed'
|
2016-03-23 06:36:30 -04:00
|
|
|
|
|
|
|
click_update_issues_button
|
|
|
|
expect(page).to have_selector('.issue', count: 0)
|
|
|
|
end
|
|
|
|
|
2021-06-18 11:10:16 -04:00
|
|
|
it 'sets to open', :js do
|
2016-03-23 06:36:30 -04:00
|
|
|
create_closed
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_issues_path(project, state: 'closed')
|
2016-03-23 06:36:30 -04:00
|
|
|
|
2017-08-15 04:07:41 -04:00
|
|
|
click_button 'Edit issues'
|
2021-05-18 23:10:31 -04:00
|
|
|
check 'Select all'
|
|
|
|
click_button 'Select status'
|
2021-06-18 11:10:16 -04:00
|
|
|
click_button 'Open'
|
2016-03-23 06:36:30 -04:00
|
|
|
|
|
|
|
click_update_issues_button
|
|
|
|
expect(page).to have_selector('.issue', count: 0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-07-03 06:55:15 -04:00
|
|
|
context 'assignee' do
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'updates to current user' do
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_issues_path(project)
|
2016-03-23 07:18:39 -04:00
|
|
|
|
2017-08-15 04:07:41 -04:00
|
|
|
click_button 'Edit issues'
|
2021-05-18 23:10:31 -04:00
|
|
|
check 'Select all'
|
2016-05-10 19:11:16 -04:00
|
|
|
click_update_assignee_button
|
2021-05-18 23:10:31 -04:00
|
|
|
click_link user.username
|
2016-03-23 07:18:39 -04:00
|
|
|
|
|
|
|
click_update_issues_button
|
|
|
|
|
|
|
|
page.within('.issue .controls') do
|
2020-07-28 02:09:53 -04:00
|
|
|
expect(find('.author-link')['href']).to have_content(user.website_url)
|
2016-03-23 07:18:39 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'updates to unassigned' do
|
2016-03-23 07:18:39 -04:00
|
|
|
create_assigned
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_issues_path(project)
|
2016-03-23 07:18:39 -04:00
|
|
|
|
2021-05-18 23:10:31 -04:00
|
|
|
expect(find('.issue:first-of-type')).to have_link "Assigned to #{user.name}"
|
|
|
|
|
2017-08-15 04:07:41 -04:00
|
|
|
click_button 'Edit issues'
|
2021-05-18 23:10:31 -04:00
|
|
|
check 'Select all'
|
2016-05-10 19:11:16 -04:00
|
|
|
click_update_assignee_button
|
2016-03-24 05:10:46 -04:00
|
|
|
click_link 'Unassigned'
|
2016-03-23 07:18:39 -04:00
|
|
|
click_update_issues_button
|
2021-05-18 23:10:31 -04:00
|
|
|
|
|
|
|
expect(find('.issue:first-of-type')).not_to have_link "Assigned to #{user.name}"
|
2016-03-23 07:18:39 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-07-03 06:55:15 -04:00
|
|
|
context 'milestone' do
|
|
|
|
let!(:milestone) { create(:milestone, project: project) }
|
2016-03-23 07:45:24 -04:00
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'updates milestone' do
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_issues_path(project)
|
2016-03-23 07:45:24 -04:00
|
|
|
|
2017-08-15 04:07:41 -04:00
|
|
|
click_button 'Edit issues'
|
2021-05-18 23:10:31 -04:00
|
|
|
check 'Select all'
|
|
|
|
click_button 'Select milestone'
|
|
|
|
click_link milestone.title
|
2016-03-23 07:45:24 -04:00
|
|
|
click_update_issues_button
|
|
|
|
|
2020-07-28 02:09:53 -04:00
|
|
|
expect(page.find('.issue')).to have_content milestone.title
|
2016-03-23 07:45:24 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'sets to no milestone' do
|
2016-03-23 07:45:24 -04:00
|
|
|
create_with_milestone
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_issues_path(project)
|
2016-03-23 07:45:24 -04:00
|
|
|
|
2020-07-28 02:09:53 -04:00
|
|
|
wait_for_requests
|
|
|
|
|
2021-05-18 23:10:31 -04:00
|
|
|
expect(find('.issue:first-of-type')).to have_text milestone.title
|
2016-03-23 07:45:24 -04:00
|
|
|
|
2017-08-15 04:07:41 -04:00
|
|
|
click_button 'Edit issues'
|
2021-05-18 23:10:31 -04:00
|
|
|
check 'Select all'
|
|
|
|
click_button 'Select milestone'
|
|
|
|
click_link 'No milestone'
|
2016-03-23 07:45:24 -04:00
|
|
|
click_update_issues_button
|
|
|
|
|
2021-05-18 23:10:31 -04:00
|
|
|
expect(find('.issue:first-of-type')).not_to have_text milestone.title
|
2016-03-23 07:45:24 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-01-07 19:14:32 -05:00
|
|
|
describe 'select all issues' do
|
|
|
|
let!(:issue_2) { create(:issue, project: project) }
|
|
|
|
|
|
|
|
it 'after selecting all issues, unchecking one issue only unselects that one issue' do
|
|
|
|
visit project_issues_path(project)
|
|
|
|
|
|
|
|
click_button 'Edit issues'
|
|
|
|
check 'Select all'
|
|
|
|
uncheck issue.title
|
|
|
|
|
|
|
|
expect(page).to have_unchecked_field 'Select all'
|
|
|
|
expect(page).to have_unchecked_field issue.title
|
|
|
|
expect(page).to have_checked_field issue_2.title
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-03-23 06:36:30 -04:00
|
|
|
def create_closed
|
|
|
|
create(:issue, project: project, state: :closed)
|
|
|
|
end
|
|
|
|
|
2016-03-23 07:18:39 -04:00
|
|
|
def create_assigned
|
2017-05-04 08:11:15 -04:00
|
|
|
create(:issue, project: project, assignees: [user])
|
2016-03-23 07:18:39 -04:00
|
|
|
end
|
|
|
|
|
2016-03-23 07:45:24 -04:00
|
|
|
def create_with_milestone
|
|
|
|
create(:issue, project: project, milestone: milestone)
|
|
|
|
end
|
|
|
|
|
2016-05-10 19:11:16 -04:00
|
|
|
def click_update_assignee_button
|
2021-05-18 23:10:31 -04:00
|
|
|
click_button 'Select assignee'
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-05-10 19:11:16 -04:00
|
|
|
end
|
|
|
|
|
2016-03-23 06:36:30 -04:00
|
|
|
def click_update_issues_button
|
2021-05-18 23:10:31 -04:00
|
|
|
click_button 'Update all'
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-03-23 06:36:30 -04:00
|
|
|
end
|
|
|
|
end
|