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

consistent usage of ICal instead of Ical

Jonas Jabari6c2a9ca11bbf
diff --git a/app/models/token/ical.rb b/app/models/token/ical.rb
index 5ca7d5856e7..799862f220f 100644
--- a/app/models/token/ical.rb
+++ b/app/models/token/ical.rb
@@ -29,7 +29,7 @@
module Token
class ICal < HashedToken
# restrict the usage of one ical token to one query (calendar)
- has_one :ical_token_query_assignment, required: true, dependent: :destroy, foreign_key: :ical_token_id
+ has_one :ical_token_query_assignment, required: true, dependent: :destroy, foreign_key: :ical_token_id, class_name: 'ICalTokenQueryAssignment'
accepts_nested_attributes_for :ical_token_query_assignment
has_one :query, through: :ical_token_query_assignment
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
index b49e97941ac..ca15b80b75a 100644
--- a/config/initializers/inflections.rb
+++ b/config/initializers/inflections.rb
@@ -43,4 +43,5 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym "API"
inflect.acronym 'OAuth'
inflect.acronym 'OpenID'
+ inflect.acronym 'ICal'
end
diff --git a/config/initializers/zeitwerk.rb b/config/initializers/zeitwerk.rb
index 20f468c39d9..0e57ddd0e14 100644
--- a/config/initializers/zeitwerk.rb
+++ b/config/initializers/zeitwerk.rb
@@ -20,6 +20,12 @@ OpenProject::Inflector.rule do |basename, abspath|
"#{default_inflect($1, abspath)}API"
when 'api'
'API'
+ when /(.*)_ical_(.*)/i
+ "#{default_inflect($1, abspath)}ICal#{default_inflect($2, abspath)}"
+ when /\Aical_(.*)\z/
+ "ICal#{default_inflect($1, abspath)}"
+ when /\A(.*)_ical\z/
+ "#{default_inflect($1, abspath)}ICal"
when 'ical'
'ICal'
when /\Aar_(.*)\z/
@@ -55,7 +61,8 @@ OpenProject::Inflector.inflection(
'pop3' => 'POP3',
'cors' => 'CORS',
'openid_connect' => 'OpenIDConnect',
- 'pdf_export' => 'PDFExport'
+ 'pdf_export' => 'PDFExport',
+ 'ical' => 'ICal'
)
Rails.autoloaders.each do |autoloader|
diff --git a/lib/api/v3/queries/queries_api.rb b/lib/api/v3/queries/queries_api.rb
index 842b1e75112..6368074df0f 100644
--- a/lib/api/v3/queries/queries_api.rb
+++ b/lib/api/v3/queries/queries_api.rb
@@ -173,7 +173,7 @@ module API
# currently the generated URL points to controller action in calendar module
# correct approach? or should it be implemented as a API here?
- call = ::Calendar::GenerateIcalUrl.new.call(
+ call = ::Calendar::GenerateICalUrl.new.call(
user: current_user,
query_id: @query.id,
project_id: @query.project_id,
diff --git a/modules/calendar/app/controllers/calendar/ical_controller.rb b/modules/calendar/app/controllers/calendar/ical_controller.rb
index 611fb6379a6..745883760c2 100644
--- a/modules/calendar/app/controllers/calendar/ical_controller.rb
+++ b/modules/calendar/app/controllers/calendar/ical_controller.rb
@@ -27,10 +27,10 @@
#++
module ::Calendar
- class IcalController < ApplicationController
+ class ICalController < ApplicationController
def show
begin
- call = ::Calendar::IcalResponseService.new.call(
+ call = ::Calendar::ICalResponseService.new.call(
ical_token_string: params[:ical_token],
query_id: params[:id]
)
diff --git a/modules/calendar/app/models/ical_token_query_assignment.rb b/modules/calendar/app/models/ical_token_query_assignment.rb
index baf168f189f..0fb3b058db9 100644
--- a/modules/calendar/app/models/ical_token_query_assignment.rb
+++ b/modules/calendar/app/models/ical_token_query_assignment.rb
@@ -26,7 +26,8 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-class IcalTokenQueryAssignment < ApplicationRecord
+class ICalTokenQueryAssignment < ApplicationRecord
+ self.table_name = 'ical_token_query_assignments'
# TODO: dependent_destroy from query model? --> already defined on database level
belongs_to :ical_token, class_name: 'Token::ICal'
belongs_to :query
diff --git a/modules/calendar/app/services/calendar/create_ical_service.rb b/modules/calendar/app/services/calendar/create_ical_service.rb
index 7636f883a25..7ba3cb59dee 100644
--- a/modules/calendar/app/services/calendar/create_ical_service.rb
+++ b/modules/calendar/app/services/calendar/create_ical_service.rb
@@ -29,7 +29,7 @@
require 'icalendar'
module Calendar
- class CreateIcalService < ::BaseServices::BaseCallable
+ class CreateICalService < ::BaseServices::BaseCallable
def perform(work_packages:, calendar_name: "OpenProject Calendar")
ical_string = create_ical_string(work_packages, calendar_name)
diff --git a/modules/calendar/app/services/calendar/generate_ical_url.rb b/modules/calendar/app/services/calendar/generate_ical_url.rb
index 1df694c3c37..32ecbbc0fae 100644
--- a/modules/calendar/app/services/calendar/generate_ical_url.rb
+++ b/modules/calendar/app/services/calendar/generate_ical_url.rb
@@ -27,7 +27,7 @@
#++
module Calendar
- class GenerateIcalUrl < ::BaseServices::BaseCallable
+ class GenerateICalUrl < ::BaseServices::BaseCallable
def perform(user:, query_id:, project_id:, token_name:)
begin
diff --git a/modules/calendar/app/services/calendar/ical_response_service.rb b/modules/calendar/app/services/calendar/ical_response_service.rb
index 9bdf1dca9e8..9a9bf086728 100644
--- a/modules/calendar/app/services/calendar/ical_response_service.rb
+++ b/modules/calendar/app/services/calendar/ical_response_service.rb
@@ -27,7 +27,7 @@
#++
module Calendar
- class IcalResponseService < ::BaseServices::BaseCallable
+ class ICalResponseService < ::BaseServices::BaseCallable
ICAL_CACHE_EXPIRES_IN = 0.minutes # cache disabled for now by setting to 0.minute
def perform(ical_token_string:, query_id:)
@@ -67,7 +67,7 @@ module Calendar
end
def resolve_ical_token(ical_token_string)
- call = ::Calendar::ResolveIcalTokenService.new.call(
+ call = ::Calendar::ResolveICalTokenService.new.call(
ical_token_string:
)
ical_token_instance = call.result if call.success?
@@ -95,7 +95,7 @@ module Calendar
end
def create_ical_string(work_packages, calendar_name)
- call = ::Calendar::CreateIcalService.new.call(
+ call = ::Calendar::CreateICalService.new.call(
work_packages:, calendar_name:
)
ical_string = call.result if call.success?
diff --git a/modules/calendar/app/services/calendar/resolve_ical_token_service.rb b/modules/calendar/app/services/calendar/resolve_ical_token_service.rb
index 534c917032f..f54d30b367d 100644
--- a/modules/calendar/app/services/calendar/resolve_ical_token_service.rb
+++ b/modules/calendar/app/services/calendar/resolve_ical_token_service.rb
@@ -27,7 +27,7 @@
#++
module Calendar
- class ResolveIcalTokenService < ::BaseServices::BaseCallable
+ class ResolveICalTokenService < ::BaseServices::BaseCallable
def perform(ical_token_string:)
if ical_token_string.blank?
raise ActiveRecord::RecordNotFound
diff --git a/modules/calendar/db/migrate/20230421154500_ical_token_query_assignment.rb b/modules/calendar/db/migrate/20230421154500_ical_token_query_assignment.rb
index beffd6b5963..35db62e3be9 100644
--- a/modules/calendar/db/migrate/20230421154500_ical_token_query_assignment.rb
+++ b/modules/calendar/db/migrate/20230421154500_ical_token_query_assignment.rb
@@ -1,4 +1,4 @@
-class IcalTokenQueryAssignment < ActiveRecord::Migration[7.0]
+class ICalTokenQueryAssignment < ActiveRecord::Migration[7.0]
def change
create_table :ical_token_query_assignments do |t|
t.references :ical_token, foreign_key: { to_table: :tokens, on_delete: :cascade }
diff --git a/modules/calendar/db/migrate/20230502094813_add_name_to_ical_tokens.rb b/modules/calendar/db/migrate/20230502094813_add_name_to_ical_tokens.rb
index 64ec97557cb..57bb8ff76a3 100644
--- a/modules/calendar/db/migrate/20230502094813_add_name_to_ical_tokens.rb
+++ b/modules/calendar/db/migrate/20230502094813_add_name_to_ical_tokens.rb
@@ -1,4 +1,4 @@
-class AddNameToIcalTokens < ActiveRecord::Migration[7.0]
+class AddNameToICalTokens < ActiveRecord::Migration[7.0]
def change
# Add column with default value to avoid null values for existing records in preview environment
add_column :ical_token_query_assignments, :name, :string, null: false, default: 'Not provided in earlier version'
diff --git a/modules/calendar/spec/controllers/ical_controller_spec.rb b/modules/calendar/spec/controllers/ical_controller_spec.rb
index 294bdb37388..d0bc7d59cd5 100644
--- a/modules/calendar/spec/controllers/ical_controller_spec.rb
+++ b/modules/calendar/spec/controllers/ical_controller_spec.rb
@@ -28,7 +28,7 @@
require 'spec_helper'
-describe Calendar::IcalController do
+describe Calendar::ICalController do
let(:project) { create(:project) }
let(:user) do
create(:user,
diff --git a/modules/calendar/spec/routing/ical_routing_spec.rb b/modules/calendar/spec/routing/ical_routing_spec.rb
index 6d3bbcd2514..5495022f9fe 100644
--- a/modules/calendar/spec/routing/ical_routing_spec.rb
+++ b/modules/calendar/spec/routing/ical_routing_spec.rb
@@ -28,7 +28,7 @@
require 'spec_helper'
-describe Calendar::IcalController do
+describe Calendar::ICalController do
it do
expect(get('/projects/1/calendars/2/ical')).to route_to(controller: 'calendar/ical',
action: 'show',
diff --git a/modules/calendar/spec/services/create_ical_service_spec.rb b/modules/calendar/spec/services/create_ical_service_spec.rb
index e740cf9e620..df976c093af 100644
--- a/modules/calendar/spec/services/create_ical_service_spec.rb
+++ b/modules/calendar/spec/services/create_ical_service_spec.rb
@@ -28,7 +28,7 @@
require 'spec_helper'
-describe Calendar::CreateIcalService, type: :model do
+describe Calendar::CreateICalService, type: :model do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:work_package_with_start_date) do
diff --git a/modules/calendar/spec/services/resolve_ical_token_service_spec.rb b/modules/calendar/spec/services/resolve_ical_token_service_spec.rb
index aa00faa707a..03c863d93bd 100644
--- a/modules/calendar/spec/services/resolve_ical_token_service_spec.rb
+++ b/modules/calendar/spec/services/resolve_ical_token_service_spec.rb
@@ -28,7 +28,7 @@
require 'spec_helper'
-describe Calendar::ResolveIcalTokenService, type: :model do
+describe Calendar::ResolveICalTokenService, type: :model do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:query) { create(:query, project:) }