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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add Global `calendars#index` route
Aaron Contreras8608e1429cf9
diff --git a/.rubocop.yml b/.rubocop.ymlindex b93cdc1295a..f53ac4aad3c 100644--- a/.rubocop.yml+++ b/.rubocop.yml@@ -242,6 +242,7 @@ RSpec/ContextWording:- unless- when- with+ - within- withoutStyle/Alias:diff --git a/modules/calendar/app/controllers/calendar/calendars_controller.rb b/modules/calendar/app/controllers/calendar/calendars_controller.rbindex cb0d7df5b8b..934cdd07439 100644--- a/modules/calendar/app/controllers/calendar/calendars_controller.rb+++ b/modules/calendar/app/controllers/calendar/calendars_controller.rb@@ -54,6 +54,15 @@ module ::Calendarprivate+ def find_optional_project+ return unless params[:project_id]++ @project = Project.find(params[:project_id])+ authorize+ rescue ActiveRecord::RecordNotFound+ render_404+ end+def visible_viewsQuery.visible(current_user)diff --git a/modules/calendar/config/routes.rb b/modules/calendar/config/routes.rbindex 7a3fb244028..993b095367b 100644--- a/modules/calendar/config/routes.rb+++ b/modules/calendar/config/routes.rb@@ -9,4 +9,6 @@ OpenProject::Application.routes.draw doget '(/*state)' => 'calendar/calendars#show', on: :member, as: ''endend++ resources :calendars, only: :index, controller: 'calendar/calendars'enddiff --git a/modules/calendar/spec/controllers/calendar_controller_spec.rb b/modules/calendar/spec/controllers/calendar_controller_spec.rbindex 834510f4843..5f76af84c4c 100644--- a/modules/calendar/spec/controllers/calendar_controller_spec.rb+++ b/modules/calendar/spec/controllers/calendar_controller_spec.rb@@ -50,7 +50,7 @@ RSpec.describe Calendar::CalendarsController doendend- before { login_as(user) }+ before { login_as user }describe '#index' doshared_examples_for 'calendar#index' do@@ -61,12 +61,20 @@ RSpec.describe Calendar::CalendarsController doit { is_expected.to render_template('calendar/calendars/index') }end- context 'with project' do+ context 'within a project context' dobefore doget :index, params: { project_id: project.id }endit_behaves_like 'calendar#index'end++ context 'within a global context' do+ before do+ get :index+ end++ it_behaves_like 'calendar#index'+ endendenddiff --git a/modules/calendar/spec/routing/calendar_routing_spec.rb b/modules/calendar/spec/routing/calendar_routing_spec.rbindex 6dff3cf7e3a..3bbd6347ee9 100644--- a/modules/calendar/spec/routing/calendar_routing_spec.rb+++ b/modules/calendar/spec/routing/calendar_routing_spec.rb@@ -29,6 +29,11 @@require 'spec_helper'RSpec.describe Calendar::CalendarsController do+ it do+ expect(get('calendars')).to route_to(controller: 'calendar/calendars',+ action: 'index')+ end+it doexpect(get('/projects/1/calendars')).to route_to(controller: 'calendar/calendars',action: 'index',