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 service call for user sync service

Oliver Günther97fb4243e4d5
diff --git a/app/services/ldap/base_service.rb b/app/services/ldap/base_service.rb
index 8be57256190..4539f5afdc3 100644
--- a/app/services/ldap/base_service.rb
+++ b/app/services/ldap/base_service.rb
@@ -8,7 +8,7 @@ module Ldap
def call
User.system.run_given do
- OpenProject::Mutex.with_advisory_lock_transaction(ldap, 'import_users') do
+ OpenProject::Mutex.with_advisory_lock_transaction(ldap, self.class.name) do
perform
end
end
diff --git a/app/services/ldap/synchronize_users_service.rb b/app/services/ldap/synchronize_users_service.rb
index c3e2e6280a8..2e9902f6b39 100644
--- a/app/services/ldap/synchronize_users_service.rb
+++ b/app/services/ldap/synchronize_users_service.rb
@@ -7,18 +7,9 @@ module Ldap
@logins = logins
end
- def call
- Rails.logger.debug { "Start LDAP user synchronization for #{ldap.name}." }
- User.system.run_given do
- OpenProject::Mutex.with_advisory_lock_transaction(ldap, 'synchronize_users') do
- synchronize!
- end
- end
- end
-
private
- def synchronize!
+ def perform
ldap_con = new_ldap_connection
applicable_users.find_each do |user|
diff --git a/app/workers/ldap/synchronization_job.rb b/app/workers/ldap/synchronization_job.rb
index 776967bf538..2ca0120a676 100644
--- a/app/workers/ldap/synchronization_job.rb
+++ b/app/workers/ldap/synchronization_job.rb
@@ -42,7 +42,7 @@ module Ldap
::LdapAuthSource.find_each do |ldap|
Rails.logger.info { "[LDAP groups] Synchronizing users for LDAP connection #{ldap.name}" }
- ::Ldap::SynchronizeUsersService.new(ldap).perform
+ ::Ldap::SynchronizeUsersService.new(ldap).call
end
end
end
diff --git a/spec/workers/ldap/synchronization_job_spec.rb b/spec/workers/ldap/synchronization_job_spec.rb
index 12a9ceb62e5..299542e6a85 100644
--- a/spec/workers/ldap/synchronization_job_spec.rb
+++ b/spec/workers/ldap/synchronization_job_spec.rb
@@ -36,14 +36,14 @@ describe Ldap::SynchronizationJob, type: :model do
before do
allow(::Ldap::SynchronizeUsersService).to receive(:new).and_return(service)
- allow(service).to receive(:perform)
+ allow(service).to receive(:call)
job.perform
end
context "with user synchronization enabled (default)" do
it "runs the sync" do
- expect(service).to have_received(:perform)
+ expect(service).to have_received(:call)
end
end
@@ -51,7 +51,7 @@ describe Ldap::SynchronizationJob, type: :model do
'ldap_users_disable_sync_job' => true
} do
it "does not run the sync" do
- expect(service).not_to have_received(:perform)
+ expect(service).not_to have_received(:call)
end
end
end