Commit b366b92c authored by eugielimpin's avatar eugielimpin

Use control/candidate/variant(:name) instead of use/try/try(:name)

use, try, and try(:variant_name) are now deprecated
parent d1f7c562
......@@ -11,8 +11,8 @@ class Groups::BoardsController < Groups::ApplicationController
push_frontend_feature_flag(:board_multi_select, group, default_enabled: :yaml)
push_frontend_feature_flag(:iteration_cadences, group, default_enabled: :yaml)
experiment(:prominent_create_board_btn, subject: current_user) do |e|
e.use { }
e.try { }
e.control { }
e.candidate { }
end.run
end
......
......@@ -11,8 +11,8 @@ class Projects::BoardsController < Projects::ApplicationController
push_frontend_feature_flag(:board_multi_select, project, default_enabled: :yaml)
push_frontend_feature_flag(:iteration_cadences, project&.group, default_enabled: :yaml)
experiment(:prominent_create_board_btn, subject: current_user) do |e|
e.use { }
e.try { }
e.control { }
e.candidate { }
end.run
end
......
......@@ -428,7 +428,7 @@ module ApplicationHelper
experiment(:logged_out_marketing_header, actor: nil) do |e|
html_class = 'logged-out-marketing-header-candidate'
e.candidate { html_class }
e.try(:trial_focused) { html_class }
e.variant(:trial_focused) { html_class }
e.control {}
e.run
end
......
......@@ -34,7 +34,7 @@ module IdeHelper
def enable_environments_guidance?
experiment(:in_product_guidance_environments_webide, project: @project) do |e|
e.try { !has_dismissed_ide_environments_callout? }
e.candidate { !has_dismissed_ide_environments_callout? }
e.run
end
......
......@@ -33,8 +33,8 @@ module LearnGitlabHelper
actor: current_user,
sticky_to: project.namespace
) do |e|
e.use { urls_to_use = action_urls }
e.try { urls_to_use = new_action_urls(project) }
e.control { urls_to_use = action_urls }
e.candidate { urls_to_use = new_action_urls(project) }
end
urls_to_use.to_h do |action, url|
......
......@@ -63,13 +63,13 @@
= s_('ProjectsNew|Allows you to immediately clone this project’s repository. Skip this if you plan to push up an existing repository.')
- experiment(:new_project_sast_enabled, user: current_user) do |e|
- e.try(:candidate) do
- e.variant(:candidate) do
= render 'new_project_initialize_with_sast', experiment_name: e.name, track_label: track_label, checked: true, with_free_badge: false
- e.try(:unchecked_candidate) do
- e.variant(:unchecked_candidate) do
= render 'new_project_initialize_with_sast', experiment_name: e.name, track_label: track_label, checked: false, with_free_badge: false
- e.try(:free_indicator) do
- e.variant(:free_indicator) do
= render 'new_project_initialize_with_sast', experiment_name: e.name, track_label: track_label, checked: true, with_free_badge: true
- e.try(:unchecked_free_indicator) do
- e.variant(:unchecked_free_indicator) do
= render 'new_project_initialize_with_sast', experiment_name: e.name, track_label: track_label, checked: false, with_free_badge: true
= f.submit _('Create project'), class: "btn gl-button btn-confirm", data: { track_label: "#{track_label}", track_action: "click_button", track_property: "create_project", track_value: "" }
......
......@@ -59,12 +59,12 @@ module EE
options = localized_jobs_to_be_done_choices.dup
experiment(:bypass_registration, user: current_user) do |e|
e.use do
e.control do
options.merge(
joining_team: _('I’m joining my team who’s already on GitLab')
)
end
e.try do
e.candidate do
options
end
e.run
......
......@@ -8,8 +8,8 @@ module PaidFeatureCalloutHelper
experiment(:highlight_paid_features_during_active_trial, group: group) do |e|
e.exclude! unless billing_plans_and_trials_available?
e.exclude! unless group && eligible_for_trial_upgrade_callout?(group)
e.use { nil } # control gets nothing new added to the existing UI
e.try(&block)
e.control { nil } # control gets nothing new added to the existing UI
e.candidate(&block)
e.publish_to_database
end
end
......
......@@ -3,8 +3,8 @@
module Projects::Security::DiscoverHelper
def pql_three_cta_test_experiment_candidate?(namespace)
experiment(:pql_three_cta_test, namespace: namespace) do |e|
e.use { false }
e.try { true }
e.control { false }
e.candidate { true }
end.run
end
......
......@@ -53,7 +53,7 @@ module TrialStatusWidgetHelper
force_popover = false
experiment(:forcibly_show_trial_status_popover, group: group) do |e|
e.try do
e.candidate do
force_popover = !dismissed_feature_callout?(
current_user_callout_feature_id(group.trial_days_remaining)
)
......
......@@ -22,7 +22,7 @@
- top_level_namespace = @target_project.root_ancestor
- if can?(current_user, :admin_group, top_level_namespace)
- experiment(:promote_mr_approvals_in_free, namespace: top_level_namespace, user: current_user, sticky_to: current_user) do |e|
- e.try do
- e.candidate do
#js-mr-approvals-promo{ data: { try_now_path: new_trial_path,
learn_more_path: help_page_path('user/project/merge_requests/approvals/index'),
promo_image_path: image_path('illustrations/merge_requests.svg'),
......
......@@ -14,8 +14,8 @@ module API
experiments = []
experiment(:null_hypothesis, canary: true, user: current_user) do |e|
e.use { bad_request! 'experimentation may not be working right now' }
e.try do
e.control { bad_request! 'experimentation may not be working right now' }
e.candidate do
experiments = Feature::Definition.definitions.values.select { |d| d.attributes[:type] == 'experiment' }
end
end
......
......@@ -359,8 +359,8 @@ RSpec.describe ApplicationExperiment, :experiment do
end
it "returns an assigned name" do
application_experiment.try(:variant1) {}
application_experiment.try(:variant2) {}
application_experiment.variant(:variant1) {}
application_experiment.variant(:variant2) {}
expect(application_experiment.variant.name).to eq('variant2')
end
......@@ -395,8 +395,8 @@ RSpec.describe ApplicationExperiment, :experiment do
cache.clear(key: application_experiment.name)
application_experiment.use { } # setup the control
application_experiment.try { } # setup the candidate
application_experiment.control { }
application_experiment.candidate { }
end
it "caches the variant determined by the variant resolver" do
......
......@@ -21,8 +21,8 @@ RSpec.describe "Gitlab::Experiment", :js do
allow_next_instance_of(Admin::AbuseReportsController) do |instance|
allow(instance).to receive(:index).and_wrap_original do |original|
instance.experiment(:null_hypothesis, user: instance.current_user) do |e|
e.use { original.call }
e.try { original.call }
e.control { original.call }
e.candidate { original.call }
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment