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

renamed ical action and cleaned up routes as proposed by @ulferts

Jonas Jabariffdff49ebb37
diff --git a/modules/calendar/app/controllers/calendar/ical_controller.rb b/modules/calendar/app/controllers/calendar/ical_controller.rb
index c3357458d6b..de8eea05995 100644
--- a/modules/calendar/app/controllers/calendar/ical_controller.rb
+++ b/modules/calendar/app/controllers/calendar/ical_controller.rb
@@ -28,7 +28,7 @@
module ::Calendar
class IcalController < ApplicationController
- def ical
+ def show
begin
call = ::Calendar::IcalResponseService.new.call(
ical_token: params[:ical_token],
diff --git a/modules/calendar/config/routes.rb b/modules/calendar/config/routes.rb
index df7feeff726..17c34c53172 100644
--- a/modules/calendar/config/routes.rb
+++ b/modules/calendar/config/routes.rb
@@ -6,8 +6,7 @@ OpenProject::Application.routes.draw do
as: :calendars do
get '/new' => 'calendar/calendars#show', on: :collection, as: 'new'
# TODO: discuss if other controller should be used
- get '/ical' => 'calendar/ical#ical', on: :member, as: 'ical'
- match '/ical' => 'calendar/ical#ical', :via => :propfind
+ get '/ical' => 'calendar/ical#show', on: :member, as: 'ical'
get '(/*state)' => 'calendar/calendars#show', on: :member, as: ''
end
end
diff --git a/modules/calendar/spec/controllers/ical_controller_spec.rb b/modules/calendar/spec/controllers/ical_controller_spec.rb
index fc76fda8d93..cf949facad7 100644
--- a/modules/calendar/spec/controllers/ical_controller_spec.rb
+++ b/modules/calendar/spec/controllers/ical_controller_spec.rb
@@ -47,8 +47,8 @@ describe Calendar::IcalController do
# the ical urls are intended to be used without a logged in user from a calendar client app
# before { login_as(user) }
- describe '#ical' do
- shared_examples_for 'ical#ical' do |expected|
+ describe '#show' do
+ shared_examples_for 'ical#show' do |expected|
subject { response }
if expected == :success
@@ -61,43 +61,43 @@ describe Calendar::IcalController do
context 'with valid params' do
before do
- get :ical, params: {
+ get :show, params: {
project_id: project.id,
id: query.id,
ical_token: valid_ical_token_value
}
end
- it_behaves_like 'ical#ical', :success
+ it_behaves_like 'ical#show', :success
end
context 'with invalid token' do
before do
- get :ical, params: {
+ get :show, params: {
project_id: project.id,
id: query.id,
ical_token: SecureRandom.hex
}
end
- it_behaves_like 'ical#ical', :failure
+ it_behaves_like 'ical#show', :failure
end
context 'with invalid query' do
before do
- get :ical, params: {
+ get :show, params: {
project_id: project.id,
id: SecureRandom.hex,
ical_token: valid_ical_token_value
}
end
- it_behaves_like 'ical#ical', :failure
+ it_behaves_like 'ical#show', :failure
end
context 'with invalid project' do
before do
- get :ical, params: {
+ get :show, params: {
project_id: SecureRandom.hex,
id: query.id,
ical_token: valid_ical_token_value
@@ -106,7 +106,7 @@ describe Calendar::IcalController do
# TODO: the project id is actually irrelevant - the query id is enough
# should the project id still be used in the ical url anyways?
- it_behaves_like 'ical#ical', :success
+ it_behaves_like 'ical#show', :success
end
end
end
diff --git a/modules/calendar/spec/routing/ical_routing_spec.rb b/modules/calendar/spec/routing/ical_routing_spec.rb
index 0e889759367..6d3bbcd2514 100644
--- a/modules/calendar/spec/routing/ical_routing_spec.rb
+++ b/modules/calendar/spec/routing/ical_routing_spec.rb
@@ -31,7 +31,7 @@ require 'spec_helper'
describe Calendar::IcalController do
it do
expect(get('/projects/1/calendars/2/ical')).to route_to(controller: 'calendar/ical',
- action: 'ical',
+ action: 'show',
id: '2',
project_id: '1')
end