Commit 4a95f807 authored by Alessio Caiazza's avatar Alessio Caiazza

Merge branch '222763-add-project-iteration-page' into 'master'

Add iteration page within projects

See merge request gitlab-org/gitlab!37715
parents 5fa85f3e e315bf2e
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
%span %span
= _('Milestones') = _('Milestones')
= render_if_exists 'layouts/nav/sidebar/iterations_link' = render_if_exists 'layouts/nav/sidebar/group_iterations_link'
- if group_sidebar_link?(:merge_requests) - if group_sidebar_link?(:merge_requests)
= nav_link(path: 'groups#merge_requests') do = nav_link(path: 'groups#merge_requests') do
......
...@@ -121,6 +121,8 @@ ...@@ -121,6 +121,8 @@
%span %span
= _('Milestones') = _('Milestones')
= render_if_exists 'layouts/nav/sidebar/project_iterations_link'
- if project_nav_tab?(:external_issue_tracker) - if project_nav_tab?(:external_issue_tracker)
- issue_tracker = @project.external_issue_tracker - issue_tracker = @project.external_issue_tracker
- if issue_tracker.is_a?(JiraService) && project_jira_issues_integration? - if issue_tracker.is_a?(JiraService) && project_jira_issues_integration?
......
# frozen_string_literal: true
class Projects::IterationsController < Projects::ApplicationController
before_action :check_iterations_available!
before_action :authorize_show_iteration!, only: [:index]
def index; end
private
def check_iterations_available!
render_404 unless project.feature_available?(:iterations)
end
def authorize_show_iteration!
render_404 unless can?(current_user, :read_iteration, project)
end
end
- return unless Feature.enabled?(:project_iterations, @project.group, default_enabled: false)
- return unless @project.feature_available?(:iterations)
- return unless can?(current_user, :read_iteration, @project)
= nav_link(controller: :iterations) do
= link_to project_iterations_path(@project), title: _('Iterations') do
%span
= _('Iterations')
...@@ -112,6 +112,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -112,6 +112,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :issues, only: [:index] resources :issues, only: [:index]
end end
end end
resources :iterations, only: [:index]
end end
# End of the /-/ scope. # End of the /-/ scope.
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::IterationsController do
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
context 'index' do
context 'when iterations license is not available' do
before do
stub_licensed_features(iterations: false)
sign_in(user)
get :index, params: { namespace_id: project.namespace, project_id: project }
end
it 'renders 404' do
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when user is unauthorized' do
before do
sign_in(user)
get :index, params: { namespace_id: project.namespace, project_id: project }
end
it 'renders 404' do
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when user is authorized' do
before do
project.add_developer(user)
sign_in(user)
get :index, params: { namespace_id: project.namespace, project_id: project }
end
it 'renders index successfully' do
expect(response).to be_successful
end
end
end
end
...@@ -11,6 +11,8 @@ RSpec.describe 'Project navbar' do ...@@ -11,6 +11,8 @@ RSpec.describe 'Project navbar' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
before do before do
stub_feature_flags(project_iterations: false)
insert_package_nav(_('Operations')) insert_package_nav(_('Operations'))
project.add_maintainer(user) project.add_maintainer(user)
...@@ -97,4 +99,21 @@ RSpec.describe 'Project navbar' do ...@@ -97,4 +99,21 @@ RSpec.describe 'Project navbar' do
it_behaves_like 'verified navigation bar' it_behaves_like 'verified navigation bar'
end end
context 'when iterations is available' do
before do
stub_licensed_features(iterations: true)
stub_feature_flags(project_iterations: true)
insert_after_sub_nav_item(
_('Milestones'),
within: _('Issues'),
new_sub_nav_item_name: _('Iterations')
)
visit project_path(project)
end
it_behaves_like 'verified navigation bar'
end
end end
...@@ -245,4 +245,102 @@ RSpec.describe 'layouts/nav/sidebar/_project' do ...@@ -245,4 +245,102 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
expect(rendered).to have_link('Operations', href: project_settings_operations_path(project)) expect(rendered).to have_link('Operations', href: project_settings_operations_path(project))
end end
end end
describe 'iterations link' do
context 'with authorized user' do
let_it_be(:current_user) { create(:user) }
before do
project.add_guest(current_user)
allow(view).to receive(:current_user).and_return(current_user)
end
context 'with iterations licensed feature available' do
before do
stub_licensed_features(iterations: true)
end
context 'with project_iterations feature flag enabled' do
before do
stub_feature_flags(project_iterations: true)
end
it 'is visible' do
render
expect(rendered).to have_text 'Iterations'
end
end
context 'with project_iterations feature flag disabled' do
before do
stub_feature_flags(project_iterations: false)
end
it 'is not visible' do
render
expect(rendered).not_to have_text 'Iterations'
end
end
end
context 'with iterations licensed feature disabled' do
before do
stub_licensed_features(iterations: false)
end
it 'is not visible' do
render
expect(rendered).not_to have_text 'Iterations'
end
end
end
context 'with unauthorized user' do
context 'with iterations licensed feature available' do
before do
stub_licensed_features(iterations: true)
end
context 'with project_iterations feature flag enabled' do
before do
stub_feature_flags(project_iterations: true)
end
it 'is not visible' do
render
expect(rendered).not_to have_text 'Iterations'
end
end
context 'with project_iterations feature flag disabled' do
before do
stub_feature_flags(project_iterations: false)
end
it 'is not visible' do
render
expect(rendered).not_to have_text 'Iterations'
end
end
end
context 'with iterations licensed feature disabled' do
before do
stub_licensed_features(iterations: false)
end
it 'is not visible' do
render
expect(rendered).not_to have_text 'Iterations'
end
end
end
end
end end
...@@ -12,6 +12,8 @@ RSpec.describe 'Project navbar' do ...@@ -12,6 +12,8 @@ RSpec.describe 'Project navbar' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
before do before do
stub_feature_flags(project_iterations: false)
insert_package_nav(_('Operations')) insert_package_nav(_('Operations'))
project.add_maintainer(user) project.add_maintainer(user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment