Skip to content

DRY new_project_sast_enabled experiment field with partials

Paul Slaughter requested to merge ps/dry-initialize-with-sast-experiment into master

What does this MR do and why?

This MR encapsulations some duplication between experiment variations in a partial.

(Copied from !76899 (comment 784278341)):

  • DRY'ing this removes any concern about error between the consistency of the experiments
  • It's not clear at first glance what the complete and actual difference is between the experiments (even though the names are descriptive).
  • Moving this to a partial improves it's own readability (because it doesn't have to be nested) + the readability of the original file since it doesn't include a big conditional block.

I'd rather have a temporary partial than temporary duplication.

Screenshots

Nothing should have changed in this MR and here's screenshots verifying locally:

control cadidate free_indicator unchecked_cadidate unchecked_free_indicator
Screenshot_from_2022-02-02_22-41-18 Screenshot_from_2022-02-02_22-41-04 Screenshot_from_2022-02-02_22-40-52 Screenshot_from_2022-02-02_22-40-29 Screenshot_from_2022-02-02_22-40-16

How to set up and validate locally

(Copied from !76899 (merged))

  1. Enable the experiment
    Feature.enable(:new_project_sast_enabled)
  2. Assign the variants you want to, for your test user (assuming root is your test user)
    include Gitlab::Experiment::Dsl
    experiment(:new_project_sast_enabled, :control, user: User.first) # no checkboxes should be visible
    experiment(:new_project_sast_enabled, :candidate, user: User.first) # checkbox should be visible and checked
    experiment(:new_project_sast_enabled, :free_indicator, user: User.first) # checkbox should be visible and checked, and you should have a label indicating that it's free if you check it
    experiment(:new_project_sast_enabled, :unchecked_candidate, user: User.first) # checkbox should be visible and unchecked
    experiment(:new_project_sast_enabled, :unchecked_free_indicator, user: User.first) # checkbox should be visible and unchecked, with the free label
  3. Create a new blank project.

MR acceptance checklist

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

Edited by Paul Slaughter

Merge request reports

Loading