debian-mirror-gitlab/spec/features/milestone_spec.rb

156 lines
4.8 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2016-06-02 11:05:42 +05:30
require 'rails_helper'
2018-11-08 19:23:39 +05:30
describe 'Milestone' do
2017-09-10 17:25:29 +05:30
let(:group) { create(:group, :public) }
let(:project) { create(:project, :public, namespace: group) }
2019-03-02 22:35:43 +05:30
let(:user) { create(:user) }
2016-06-02 11:05:42 +05:30
before do
2017-09-10 17:25:29 +05:30
create(:group_member, group: group, user: user)
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2017-09-10 17:25:29 +05:30
sign_in(user)
2016-06-02 11:05:42 +05:30
end
2018-11-08 19:23:39 +05:30
describe 'Create a milestone' do
it 'shows an informative message for a new milestone' do
2017-09-10 17:25:29 +05:30
visit new_project_milestone_path(project)
2017-08-17 22:00:37 +05:30
2016-06-02 11:05:42 +05:30
page.within '.milestone-form' do
fill_in "milestone_title", with: '8.7'
2017-08-17 22:00:37 +05:30
fill_in "milestone_start_date", with: '2016-11-16'
fill_in "milestone_due_date", with: '2016-12-16'
2016-06-02 11:05:42 +05:30
end
2017-08-17 22:00:37 +05:30
2016-06-02 11:05:42 +05:30
find('input[name="commit"]').click
expect(find('.alert-success')).to have_content('Assign some issues to this milestone.')
2017-08-17 22:00:37 +05:30
expect(page).to have_content('Nov 16, 2016Dec 16, 2016')
2016-06-02 11:05:42 +05:30
end
end
2018-11-08 19:23:39 +05:30
describe 'Open a milestone with closed issues' do
it 'shows an informative message' do
2016-09-29 09:46:39 +05:30
milestone = create(:milestone, project: project, title: 8.7)
2016-06-02 11:05:42 +05:30
create(:issue, title: "Bugfix1", project: project, milestone: milestone, state: "closed")
2017-09-10 17:25:29 +05:30
visit project_milestone_path(project, milestone)
2016-06-02 11:05:42 +05:30
expect(find('.alert-success')).to have_content('All issues for this milestone are closed. You may close this milestone now.')
end
end
2016-09-29 09:46:39 +05:30
2018-11-08 19:23:39 +05:30
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-29 09:46:39 +05:30
milestone = create(:milestone, project: project, title: 8.7)
2017-09-10 17:25:29 +05:30
visit new_project_milestone_path(project)
2016-09-29 09:46:39 +05:30
page.within '.milestone-form' do
fill_in "milestone_title", with: milestone.title
end
find('input[name="commit"]').click
2017-09-10 17:25:29 +05:30
expect(find('.alert-danger')).to have_content('already being used for another group or project milestone.')
end
2018-11-08 19:23:39 +05:30
it 'displays validation message when there is a group milestone with same title' do
2017-09-10 17:25:29 +05:30
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-29 09:46:39 +05:30
end
end
2018-03-17 18:26:18 +05:30
2018-11-08 19:23:39 +05:30
describe 'Open a milestone', :js do
it 'shows total issue time spent correctly when no time has been logged' do
2018-03-17 18:26:18 +05:30
milestone = create(:milestone, project: project, title: 8.7)
visit project_milestone_path(project, milestone)
2018-03-27 19:54:05 +05:30
wait_for_requests
page.within('.time-tracking-no-tracking-pane') do
expect(page).to have_content 'No estimate or time spent'
2018-03-17 18:26:18 +05:30
end
end
2018-11-08 19:23:39 +05:30
it 'shows total issue time spent' do
2018-03-17 18:26:18 +05:30
milestone = create(:milestone, project: project, title: 8.7)
issue1 = create(:issue, project: project, milestone: milestone)
issue2 = create(:issue, project: project, milestone: milestone)
issue1.spend_time(duration: 3600, user_id: user.id)
issue1.save!
issue2.spend_time(duration: 7200, user_id: user.id)
issue2.save!
visit project_milestone_path(project, milestone)
2018-03-27 19:54:05 +05:30
wait_for_requests
2018-03-17 18:26:18 +05:30
2018-03-27 19:54:05 +05:30
page.within('.time-tracking-spend-only-pane') do
expect(page).to have_content 'Spent: 3h'
end
2018-03-17 18:26:18 +05:30
end
end
2018-05-09 12:01:36 +05:30
2018-11-08 19:23:39 +05:30
describe 'Deleting a milestone' do
it "The delete milestone button does not show for unauthorized users" do
2018-05-09 12:01:36 +05:30
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-10-15 14:42:47 +05:30
2018-11-08 19:23:39 +05:30
describe 'deprecation popover', :js do
2018-10-15 14:42:47 +05:30
it 'opens deprecation popover' do
milestone = create(:milestone, project: project)
visit group_milestone_path(group, milestone, title: milestone.title)
expect(page).to have_selector('.milestone-deprecation-message')
find('.milestone-deprecation-message .js-popover-link').click
2018-11-08 19:23:39 +05:30
expect(page).to have_selector('.popover')
2018-10-15 14:42:47 +05:30
end
end
2019-07-07 11:18:12 +05:30
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-06-02 11:05:42 +05:30
end