Commit ce5fcf69 authored by Matthias Käppler's avatar Matthias Käppler

Merge branch 'jejacks0n/maintenance/remove-public-behaviors' into 'master'

Switch to using declarative behavior registration

See merge request gitlab-org/gitlab!80001
parents e23a5811 c5507970
# frozen_string_literal: true
class ApplicationExperiment < Gitlab::Experiment
control { nil } # provide a default control for anonymous experiments
def publish(_result = nil)
super
......
......@@ -3,6 +3,9 @@
class CombinedRegistrationExperiment < ApplicationExperiment
include Rails.application.routes.url_helpers
control { new_users_sign_up_group_path }
candidate { new_users_sign_up_groups_project_path }
def key_for(source, _ = nil)
super(source, 'force_company_trial')
end
......@@ -10,12 +13,4 @@ class CombinedRegistrationExperiment < ApplicationExperiment
def redirect_path
run
end
def control_behavior
new_users_sign_up_group_path
end
def candidate_behavior
new_users_sign_up_groups_project_path
end
end
# frozen_string_literal: true
class InProductGuidanceEnvironmentsWebideExperiment < ApplicationExperiment
exclude :has_environments?
control { false }
def control_behavior
false
end
exclude :has_environments?
private
......
# frozen_string_literal: true
class NewProjectSastEnabledExperiment < ApplicationExperiment
def publish(_result = nil)
control { }
variant(:candidate) { }
variant(:free_indicator) { }
variant(:unchecked_candidate) { }
variant(:unchecked_free_indicator) { }
def publish(*args)
super
publish_to_database
end
def candidate_behavior
end
def free_indicator_behavior
end
def unchecked_candidate_behavior
end
def unchecked_free_indicator_behavior
end
end
# frozen_string_literal: true
class RequireVerificationForNamespaceCreationExperiment < ApplicationExperiment
control { false }
candidate { true }
exclude :existing_user
EXPERIMENT_START_DATE = Date.new(2022, 1, 31)
def control_behavior
false
end
def candidate_behavior
true
end
def candidate?
run
end
......
# frozen_string_literal: true
class SecurityReportsMrWidgetPromptExperiment < ApplicationExperiment
control { }
candidate { }
def publish(_result = nil)
super
publish_to_database
end
# This is a purely client side experiment, and since we don't have a nicer
# way to define variants yet, we define them here.
def candidate_behavior
end
end
......@@ -18,10 +18,13 @@ RSpec.describe ApplicationExperiment, :experiment do
allow(application_experiment).to receive(:enabled?).and_return(true)
end
it "doesn't raise an exception without a defined control" do
# because we have a default behavior defined
it "registers a default control behavior for anonymous experiments" do
# This default control behavior is not inherited, intentionally, but it
# does provide anonymous experiments with a base control behavior to keep
# them optional there.
expect { experiment('namespaced/stub') { } }.not_to raise_error
expect(experiment(:example)).to register_behavior(:control).with(nil)
expect { experiment(:example) { } }.not_to raise_error
end
describe "#publish" do
......
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