2019-07-25 01:24:42 -04:00
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2019-08-29 03:56:52 -04:00
|
|
|
|
require 'spec_helper'
|
2016-04-26 07:22:52 -04:00
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
|
RSpec.describe 'Milestone' do
|
2017-07-07 11:08:49 -04:00
|
|
|
|
let(:group) { create(:group, :public) }
|
2017-08-02 15:55:11 -04:00
|
|
|
|
let(:project) { create(:project, :public, namespace: group) }
|
2019-01-16 07:09:29 -05:00
|
|
|
|
let(:user) { create(:user) }
|
2016-04-26 07:22:52 -04:00
|
|
|
|
|
|
|
|
|
before do
|
2017-07-07 11:08:49 -04:00
|
|
|
|
create(:group_member, group: group, user: user)
|
2018-07-11 10:36:08 -04:00
|
|
|
|
project.add_maintainer(user)
|
2017-06-21 19:44:10 -04:00
|
|
|
|
sign_in(user)
|
2016-04-26 07:22:52 -04:00
|
|
|
|
end
|
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
|
describe 'Create a milestone' do
|
|
|
|
|
it 'shows an informative message for a new milestone' do
|
2017-07-06 12:20:50 -04:00
|
|
|
|
visit new_project_milestone_path(project)
|
2016-11-15 12:48:30 -05:00
|
|
|
|
|
2016-04-26 07:22:52 -04:00
|
|
|
|
page.within '.milestone-form' do
|
|
|
|
|
fill_in "milestone_title", with: '8.7'
|
2016-11-15 12:48:30 -05:00
|
|
|
|
fill_in "milestone_start_date", with: '2016-11-16'
|
|
|
|
|
fill_in "milestone_due_date", with: '2016-12-16'
|
2016-04-26 07:22:52 -04:00
|
|
|
|
end
|
2016-11-15 12:48:30 -05:00
|
|
|
|
|
2016-04-26 07:22:52 -04:00
|
|
|
|
find('input[name="commit"]').click
|
|
|
|
|
|
2020-10-05 23:08:19 -04:00
|
|
|
|
expect(find('[data-testid="no-issues-alert"]')).to have_content('Assign some issues to this milestone.')
|
2017-02-24 12:07:29 -05:00
|
|
|
|
expect(page).to have_content('Nov 16, 2016–Dec 16, 2016')
|
2016-04-26 07:22:52 -04:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
|
describe 'Open a milestone with closed issues' do
|
|
|
|
|
it 'shows an informative message' do
|
2016-09-12 15:14:26 -04:00
|
|
|
|
milestone = create(:milestone, project: project, title: 8.7)
|
|
|
|
|
|
2016-04-26 07:22:52 -04:00
|
|
|
|
create(:issue, title: "Bugfix1", project: project, milestone: milestone, state: "closed")
|
2017-07-06 12:20:50 -04:00
|
|
|
|
visit project_milestone_path(project, milestone)
|
2016-04-26 07:22:52 -04:00
|
|
|
|
|
2020-10-05 23:08:19 -04:00
|
|
|
|
expect(find('[data-testid="all-issues-closed-alert"]')).to have_content('All issues for this milestone are closed. You may close this milestone now.')
|
2016-04-26 07:22:52 -04:00
|
|
|
|
end
|
|
|
|
|
end
|
2016-09-12 15:14:26 -04:00
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
|
describe 'Open a project milestone with an existing title' do
|
|
|
|
|
it 'displays validation message when there is a project milestone with same title' do
|
2016-09-12 15:14:26 -04:00
|
|
|
|
milestone = create(:milestone, project: project, title: 8.7)
|
|
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
|
visit new_project_milestone_path(project)
|
2016-09-12 15:14:26 -04:00
|
|
|
|
page.within '.milestone-form' do
|
|
|
|
|
fill_in "milestone_title", with: milestone.title
|
|
|
|
|
end
|
|
|
|
|
find('input[name="commit"]').click
|
|
|
|
|
|
2017-07-07 11:08:49 -04:00
|
|
|
|
expect(find('.alert-danger')).to have_content('already being used for another group or project milestone.')
|
|
|
|
|
end
|
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
|
it 'displays validation message when there is a group milestone with same title' do
|
2017-07-07 11:08:49 -04:00
|
|
|
|
milestone = create(:milestone, project_id: nil, group: project.group, title: 8.7)
|
|
|
|
|
|
|
|
|
|
visit new_group_milestone_path(project.group)
|
|
|
|
|
|
|
|
|
|
page.within '.milestone-form' do
|
|
|
|
|
fill_in "milestone_title", with: milestone.title
|
|
|
|
|
end
|
|
|
|
|
find('input[name="commit"]').click
|
|
|
|
|
|
|
|
|
|
expect(find('.alert-danger')).to have_content('already being used for another group or project milestone.')
|
2016-09-12 15:14:26 -04:00
|
|
|
|
end
|
|
|
|
|
end
|
2017-11-07 14:49:41 -05:00
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
|
describe 'Open a milestone', :js do
|
|
|
|
|
it 'shows total issue time spent correctly when no time has been logged' do
|
2017-11-07 14:49:41 -05:00
|
|
|
|
milestone = create(:milestone, project: project, title: 8.7)
|
|
|
|
|
|
|
|
|
|
visit project_milestone_path(project, milestone)
|
|
|
|
|
|
2018-02-21 12:20:56 -05:00
|
|
|
|
wait_for_requests
|
|
|
|
|
|
2020-10-23 05:08:41 -04:00
|
|
|
|
page.within('[data-testid="noTrackingPane"]') do
|
2018-02-21 12:20:56 -05:00
|
|
|
|
expect(page).to have_content 'No estimate or time spent'
|
2017-11-07 14:49:41 -05:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
|
it 'shows total issue time spent' do
|
2017-11-07 14:49:41 -05:00
|
|
|
|
milestone = create(:milestone, project: project, title: 8.7)
|
|
|
|
|
issue1 = create(:issue, project: project, milestone: milestone)
|
|
|
|
|
issue2 = create(:issue, project: project, milestone: milestone)
|
2017-12-14 14:32:55 -05:00
|
|
|
|
issue1.spend_time(duration: 3600, user_id: user.id)
|
2017-11-07 14:49:41 -05:00
|
|
|
|
issue1.save!
|
2017-12-14 14:32:55 -05:00
|
|
|
|
issue2.spend_time(duration: 7200, user_id: user.id)
|
2017-11-07 14:49:41 -05:00
|
|
|
|
issue2.save!
|
|
|
|
|
|
|
|
|
|
visit project_milestone_path(project, milestone)
|
|
|
|
|
|
2018-02-21 12:20:56 -05:00
|
|
|
|
wait_for_requests
|
|
|
|
|
|
2020-10-23 05:08:41 -04:00
|
|
|
|
page.within('[data-testid="spentOnlyPane"]') do
|
2018-02-21 12:20:56 -05:00
|
|
|
|
expect(page).to have_content 'Spent: 3h'
|
2017-11-07 14:49:41 -05:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2018-03-01 18:20:06 -05:00
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
|
describe 'Deleting a milestone' do
|
2020-12-09 13:09:48 -05:00
|
|
|
|
it "the delete milestone button does not show for unauthorized users" do
|
2018-03-01 18:20:06 -05:00
|
|
|
|
create(:milestone, project: project, title: 8.7)
|
|
|
|
|
sign_out(user)
|
|
|
|
|
|
|
|
|
|
visit group_milestones_path(group)
|
|
|
|
|
|
|
|
|
|
expect(page).to have_selector('.js-delete-milestone-button', count: 0)
|
|
|
|
|
end
|
|
|
|
|
end
|
2018-03-23 15:14:09 -04:00
|
|
|
|
|
2019-03-26 09:47:54 -04:00
|
|
|
|
describe 'reopen closed milestones' do
|
|
|
|
|
before do
|
|
|
|
|
create(:milestone, :closed, project: project)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'group milestones page' do
|
|
|
|
|
it 'reopens the milestone' do
|
|
|
|
|
visit group_milestones_path(group, { state: 'closed' })
|
|
|
|
|
|
|
|
|
|
click_link 'Reopen Milestone'
|
|
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('.status-box-closed')
|
|
|
|
|
expect(page).to have_selector('.status-box-open')
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'project milestones page' do
|
|
|
|
|
it 'reopens the milestone' do
|
|
|
|
|
visit project_milestones_path(project, { state: 'closed' })
|
|
|
|
|
|
|
|
|
|
click_link 'Reopen Milestone'
|
|
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('.status-box-closed')
|
|
|
|
|
expect(page).to have_selector('.status-box-open')
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2016-04-26 07:22:52 -04:00
|
|
|
|
end
|