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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
use advisory lock in AddWorkPackageNoteService
Ivan Kuchin7d892335b617
diff --git a/app/services/add_work_package_note_service.rb b/app/services/add_work_package_note_service.rbindex d0bf6ff79b6..69bb8054f41 100644--- a/app/services/add_work_package_note_service.rb+++ b/app/services/add_work_package_note_service.rb@@ -32,6 +32,8 @@class AddWorkPackageNoteServiceinclude Contracted+ include Shared::ServiceContext+attr_accessor :user, :work_packagedef initialize(user:, work_package:)@@ -41,7 +43,7 @@ class AddWorkPackageNoteServiceenddef call(notes, send_notifications: nil)- Journal::NotificationConfiguration.with send_notifications do+ in_context(work_package, send_notifications:) dowork_package.add_journal(user:, notes:)success, errors = validate_and_yield(work_package, user) dodiff --git a/spec/services/add_work_package_note_service_spec.rb b/spec/services/add_work_package_note_service_spec.rbindex 7bc8d81788e..ed6156c640b 100644--- a/spec/services/add_work_package_note_service_spec.rb+++ b/spec/services/add_work_package_note_service_spec.rb@@ -60,11 +60,6 @@ RSpec.describe AddWorkPackageNoteService, type: :model dolet(:send_notifications) { false }before do- expect(Journal::NotificationConfiguration)- .to receive(:with)- .with(send_notifications)- .and_yield-allow(instance).to receive(:contract_class).and_return(mock_contract)allow(work_package).to receive(:save_journals).and_return trueend@@ -81,6 +76,30 @@ RSpec.describe AddWorkPackageNoteService, type: :model dosubjectend+ it "creates an advisory lock" do+ allow(OpenProject::Mutex)+ .to receive(:with_advisory_lock_transaction)+ .with(work_package)+ .and_call_original++ subject++ expect(OpenProject::Mutex)+ .to have_received(:with_advisory_lock_transaction)+ end++ it "sends notifications" do+ allow(Journal::NotificationConfiguration)+ .to receive(:with)+ .with(send_notifications)+ .and_yield++ subject++ expect(Journal::NotificationConfiguration)+ .to have_received(:with)+ end+it "has no errors" doexpect(subject.errors).to be_emptyend