The Rspec/FilePath does not catch wrong path names when not describing a constant

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Close this issue

Description of the proposal

When we spec GraphQL types we sometimes load the constant directly from the schema using something like:

GitlabSchema.types['Namespace']

This causes the Rspec/FilePath cop not to run, since it only enforces the filename of specs describing constants.

This caused us to miss an invalid filename in https://gitlab.com/gitlab-org/gitlab-ce/commit/f5c7c3b9ae8b91662830f46b595ce1512050be89#ffa47b2133b4ef38564af8741da79eda748f817b.

For GraphQL specifically we should describe the type as a constant, and check it's name using by comparing described_class.graphql_name.

Should we enforce always describing constants for specs in spec/graphql/types? Are there other places we should enforce this?

/cc @gitlab-org/maintainers/rails-backend

Edited Jun 30, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading