- Test `GET` endpoints to check that the scope is allowed.
- Test `POST` endpoints to check that the scope is disallowed.
- Test both `v3` and `v4` endpoints.
- Declaring an endpoint's scopes in a `before` block has proved to be
unreliable. For example, if we're accessing the `API::Users` endpoint - code
in a `before` block in `API::API` wouldn't be able to see the scopes set in
`API::Users` since the `API::API` `before` block runs first.
- This commit moves these declarations to the class level, since they don't need
to change once set.
This is not a good idea to memoize `json_response` using an instance
variable because `rspec-retry` doesn't clear instance variables on
retries, only `let` variables.
This will avoid issues where retries would fail on a different line that
the original failure, blurrying what's the real failure.
Also, automatically add api: true to specs under
/spec/requests/(ci/)?api/, and include JsonHelpers in controller, request
and API specs.
Signed-off-by: Rémy Coutable <remy@rymai.me>
Changes:
* Move spec/monkeypatch to spec/support
* Remove unused support/shared_examples
* Move support/api to support/api_helpers to match module name
* Move support/login to support/login_helpers to match module name
* Move API specs to requests/api (convention over configuration)
* Remove unused support/js_patch
* Simplify login_as helper
* Move DatabaseCleaner stuff to its own support file
* Remove unnecessary configuration and requires from spec_helper