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.
This commit is contained in:
Kabiru Mwenja
2026-04-15 15:32:40 +03:00
parent db88a2da7e
commit 81fbb035cc
2 changed files with 35 additions and 0 deletions
@@ -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 }
@@ -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