2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-08 15:57:23 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
describe 'Project milestone' do
|
2017-02-08 15:57:23 -05:00
|
|
|
let(:user) { create(:user) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, name: 'test', namespace: user.namespace) }
|
2017-02-08 15:57:23 -05:00
|
|
|
let(:milestone) { create(:milestone, project: project) }
|
|
|
|
|
2019-11-06 10:06:23 -05:00
|
|
|
def toggle_sidebar
|
|
|
|
find('.milestone-sidebar .gutter-toggle').click
|
|
|
|
end
|
|
|
|
|
|
|
|
def sidebar_release_block
|
|
|
|
find('.milestone-sidebar .block.releases')
|
|
|
|
end
|
|
|
|
|
|
|
|
def sidebar_release_block_collapsed_icon
|
|
|
|
find('.milestone-sidebar .block.releases .sidebar-collapsed-icon')
|
|
|
|
end
|
|
|
|
|
2017-02-08 15:57:23 -05:00
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-02-08 15:57:23 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when project has enabled issues' do
|
|
|
|
before do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_milestone_path(project, milestone)
|
2017-02-08 15:57:23 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows issues tab' do
|
|
|
|
within('#content-body') do
|
|
|
|
expect(page).to have_link 'Issues', href: '#tab-issues'
|
2018-05-31 10:23:49 -04:00
|
|
|
expect(page).to have_selector '.nav-links li a.active', count: 1
|
|
|
|
expect(find('.nav-links li a.active')).to have_content 'Issues'
|
2017-02-08 15:57:23 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows issues stats' do
|
2017-03-24 19:27:47 -04:00
|
|
|
expect(find('.milestone-sidebar')).to have_content 'Issues 0'
|
2017-02-08 15:57:23 -05:00
|
|
|
end
|
|
|
|
|
2017-03-24 19:27:47 -04:00
|
|
|
it 'shows link to browse and add issues' do
|
|
|
|
within('.milestone-sidebar') do
|
|
|
|
expect(page).to have_link 'New issue'
|
|
|
|
expect(page).to have_link 'Open: 0'
|
|
|
|
expect(page).to have_link 'Closed: 0'
|
2017-02-08 15:57:23 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when project has disabled issues' do
|
|
|
|
before do
|
2019-11-07 16:06:14 -05:00
|
|
|
create(:issue, project: project, milestone: milestone)
|
2017-02-08 15:57:23 -05:00
|
|
|
project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED)
|
2019-11-07 16:06:14 -05:00
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_milestone_path(project, milestone)
|
2017-02-08 15:57:23 -05:00
|
|
|
end
|
|
|
|
|
2019-11-07 16:06:14 -05:00
|
|
|
it 'does not show any issues under the issues tab' do
|
2017-02-08 15:57:23 -05:00
|
|
|
within('#content-body') do
|
2019-11-07 16:06:14 -05:00
|
|
|
expect(find('.nav-links li a.active')).to have_content 'Issues'
|
|
|
|
expect(page).not_to have_selector '.issuable-row'
|
2017-02-08 15:57:23 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'hides issues stats' do
|
2017-03-24 19:27:47 -04:00
|
|
|
expect(find('.milestone-sidebar')).not_to have_content 'Issues 0'
|
2017-02-08 15:57:23 -05:00
|
|
|
end
|
|
|
|
|
2017-03-24 19:27:47 -04:00
|
|
|
it 'hides new issue button' do
|
|
|
|
within('.milestone-sidebar') do
|
|
|
|
expect(page).not_to have_link 'New issue'
|
2017-02-08 15:57:23 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show an informative message' do
|
|
|
|
expect(page).not_to have_content('Assign some issues to this milestone.')
|
|
|
|
end
|
|
|
|
end
|
2017-04-26 06:02:32 -04:00
|
|
|
|
|
|
|
context 'when project has an issue' do
|
|
|
|
before do
|
|
|
|
create(:issue, project: project, milestone: milestone)
|
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_milestone_path(project, milestone)
|
2017-04-26 06:02:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'the collapsed sidebar' do
|
|
|
|
before do
|
2019-11-06 10:06:23 -05:00
|
|
|
toggle_sidebar
|
2017-04-26 06:02:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the total MR and issue counts' do
|
|
|
|
find('.milestone-sidebar .block', match: :first)
|
|
|
|
|
|
|
|
aggregate_failures 'MR and issue blocks' do
|
2019-11-06 10:06:23 -05:00
|
|
|
expect(find('.milestone-sidebar .block.issues')).to have_content '1'
|
|
|
|
expect(find('.milestone-sidebar .block.merge-requests')).to have_content '0'
|
2017-04-26 06:02:32 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-11-06 10:06:23 -05:00
|
|
|
|
|
|
|
context 'when the milestone is not associated with a release' do
|
|
|
|
before do
|
|
|
|
visit project_milestone_path(project, milestone)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows "None" in the "Releases" section' do
|
|
|
|
expect(sidebar_release_block).to have_content 'Releases None'
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'when the sidebar is collapsed' do
|
|
|
|
before do
|
|
|
|
toggle_sidebar
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows "0" in the "Releases" section' do
|
|
|
|
expect(sidebar_release_block).to have_content '0'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a tooltip that reads "Releases"' do
|
|
|
|
expect(sidebar_release_block_collapsed_icon['title']).to eq 'Releases'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the milestone is associated with one release' do
|
|
|
|
before do
|
|
|
|
create(:release, project: project, name: 'Version 5', milestones: [milestone])
|
|
|
|
|
|
|
|
visit project_milestone_path(project, milestone)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows "Version 5" in the "Release" section' do
|
|
|
|
expect(sidebar_release_block).to have_content 'Release Version 5'
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'when the sidebar is collapsed' do
|
|
|
|
before do
|
|
|
|
toggle_sidebar
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows "1" in the "Releases" section' do
|
|
|
|
expect(sidebar_release_block).to have_content '1'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a tooltip that reads "1 release"' do
|
|
|
|
expect(sidebar_release_block_collapsed_icon['title']).to eq '1 release'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the milestone is associated with multiple releases' do
|
|
|
|
before do
|
|
|
|
(5..10).each do |num|
|
|
|
|
released_at = Time.zone.parse('2019-10-04') + num.months
|
|
|
|
create(:release, project: project, name: "Version #{num}", milestones: [milestone], released_at: released_at)
|
|
|
|
end
|
|
|
|
|
|
|
|
visit project_milestone_path(project, milestone)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows a shortened list of releases in the "Releases" section' do
|
|
|
|
expect(sidebar_release_block).to have_content 'Releases Version 10 • Version 9 • Version 8 • 3 more releases'
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'when the sidebar is collapsed' do
|
|
|
|
before do
|
|
|
|
toggle_sidebar
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows "6" in the "Releases" section' do
|
|
|
|
expect(sidebar_release_block).to have_content '6'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a tooltip that reads "6 releases"' do
|
|
|
|
expect(sidebar_release_block_collapsed_icon['title']).to eq '6 releases'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-02-08 15:57:23 -05:00
|
|
|
end
|