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

Include Budget in Checksum for Work Packages

Klaus Zanders4e27ffa8bc73
diff --git a/lib/api/v3/work_packages/eager_loading/checksum.rb b/lib/api/v3/work_packages/eager_loading/checksum.rb
index b71233de468..98bffa43a61 100644
--- a/lib/api/v3/work_packages/eager_loading/checksum.rb
+++ b/lib/api/v3/work_packages/eager_loading/checksum.rb
@@ -67,7 +67,7 @@ module API
end
def checksum_associations
- %i[status author responsible assigned_to version priority category type]
+ %i[status author responsible assigned_to version priority category type budget]
end
def md5_checksum_table_name(association_name)
diff --git a/spec/lib/api/v3/work_packages/eager_loading/cache_checksum_integration_spec.rb b/spec/lib/api/v3/work_packages/eager_loading/cache_checksum_integration_spec.rb
index db9d70e12cc..483153a3fad 100644
--- a/spec/lib/api/v3/work_packages/eager_loading/cache_checksum_integration_spec.rb
+++ b/spec/lib/api/v3/work_packages/eager_loading/cache_checksum_integration_spec.rb
@@ -27,22 +27,25 @@
#++require 'rspec'
require 'spec_helper'
-require_relative './eager_loading_mock_wrapper'
+require_relative 'eager_loading_mock_wrapper'
RSpec.describe API::V3::WorkPackages::EagerLoading::Checksum do
+ let(:project) { create(:project) }
let(:responsible) { create(:user) }
let(:assignee) { create(:user) }
let(:category) { create(:category) }
let(:version) { create(:version) }
+ let(:budget) { create(:budget, project:) }
let!(:work_package) do
create(:work_package,
+ project:,
responsible:,
assigned_to: assignee,
+ budget:,
version:,
category:)
end
let!(:type) { work_package.type }
- let!(:project) { work_package.project }
describe '.apply' do
let!(:orig_checksum) do
@@ -173,5 +176,19 @@ RSpec.describe API::V3::WorkPackages::EagerLoading::Checksum do
expect(new_checksum)
.not_to eql orig_checksum
end
+
+ it 'produces a different checksum on changes to the budget id' do
+ WorkPackage.where(id: work_package.id).update_all(budget_id: 0)
+
+ expect(new_checksum)
+ .not_to eql orig_checksum
+ end
+
+ it 'produces a different checksum on changes to the budget' do
+ work_package.budget.update_attribute(:updated_at, Time.now + 10.seconds)
+
+ expect(new_checksum)
+ .not_to eql orig_checksum
+ end
end
end