Commit 7b257c7c authored by jejacks0n's avatar jejacks0n

Use the custom RoundRobin strategy directly

- This will allow us to remove it from ApplicationExperiment.
parent 8d0ec9fb
...@@ -7,12 +7,8 @@ module Members ...@@ -7,12 +7,8 @@ module Members
INVITE_TYPE = 'initial_email' INVITE_TYPE = 'initial_email'
def rollout_strategy def resolve_variant_name
:round_robin Strategy::RoundRobin.new(feature_flag_name, %i[avatar permission_info control]).execute
end
def variants
%i[avatar permission_info control]
end end
end end
end end
...@@ -3,26 +3,14 @@ ...@@ -3,26 +3,14 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Members::InviteEmailExperiment do RSpec.describe Members::InviteEmailExperiment do
subject :invite_email do subject(:invite_email) { experiment('members/invite_email', **context) }
experiment('members/invite_email', actor: double('Member', created_by: double('User', avatar_url: '_avatar_url_')))
end let(:context) { { actor: double('Member', created_by: double('User', avatar_url: '_avatar_url_')) } }
before do before do
allow(invite_email).to receive(:enabled?).and_return(true) allow(invite_email).to receive(:enabled?).and_return(true)
end end
describe "#rollout_strategy" do
it "resolves to round_robin" do
expect(invite_email.rollout_strategy).to eq(:round_robin)
end
end
describe "#variants" do
it "has all the expected variants" do
expect(invite_email.variants).to match(%i[avatar permission_info control])
end
end
describe "exclusions", :experiment do describe "exclusions", :experiment do
it "excludes when created by is nil" do it "excludes when created by is nil" do
expect(experiment('members/invite_email')).to exclude(actor: double(created_by: nil)) expect(experiment('members/invite_email')).to exclude(actor: double(created_by: nil))
...@@ -34,4 +22,27 @@ RSpec.describe Members::InviteEmailExperiment do ...@@ -34,4 +22,27 @@ RSpec.describe Members::InviteEmailExperiment do
expect(experiment('members/invite_email')).to exclude(actor: member_without_avatar_url) expect(experiment('members/invite_email')).to exclude(actor: member_without_avatar_url)
end end
end end
describe "variant resolution", :clean_gitlab_redis_shared_state do
it "proves out round robin in variant selection", :aggregate_failures do
instance_1 = described_class.new('members/invite_email', **context)
allow(instance_1).to receive(:enabled?).and_return(true)
instance_2 = described_class.new('members/invite_email', **context)
allow(instance_2).to receive(:enabled?).and_return(true)
instance_3 = described_class.new('members/invite_email', **context)
allow(instance_3).to receive(:enabled?).and_return(true)
instance_1.try { }
expect(instance_1.variant.name).to eq('permission_info')
instance_2.try { }
expect(instance_2.variant.name).to eq('control')
instance_3.try { }
expect(instance_3.variant.name).to eq('avatar')
end
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