Skip to content

fix: Don't fetch environments on Admin variables page

What does this MR do and why?

A request to fetch environments would be sent on the Admin variables page when the ci_variable_settings_graphql FF is disabled, but that doesn't make sense as we're not in a project context.

A system test started to fail recently because of an ambiguous match on alert boxes.

The fix is to only fetch environments if we're in a project's context.

Possibly related MRs are:

Screenshots or screen recordings

Before

Screen_Shot_2022-10-06_at_09.38.34

After

Screen_Shot_2022-10-06_at_10.25.50

How to set up and validate locally

On master

  1. Ensure the ci_variable_settings_graphql feature flag is disabled (Feature.disable('ci_variable_settings_graphql'))
  2. Visit http://gdk.test:3000/admin/application_settings/ci_cd
  3. Notice the There was an error fetching the environments information. alert, similar to #376761 (closed)
  4. You can inspect the XHR requests and notice a 404 request to http://gdk.test:3000/api/v4/projects/undefined/environments

Alternatively, you can also just run bin/rspec './spec/features/admin_variables_spec.rb[1:1:1:10]', it should fail with the same error as #376761 (closed).

On this branch

  1. Ensure the ci_variable_settings_graphql feature flag is disabled (Feature.disable('ci_variable_settings_graphql'))
  2. Visit http://gdk.test:3000/admin/application_settings/ci_cd
  3. Notice there's no There was an error fetching the environments information. alert
  4. You can inspect the XHR requests and shouldn't see any one to http://gdk.test:3000/api/v4/projects/undefined/environments

Alternatively, you can also just run bin/rspec './spec/features/admin_variables_spec.rb[1:1:1:10]', it should pass.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #376761 (closed)

Edited by Mark Florian

Merge request reports