From 81fbb035ccdb69c22095c8db145e5a05ce764cdc Mon Sep 17 00:00:00 2001 From: Kabiru Mwenja Date: Wed, 15 Apr 2026 15:32:40 +0300 Subject: [PATCH] Add integration tests for semantic identifier resolution Verify that semantic work package identifiers (e.g. "TESTPROJ-1") are resolved end-to-end through the controller and API layers, using with_settings/with_flag helpers instead of allow mocks. --- .../work_packages_controller_spec.rb | 15 ++++++++++++++ .../v3/work_packages/show_resource_spec.rb | 20 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/spec/controllers/work_packages_controller_spec.rb b/spec/controllers/work_packages_controller_spec.rb index a6671b0e96e..53320ea4f6d 100644 --- a/spec/controllers/work_packages_controller_spec.rb +++ b/spec/controllers/work_packages_controller_spec.rb @@ -265,6 +265,21 @@ RSpec.describe WorkPackagesController do end end + describe "show.html with semantic identifier", + with_flag: { semantic_work_package_ids: true }, + with_settings: { work_packages_identifier: "semantic" } do + let(:project) { create(:project, identifier: "TESTPROJ") } + let(:call_action) { get("show", params: { id: work_package.display_id.to_s }) } + + requires_permission_in_project do + it "resolves the semantic identifier and redirects to the full url" do + call_action + + expect(response).to redirect_to("/projects/TESTPROJ/work_packages/#{work_package.display_id}/activity") + end + end + end + describe "show.pdf" do let(:call_action) { get("show", params: { format: "pdf", id: work_package.id.to_s }) } let(:exporter) { WorkPackage::PDFExport::WorkPackageToPdf } diff --git a/spec/requests/api/v3/work_packages/show_resource_spec.rb b/spec/requests/api/v3/work_packages/show_resource_spec.rb index 5eba4712539..63105f96f7b 100644 --- a/spec/requests/api/v3/work_packages/show_resource_spec.rb +++ b/spec/requests/api/v3/work_packages/show_resource_spec.rb @@ -217,6 +217,26 @@ RSpec.describe "API v3 Work package resource", it_behaves_like "not found response based on login_required", I18n.t("api_v3.errors.not_found.work_package") end + + context "with a semantic identifier", + with_flag: { semantic_work_package_ids: true }, + with_settings: { work_packages_identifier: "semantic" } do + let(:get_path) { api_v3_paths.work_package work_package.display_id } + + before do + get get_path + end + + it "resolves the semantic identifier and responds with 200" do + expect(last_response).to have_http_status(:ok) + end + + it "returns the correct work package" do + expect(last_response.body) + .to be_json_eql(work_package.id.to_json) + .at_path("id") + end + end end describe "GET /api/v3/work_packages/:id?timestamps=" do