From 0acda9d84bdfcebfa96547c2129bae0b23c2c505 Mon Sep 17 00:00:00 2001 From: Kabiru Mwenja Date: Wed, 29 Apr 2026 12:02:24 +0300 Subject: [PATCH] Cover historical reservation under :semantic_conversion context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses Copilot review on PR 22982. The previous spec covered historical reservation in the two mode contexts but lost the case where another project's FriendlyId slug history blocks a semantic identifier when the global mode is classic — the exact scenario that drives the converter service's :semantic_conversion path. --- spec/validators/projects/identifier_validator_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/validators/projects/identifier_validator_spec.rb b/spec/validators/projects/identifier_validator_spec.rb index 28d641ce744..fe868dd3078 100644 --- a/spec/validators/projects/identifier_validator_spec.rb +++ b/spec/validators/projects/identifier_validator_spec.rb @@ -208,5 +208,14 @@ RSpec.describe Projects::IdentifierValidator do project.save!(context: :semantic_conversion) expect(project.reload.identifier).to eq("PROJ") end + + it "rejects a semantic identifier reserved by another project's slug history" do + other = create(:project, identifier: "other-id") + FriendlyId::Slug.create!(sluggable: other, slug: "PROJ") + + project.identifier = "PROJ" + expect(project.valid?(:semantic_conversion)).to be(false) + expect(project.errors[:identifier]).to include(I18n.t("activerecord.errors.messages.taken")) + end end end