This check works for classes, that don't try to load extensions, but if a class tries to load extensions and there is no extension, the class is considered as extended anyways.
The problem is, that InjectExtensions.extended_constants contains the class with an empty list of extensions.
We can fix that by adding a check, that the extensions are not empty (in addition to the rails env check) before adding it to the InjectExtensions.extended_constants map.
The
have_graphql_fields
matcher allows unexpected fields if theallow_unexpected_if_extended
chain is invoked.The matcher checks the extension by checking if
InjectExtensions.extended_constants
contains the relevant class.https://github.com/code0-tech/sagittarius/blob/3b90c54cacecff8190c3f696ebcb71e3c2d9b1a5/spec/support/matchers/graphql_matchers.rb#L18
This variable is filled with data here:
https://github.com/code0-tech/sagittarius/blob/3b90c54cacecff8190c3f696ebcb71e3c2d9b1a5/config/initializers/0_inject_extensions.rb#L9
This check works for classes, that don't try to load extensions, but if a class tries to load extensions and there is no extension, the class is considered as extended anyways. The problem is, that
InjectExtensions.extended_constants
contains the class with an empty list of extensions.We can fix that by adding a check, that the extensions are not empty (in addition to the rails env check) before adding it to the
InjectExtensions.extended_constants
map.