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

Fix test broken by rubocop --autocorrect in 8fa8584538

Christophe Bliard50558549cea8
diff --git a/modules/github_integration/lib/open_project/github_integration/hook_handler.rb b/modules/github_integration/lib/open_project/github_integration/hook_handler.rb
index 13c604b5aee..4a70fbfd731 100644
--- a/modules/github_integration/lib/open_project/github_integration/hook_handler.rb
+++ b/modules/github_integration/lib/open_project/github_integration/hook_handler.rb
@@ -55,7 +55,8 @@ module OpenProject::GithubIntegration
'github_event' => event_type,
'github_delivery' => event_delivery)
- OpenProject::Notifications.send(:"github.#{event_type}", payload)
+ event_name = "github.#{event_type}"
+ OpenProject::Notifications.send(event_name, payload)
200
end
diff --git a/modules/storages/spec/factories/storage_file_info_factory.rb b/modules/storages/spec/factories/storage_file_info_factory.rb
index fee2918c3eb..969ad8e201d 100644
--- a/modules/storages/spec/factories/storage_file_info_factory.rb
+++ b/modules/storages/spec/factories/storage_file_info_factory.rb
@@ -30,6 +30,7 @@ FactoryBot.define do
factory :storage_file_info, class: '::Storages::StorageFileInfo' do
status { "OK" }
status_code { 200 }
+ sequence(:id) { |n| "20000#{n}" } # rubocop:disable FactoryBot/IdSequence
sequence(:name) { |n| "file_name_#{n}.txt" }
last_modified_at { Time.zone.now }
created_at { Time.zone.now }
diff --git a/spec/features/projects/work_package_type_mgmt_spec.rb b/spec/features/projects/work_package_type_mgmt_spec.rb
index 4d0296e9e32..82c7d8cae34 100644
--- a/spec/features/projects/work_package_type_mgmt_spec.rb
+++ b/spec/features/projects/work_package_type_mgmt_spec.rb
@@ -28,7 +28,7 @@
require 'spec_helper'
-RSpec.describe 'Projects', :js, :with_cuprite, 'work package type mgmt' do
+RSpec.describe 'Projects', 'work package type mgmt', :js, :with_cuprite do # rubocop:disable RSpec/SortMetadata
current_user { create(:user, member_with_permissions: { project => %i[edit_project manage_types] }) }
let(:phase_type) { create(:type, name: 'Phase', is_default: true) }
diff --git a/spec/lib/open_project/notifications_spec.rb b/spec/lib/open_project/notifications_spec.rb
index a2429e61cd7..db787549087 100644
--- a/spec/lib/open_project/notifications_spec.rb
+++ b/spec/lib/open_project/notifications_spec.rb
@@ -29,30 +29,34 @@
require 'spec_helper'
RSpec.describe OpenProject::Notifications do
- let(:probe) { lambda { |*_args| } }
- let(:payload) { { 'test' => 'payload' } }
-
describe '.send' do
+ let(:probe) { lambda { |*_args| } }
+ let(:payload) { { 'test' => 'payload' } }
+
before do
# We can't clean this up, so we need to use a unique name
- OpenProject::Notifications.subscribe('notifications_spec_send', &probe)
-
- expect(probe).to receive(:call) do |payload|
- # Don't check for object identity for the payload as it might be
- # marshalled and unmarshalled before being delivered in the future.
- expect(payload).to eql(payload)
+ described_class.subscribe('notifications_spec_send') do |*args, **kwargs|
+ probe.call(*args, **kwargs)
end
+
+ allow(probe).to receive(:call)
end
it 'delivers a notification' do
- OpenProject::Notifications.send(:notifications_spec_send, payload)
+ described_class.send(:notifications_spec_send, payload)
+
+ expect(probe).to have_received(:call) do |call_payload|
+ # Don't check for object identity for the payload as it might be
+ # marshalled and unmarshalled before being delivered in the future.
+ expect(call_payload).to eql(payload)
+ end
end
end
describe '.subscribe' do
it 'throws an error when no callback is given' do
expect do
- OpenProject::Notifications.subscribe('notifications_spec_send')
+ described_class.subscribe('notifications_spec_send')
end.to raise_error ArgumentError, /provide a block as a callback/
end
@@ -61,21 +65,21 @@ RSpec.describe OpenProject::Notifications do
let(:as) { [] }
let(:bs) { [] }
- def example_with(clear:)
- OpenProject::Notifications.subscribe(key) do |out|
+ def example_with(clear_subscriptions:)
+ described_class.subscribe(key) do |out|
as << out
end
- OpenProject::Notifications.send(key, 1)
+ described_class.send(key, 1)
- OpenProject::Notifications.subscribe(key, clear_subscriptions: clear) do |out|
+ described_class.subscribe(key, clear_subscriptions:) do |out|
bs << out
end
- OpenProject::Notifications.send(key, 2)
+ described_class.send(key, 2)
end
- context 'true' do
+ context 'when true' do
before do
- example_with clear: true
+ example_with clear_subscriptions: true
end
it 'clears previous subscriptions' do
@@ -84,9 +88,9 @@ RSpec.describe OpenProject::Notifications do
end
end
- context 'false' do
+ context 'when false' do
before do
- example_with clear: false
+ example_with clear_subscriptions: false
end
it 'notifies both subscriptions' do