Skip to content

Commit 2b105ef

Browse files
committed
broaden /metadata/:class tests; narrow 404 test to bogus-only names
- Extend `test_metadata_route_renders_for_model_class` to loop over `Ontology`, `Metrics`, `Class` — covers plain top-level lookup (`Ontology`), singularization (`Metrics` → `Metric`), and a second plain case with a distinctive name (`Class`). All three hit the same `resolve_model_class` top-level branch, but `Ontology` was the one case we previously had no explicit coverage for. - Rename `test_metadata_route_returns_404_for_non_class_names` → `test_metadata_route_returns_404_for_bogus_names` and trim its list to `DefinitelyNotAModel`, `nonexistent_thing`, `xyzqux123` — guaranteed-nonexistent identifiers that will stay 404 regardless of future features. The previous list (`created`, `body`, `prefixIRI`, `name`, `omvacronym`) was misleading: those *are* attribute URIs the API emits in JSON-LD @context, currently 404'd as a stop-gap but tracked in ncbo/bioportal-project#388 for actual attribute-documentation rendering. Leaving them asserted as 404 would turn into a false regression signal when #388 lands.
1 parent d2e5b64 commit 2b105ef

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

test/controllers/test_home_controller.rb

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ def test_documentation_route_renders
2929
# for the same namespace-helper-resolution reason as /documentation, and
3030
# had been listed as broken in #37 since 2017.
3131
def test_metadata_route_renders_for_model_class
32-
get '/metadata/Metrics'
33-
assert last_response.ok?, get_errors(last_response)
34-
assert_match(/<html/i, last_response.body)
32+
%w[Ontology Metrics Class].each do |name|
33+
get "/metadata/#{name}"
34+
assert last_response.ok?,
35+
"expected 200 for /metadata/#{name}, got #{last_response.status}: #{get_errors(last_response)}"
36+
assert_match(/<html/i, last_response.body)
37+
end
3538
end
3639

3740
# Exercises the sub-module lookup branch in HomeHelper#routes_by_class
@@ -42,11 +45,19 @@ def test_metadata_route_resolves_submodule_class
4245
assert_match(/<html/i, last_response.body)
4346
end
4447

45-
# /metadata/:class for names that aren't model classes (attribute/property
46-
# names, arbitrary typos) should return 404, not 500. Several paths of this
47-
# shape are listed in ncbo/ontologies_api#37.
48-
def test_metadata_route_returns_404_for_non_class_names
49-
%w[created body prefixIRI name omvacronym Nonexistent].each do |name|
48+
# /metadata/:class for genuinely bogus names (arbitrary typos, identifiers
49+
# not emitted by the API anywhere) should always return 404.
50+
#
51+
# Attribute URIs that the API *does* emit in JSON-LD @context (e.g.
52+
# /metadata/created, /metadata/name, /metadata/prefixIRI, /metadata/omv*)
53+
# are intentionally NOT asserted here. Those currently 404 as a stop-gap
54+
# (commit d2e5b64), but ncbo/bioportal-project#388 tracks making them
55+
# render actual attribute documentation. When that lands this test should
56+
# not silently flip from "correctly 404" to "incorrectly 404 — feature
57+
# regressed"; a new assertion covering attribute URIs will live alongside
58+
# that feature work instead.
59+
def test_metadata_route_returns_404_for_bogus_names
60+
%w[DefinitelyNotAModel nonexistent_thing xyzqux123].each do |name|
5061
get "/metadata/#{name}"
5162
assert_equal 404, last_response.status,
5263
"expected 404 for /metadata/#{name}, got #{last_response.status}: #{last_response.body[0, 200]}"

0 commit comments

Comments
 (0)