Commit a8850202 authored by Alper Akgun's avatar Alper Akgun

Redirect trial user to feature for project security

parent 05476fef
...@@ -190,6 +190,6 @@ class TrialsController < ApplicationController ...@@ -190,6 +190,6 @@ class TrialsController < ApplicationController
end end
def discover_group_security_flow? def discover_group_security_flow?
params[:glm_content] == 'discover-group-security' %w(discover-group-security discover-project-security).include?(params[:glm_content])
end end
end end
...@@ -184,30 +184,30 @@ RSpec.describe TrialsController do ...@@ -184,30 +184,30 @@ RSpec.describe TrialsController do
subject subject
end end
context 'in discover group security flow' do context 'redirect trial user to feature' do
let(:post_params) { { namespace_id: namespace.id, glm_content: 'discover-group-security' } } using RSpec::Parameterized::TableSyntax
context 'with redirect_trial_user_to_feature experiment variant' do where(:segment, :glm_content, :redirect) do
before do :control | 'discover-group-security' | :group_url
stub_experiments(redirect_trial_user_to_feature: :candidate) :candidate | 'discover-group-security' | :group_security_dashboard_url
:control | 'discover-project-security' | :group_url
:candidate | 'discover-project-security' | :group_security_dashboard_url
end end
it { is_expected.to redirect_to(group_security_dashboard_url(namespace, { trial: true })) } with_them do
it 'records the subject' do let(:post_params) { { namespace_id: namespace.id, glm_content: glm_content } }
expect(Experiment).to receive(:add_subject).with('redirect_trial_user_to_feature', variant: :experimental, subject: namespace) let(:variant) { segment == :control ? :control : :experimental }
let(:redirect_url) do
subject redirect == :group_url ? group_url(namespace, { trial: true }) : group_security_dashboard_url(namespace, { trial: true })
end
end end
context 'with redirect_trial_user_to_feature experiment control' do
before do before do
stub_experiments(redirect_trial_user_to_feature: :control) stub_experiments(redirect_trial_user_to_feature: segment)
end end
it { is_expected.to redirect_to(group_url(namespace, { trial: true })) } it { is_expected.to redirect_to(redirect_url) }
it 'records the subject' do it 'records the subject' do
expect(Experiment).to receive(:add_subject).with('redirect_trial_user_to_feature', variant: :control, subject: namespace) expect(Experiment).to receive(:add_subject).with('redirect_trial_user_to_feature', variant: variant, subject: namespace)
subject subject
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