Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add global new team planner route

Aaron Contreras96fee51354ac
diff --git a/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb b/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
index 7069358a8b7..17fec45a7fc 100644
--- a/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
+++ b/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
@@ -3,8 +3,8 @@ module ::TeamPlanner
include EnterpriseTrialHelper
include Layout
before_action :find_optional_project
- before_action :authorize, except: %i[overview upsale]
- before_action :authorize_global, only: %i[overview]
+ before_action :authorize, except: %i[overview new upsale]
+ before_action :authorize_global, only: %i[overview new]
before_action :require_ee_token, except: %i[upsale]
before_action :find_plan_view, only: %i[destroy]
@@ -19,6 +19,8 @@ module ::TeamPlanner
render layout: 'global'
end
+ def new; end
+
def show
render layout: 'angular/angular'
end
diff --git a/modules/team_planner/config/routes.rb b/modules/team_planner/config/routes.rb
index 895a85e0eca..4c2ee8e52d7 100644
--- a/modules/team_planner/config/routes.rb
+++ b/modules/team_planner/config/routes.rb
@@ -1,16 +1,27 @@
OpenProject::Application.routes.draw do
- get :team_planners, to: 'team_planner/team_planner#overview'
- get 'team_planners/upsale', to: 'team_planner/team_planner#upsale', as: :upsale_team_planners
+ resources :team_planners,
+ controller: 'team_planner/team_planner',
+ only: %i[] do
+ collection do
+ get '/', to: 'team_planner/team_planner#overview'
+ get '/new', to: 'team_planner/team_planner#new'
+ get '/upsale', to: 'team_planner/team_planner#upsale', as: :upsale
+ end
+ end
scope 'projects/:project_id', as: 'project' do
resources :team_planners,
controller: 'team_planner/team_planner',
only: %i[index destroy],
as: :team_planners do
- get :upsale, to: 'team_planner/team_planner#upsale', on: :collection, as: :upsale
+ collection do
+ get '/upsale', to: 'team_planner/team_planner#upsale', as: :upsale
+ get '/new', to: 'team_planner/team_planner#show', as: :new
+ end
- get '/new' => 'team_planner/team_planner#show', on: :collection, as: 'new'
- get '(/*state)' => 'team_planner/team_planner#show', on: :member, as: ''
+ member do
+ get '(/*state)' => 'team_planner/team_planner#show', as: ''
+ end
end
end
end
diff --git a/modules/team_planner/spec/routing/team_planner_routing_spec.rb b/modules/team_planner/spec/routing/team_planner_routing_spec.rb
index ab150a5313e..e08b4faee99 100644
--- a/modules/team_planner/spec/routing/team_planner_routing_spec.rb
+++ b/modules/team_planner/spec/routing/team_planner_routing_spec.rb
@@ -41,10 +41,20 @@ RSpec.describe 'Team planner routing' do
.to(controller: 'team_planner/team_planner', action: :show, project_id: 'foobar', id: '1234')
end
- it 'routes to team_planner#new' do
- expect(subject)
- .to route(:get, '/projects/foobar/team_planners/new')
- .to(controller: 'team_planner/team_planner', action: :show, project_id: 'foobar')
+ context 'with :project_id' do
+ it 'routes to team_planner#new' do
+ expect(subject)
+ .to route(:get, '/projects/foobar/team_planners/new')
+ .to(controller: 'team_planner/team_planner', action: :show, project_id: 'foobar')
+ end
+ end
+
+ context 'without :project_id' do
+ it 'routes to team_planner#new' do
+ expect(subject)
+ .to route(:get, '/team_planners/new')
+ .to(controller: 'team_planner/team_planner', action: :new)
+ end
end
it 'routes to team_planner#show with state' do