Skip to content

Commit 839cea0

Browse files
committed
Fix error_too_long translation and tighten MCP search spec assertions
Corrected error_too_long message from "fewer than 5" to "10 or fewer" to match SEMANTIC_IDENTIFIER_MAX_LENGTH. Replaced be_present with specific assertions on item count and identifier in MCP search_{projects,programs,portfolios} specs to ensure the correct resource is returned, not just any resource.
1 parent d14c8e2 commit 839cea0

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

config/locales/en.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ en:
410410
label_autofixed_suggestion: Future identifier
411411
label_example_work_package_id: Example work package ID
412412
autofix_preview:
413-
error_too_long: Has to be fewer than 5 characters
413+
error_too_long: Has to be 10 characters or fewer
414414
error_numerical: Cannot be purely numerical
415415
error_starts_with_number: Cannot start with a number
416416
error_special_characters: Special characters not allowed

spec/requests/mcp/mcp_tools/search_portfolios_spec.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,22 @@
8484
context "when passing an exact identifier" do
8585
let(:call_args) { { identifier: "abc" } }
8686

87-
it "finds the portfolio" do
87+
it "finds only the matching portfolio" do
8888
subject
89-
expect(parsed_results.dig("structuredContent", "items")).to be_present
89+
items = parsed_results.dig("structuredContent", "items")
90+
expect(items.size).to eq(1)
91+
expect(items.first).to include("identifier" => "abc")
9092
end
9193
end
9294

9395
context "when passing a case-variant identifier" do
9496
let(:call_args) { { identifier: "Abc" } }
9597

96-
it "finds the portfolio (case-insensitive)" do
98+
it "finds only the matching portfolio (case-insensitive)" do
9799
subject
98-
expect(parsed_results.dig("structuredContent", "items")).to be_present
100+
items = parsed_results.dig("structuredContent", "items")
101+
expect(items.size).to eq(1)
102+
expect(items.first).to include("identifier" => "abc")
99103
end
100104
end
101105

spec/requests/mcp/mcp_tools/search_programs_spec.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,22 @@
8484
context "when passing an exact identifier" do
8585
let(:call_args) { { identifier: "abc" } }
8686

87-
it "finds the program" do
87+
it "finds only the matching program" do
8888
subject
89-
expect(parsed_results.dig("structuredContent", "items")).to be_present
89+
items = parsed_results.dig("structuredContent", "items")
90+
expect(items.size).to eq(1)
91+
expect(items.first).to include("identifier" => "abc")
9092
end
9193
end
9294

9395
context "when passing a case-variant identifier" do
9496
let(:call_args) { { identifier: "Abc" } }
9597

96-
it "finds the program (case-insensitive)" do
98+
it "finds only the matching program (case-insensitive)" do
9799
subject
98-
expect(parsed_results.dig("structuredContent", "items")).to be_present
100+
items = parsed_results.dig("structuredContent", "items")
101+
expect(items.size).to eq(1)
102+
expect(items.first).to include("identifier" => "abc")
99103
end
100104
end
101105

spec/requests/mcp/mcp_tools/search_projects_spec.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,22 @@
8383
context "when passing an exact identifier" do
8484
let(:call_args) { { identifier: "abc" } }
8585

86-
it "finds the project" do
86+
it "finds only the matching project" do
8787
subject
88-
expect(parsed_results.dig("structuredContent", "items")).to be_present
88+
items = parsed_results.dig("structuredContent", "items")
89+
expect(items.size).to eq(1)
90+
expect(items.first).to include("identifier" => "abc")
8991
end
9092
end
9193

9294
context "when passing a case-variant identifier" do
9395
let(:call_args) { { identifier: "Abc" } }
9496

95-
it "finds the project (case-insensitive)" do
97+
it "finds only the matching project (case-insensitive)" do
9698
subject
97-
expect(parsed_results.dig("structuredContent", "items")).to be_present
99+
items = parsed_results.dig("structuredContent", "items")
100+
expect(items.size).to eq(1)
101+
expect(items.first).to include("identifier" => "abc")
98102
end
99103
end
100104

0 commit comments

Comments
 (0)