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

baseline api: don't mock the eager-loading wrapper

Sebastian Fiedlschusterc4bb7096291c
diff --git a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
index e6a1d554ae9..95a77afc2f6 100644
--- a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
@@ -1303,7 +1303,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
context 'when passing timestamps' do
let(:timestamps) { [Timestamp.new(baseline_time), Timestamp.now] }
- let(:baseline_time) { "2022-01-01".to_time }
+ let(:baseline_time) { Time.zone.parse("2022-01-01") }
let(:work_pacakges) { WorkPackage.where(id: work_package.id) }
let(:work_package) do
new_work_package = create(:work_package, subject: "The current work package")
@@ -1332,6 +1332,14 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
end
before do
+ # Usually the eager loading wrapper is mocked
+ # in spec/support/api/v3/work_packages/work_package_representer_eager_loading.rb.
+ # However, I feel more comfortable if we test the real thing here.
+ #
+ allow(::API::V3::WorkPackages::WorkPackageEagerLoadingWrapper)
+ .to receive(:wrap_one)
+ .and_call_original
+
WorkPackage.destroy_all
work_package
Journal.destroy_all
diff --git a/spec/support/api/v3/work_packages/work_package_representer_eager_loading.rb b/spec/support/api/v3/work_packages/work_package_representer_eager_loading.rb
index f497076ef69..af43b97956d 100644
--- a/spec/support/api/v3/work_packages/work_package_representer_eager_loading.rb
+++ b/spec/support/api/v3/work_packages/work_package_representer_eager_loading.rb
@@ -34,21 +34,6 @@ shared_context 'eager loaded work package representer' do
.to receive(:cache_checksum)
.and_return(srand)
- allow(work_package)
- .to receive(:baseline_attributes)
- .and_return({ subject: "The original work package" })
-
- allow(work_package)
- .to receive(:attributes_by_timestamp)
- .and_return({
- "2022-01-01T00:00:00+00:00" => {subject: "The original work package"},
- "PT0S" => {subject: "The current work package"}
- })
-
- allow(work_package)
- .to receive(:baseline_timestamp)
- .and_return(Timestamp.parse("2022-01-01T00:00:00+00:00"))
-
work_package
end
end