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

adapt journal reloading for test env

ulferts9d2bb995387e
diff --git a/app/services/add_work_package_note_service.rb b/app/services/add_work_package_note_service.rb
index a30c3e839e2..76fda70828d 100644
--- a/app/services/add_work_package_note_service.rb
+++ b/app/services/add_work_package_note_service.rb
@@ -48,7 +48,14 @@ class AddWorkPackageNoteService
work_package.save_journals
end
- journal = work_package.journals.last if success
+ if success
+ # In test environment, because of the difference in the way of handling transactions,
+ # the journal needs to be actively loaded without SQL caching in place.
+ journal = Journal.connection.uncached do
+ work_package.journals.last
+ end
+ end
+
ServiceResult.new(success:, result: journal, errors:)
end
end
diff --git a/lib/api/v3/activities/activities_by_work_package_api.rb b/lib/api/v3/activities/activities_by_work_package_api.rb
index 8a2c0a0d9c0..229e166b640 100644
--- a/lib/api/v3/activities/activities_by_work_package_api.rb
+++ b/lib/api/v3/activities/activities_by_work_package_api.rb
@@ -53,16 +53,16 @@ module API
raise ::API::Errors::NotFound.new
end
- result = AddWorkPackageNoteService
+ call = AddWorkPackageNoteService
.new(user: current_user,
work_package: @work_package)
.call(params[:comment][:raw],
send_notifications: !(params.has_key?(:notify) && params[:notify] == 'false'))
- if result.success?
- Activities::ActivityRepresenter.new(work_package.journals.last, current_user:)
+ if call.success?
+ Activities::ActivityRepresenter.new(call.result, current_user:)
else
- fail ::API::Errors::ErrorBase.create_and_merge_errors(result.errors)
+ fail ::API::Errors::ErrorBase.create_and_merge_errors(call.errors)
end
end
end