Commit 42ece464 authored by Alper Akgun's avatar Alper Akgun

Merge branch 'disable-experiment-for-self-managed' into 'master'

Skip experimentation on self-managed

See merge request gitlab-org/gitlab!59362
parents 03637c50 ca1e4fb3
...@@ -41,9 +41,11 @@ module Namespaces ...@@ -41,9 +41,11 @@ module Namespaces
attr_reader :track, :interval, :in_product_marketing_email_records attr_reader :track, :interval, :in_product_marketing_email_records
def send_email_for_group(group) def send_email_for_group(group)
experiment_enabled_for_group = experiment_enabled_for_group?(group) if Gitlab.com?
experiment_add_group(group, experiment_enabled_for_group) experiment_enabled_for_group = experiment_enabled_for_group?(group)
return unless experiment_enabled_for_group experiment_add_group(group, experiment_enabled_for_group)
return unless experiment_enabled_for_group
end
users_for_group(group).each do |user| users_for_group(group).each do |user|
if can_perform_action?(user, group) if can_perform_action?(user, group)
......
...@@ -85,26 +85,46 @@ RSpec.describe Namespaces::InProductMarketingEmailsService, '#execute' do ...@@ -85,26 +85,46 @@ RSpec.describe Namespaces::InProductMarketingEmailsService, '#execute' do
end end
describe 'experimentation' do describe 'experimentation' do
context 'when the experiment is enabled' do context 'when on dotcom' do
it 'adds the group as an experiment subject in the experimental group' do before do
expect(Experiment).to receive(:add_group) allow(::Gitlab).to receive(:com?).and_return(true)
.with(:in_product_marketing_emails, variant: :experimental, group: group) end
execute_service context 'when the experiment is enabled' do
it 'adds the group as an experiment subject in the experimental group' do
expect(Experiment).to receive(:add_group)
.with(:in_product_marketing_emails, variant: :experimental, group: group)
execute_service
end
end end
end
context 'when the experiment is disabled' do context 'when the experiment is disabled' do
let(:experiment_enabled) { false } let(:experiment_enabled) { false }
it 'adds the group as an experiment subject in the control group' do
expect(Experiment).to receive(:add_group)
.with(:in_product_marketing_emails, variant: :control, group: group)
it 'adds the group as an experiment subject in the control group' do execute_service
expect(Experiment).to receive(:add_group) end
.with(:in_product_marketing_emails, variant: :control, group: group)
execute_service it { is_expected.not_to send_in_product_marketing_email }
end end
it { is_expected.not_to send_in_product_marketing_email } context 'when not on dotcom' do
before do
allow(::Gitlab).to receive(:com?).and_return(false)
end
it 'does not add the group as an experiment subject' do
expect(Experiment).not_to receive(:add_group)
execute_service
end
it { is_expected.to send_in_product_marketing_email(user.id, group.id, :create, 0) }
end
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