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

linting

ulferts9acf523f2f6d
diff --git a/modules/webhooks/app/controllers/webhooks/incoming/hooks_controller.rb b/modules/webhooks/app/controllers/webhooks/incoming/hooks_controller.rb
index 65191c2ea92..ee58a5139c8 100644
--- a/modules/webhooks/app/controllers/webhooks/incoming/hooks_controller.rb
+++ b/modules/webhooks/app/controllers/webhooks/incoming/hooks_controller.rb
@@ -37,7 +37,7 @@ module Webhooks
end
def handle_hook
- hook = OpenProject::Webhooks.find(params.require 'hook_name')
+ hook = OpenProject::Webhooks.find(params.require('hook_name'))
if hook
code = hook.handle(request, params, find_current_user)
diff --git a/modules/webhooks/lib/open_project/webhooks.rb b/modules/webhooks/lib/open_project/webhooks.rb
index 2bc5caf1711..63c4f5bd66d 100644
--- a/modules/webhooks/lib/open_project/webhooks.rb
+++ b/modules/webhooks/lib/open_project/webhooks.rb
@@ -36,6 +36,7 @@ module OpenProject
# Returns the newly created hook
def self.register_hook(name, &callback)
raise "A hook named '#{name}' is already registered!" if find(name)
+
Rails.logger.warn "hook registered"
hook = Hook.new(name, &callback)
@@registered_hooks << hook
@@ -47,11 +48,12 @@ module OpenProject
def self.unregister_hook(name)
hook = find(name)
raise "A hook named '#{name}' was not registered!" unless find(name)
+
@@registered_hooks.delete hook
end
def self.find(name)
- @@registered_hooks.find {|h| h.name == name}
+ @@registered_hooks.find { |h| h.name == name }
end
end
end
diff --git a/modules/webhooks/lib/open_project/webhooks/event_resources/base.rb b/modules/webhooks/lib/open_project/webhooks/event_resources/base.rb
index 7a2abfcb8c6..1e51d7bc108 100644
--- a/modules/webhooks/lib/open_project/webhooks/event_resources/base.rb
+++ b/modules/webhooks/lib/open_project/webhooks/event_resources/base.rb
@@ -1,19 +1,16 @@
module OpenProject::Webhooks::EventResources
class Base
class << self
-
##
# Subscribe for events on this resource schedule the respective
# webhooks, if any.
def subscribe!
notification_names.each do |key|
OpenProject::Notifications.subscribe(key) do |payload|
- begin
- Rails.logger.debug { "[Webhooks Plugin] Handling notification for '#{key}'." }
- handle_notification(payload, key)
- rescue => e
- Rails.logger.error { "[Webhooks Plugin] Failed notification handling for '#{key}': #{e}" }
- end
+ Rails.logger.debug { "[Webhooks Plugin] Handling notification for '#{key}'." }
+ handle_notification(payload, key)
+ rescue StandardError => e
+ Rails.logger.error { "[Webhooks Plugin] Failed notification handling for '#{key}': #{e}" }
end
end
end
@@ -36,7 +33,6 @@ module OpenProject::Webhooks::EventResources
"#{prefix_key}:#{action}"
end
-
def available_actions
raise NotImplementedError
end
diff --git a/spec/models/journal_notification_mailer_spec.rb b/spec/models/journal_notification_mailer_spec.rb
index e604306f2a1..6154e4c0ff8 100644
--- a/spec/models/journal_notification_mailer_spec.rb
+++ b/spec/models/journal_notification_mailer_spec.rb
@@ -35,12 +35,12 @@ describe JournalNotificationMailer do
mail_notification: 'all',
member_in_project: project)
end
- let(:work_package) {
+ let(:work_package) do
FactoryBot.create(:work_package,
project: project,
author: user,
type: project.types.first)
- }
+ end
let(:journal) { work_package.journals.last }
let(:send_notification) { true }
let(:notifications) { [] }
@@ -81,12 +81,12 @@ describe JournalNotificationMailer do
context 'insufficient work package changes' do
let(:journal) { another_work_package.journals.last }
- let(:another_work_package) {
+ let(:another_work_package) do
FactoryBot.create(:work_package,
- project: project,
- author: user,
- type: project.types.first)
- }
+ project: project,
+ author: user,
+ type: project.types.first)
+ end
before do
another_work_package.add_journal(user)
another_work_package.description = 'needs more changes'