Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-23 18:06:29 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-23 18:06:29 +0300
commitb3f7042d06c53e5d4b8cad42e1b2679d0450f1a7 (patch)
tree373a039989e0497a71a4844f48e27d5f82f0e198 /spec/controllers
parent09ffaae1328da918056512ddc674913f0bb7b134 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/application_controller_spec.rb2
-rw-r--r--spec/controllers/registrations_controller_spec.rb92
-rw-r--r--spec/controllers/sessions_controller_spec.rb33
3 files changed, 126 insertions, 1 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index f4ac539136c..94afe741057 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -836,7 +836,7 @@ describe ApplicationController do
let(:experiment_enabled) { true }
before do
- stub_experiment(signup_flow: experiment_enabled)
+ stub_experiment_for_user(signup_flow: experiment_enabled)
end
context 'experiment enabled and user with required role' do
diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb
index ebeed94c274..8f147f949d0 100644
--- a/spec/controllers/registrations_controller_spec.rb
+++ b/spec/controllers/registrations_controller_spec.rb
@@ -9,6 +9,49 @@ describe RegistrationsController do
stub_feature_flags(invisible_captcha: false)
end
+ describe '#new' do
+ subject { get :new }
+
+ context 'with the experimental signup flow enabled and the user is part of the experimental group' do
+ before do
+ stub_experiment(signup_flow: true)
+ stub_experiment_for_user(signup_flow: true)
+ end
+
+ it 'tracks the event with the right parameters' do
+ expect(Gitlab::Tracking).to receive(:event).with(
+ 'Growth::Acquisition::Experiment::SignUpFlow',
+ 'start',
+ label: anything,
+ property: 'experimental_group'
+ )
+ subject
+ end
+
+ it 'renders new template and sets the resource variable' do
+ expect(subject).to render_template(:new)
+ expect(assigns(:resource)).to be_a(User)
+ end
+ end
+
+ context 'with the experimental signup flow enabled and the user is part of the control group' do
+ before do
+ stub_experiment(signup_flow: true)
+ stub_experiment_for_user(signup_flow: false)
+ end
+
+ it 'does not track the event' do
+ expect(Gitlab::Tracking).not_to receive(:event)
+ subject
+ end
+
+ it 'renders new template and sets the resource variable' do
+ subject
+ expect(response).to redirect_to(new_user_session_path(anchor: 'register-pane'))
+ end
+ end
+ end
+
describe '#create' do
let(:base_user_params) { { name: 'new_user', username: 'new_username', email: 'new@user.com', password: 'Any_password' } }
let(:user_params) { { user: base_user_params } }
@@ -217,6 +260,37 @@ describe RegistrationsController do
end
end
+ describe 'tracking data' do
+ context 'with the experimental signup flow enabled and the user is part of the control group' do
+ before do
+ stub_experiment(signup_flow: true)
+ stub_experiment_for_user(signup_flow: false)
+ end
+
+ it 'tracks the event with the right parameters' do
+ expect(Gitlab::Tracking).to receive(:event).with(
+ 'Growth::Acquisition::Experiment::SignUpFlow',
+ 'end',
+ label: anything,
+ property: 'control_group'
+ )
+ post :create, params: user_params
+ end
+ end
+
+ context 'with the experimental signup flow enabled and the user is part of the experimental group' do
+ before do
+ stub_experiment(signup_flow: true)
+ stub_experiment_for_user(signup_flow: true)
+ end
+
+ it 'does not track the event' do
+ expect(Gitlab::Tracking).not_to receive(:event)
+ post :create, params: user_params
+ end
+ end
+ end
+
it "logs a 'User Created' message" do
stub_feature_flags(registrations_recaptcha: false)
@@ -304,4 +378,22 @@ describe RegistrationsController do
end
end
end
+
+ describe '#update_role' do
+ before do
+ stub_experiment(signup_flow: true)
+ stub_experiment_for_user(signup_flow: true)
+ sign_in(create(:user))
+ end
+
+ it 'tracks the event with the right parameters' do
+ expect(Gitlab::Tracking).to receive(:event).with(
+ 'Growth::Acquisition::Experiment::SignUpFlow',
+ 'end',
+ label: anything,
+ property: 'experimental_group'
+ )
+ patch :update_role, params: { user: { name: 'New name', role: 'software_developer' } }
+ end
+ end
end
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb
index 2108cf1c8ae..53847e30a5c 100644
--- a/spec/controllers/sessions_controller_spec.rb
+++ b/spec/controllers/sessions_controller_spec.rb
@@ -34,6 +34,39 @@ describe SessionsController do
end
end
end
+
+ describe 'tracking data' do
+ context 'when the user is part of the experimental group' do
+ before do
+ stub_experiment_for_user(signup_flow: true)
+ end
+
+ it 'doesn\'t pass tracking parameters to the frontend' do
+ get(:new)
+ expect(Gon.tracking_data).to be_nil
+ end
+ end
+
+ context 'with the experimental signup flow enabled and the user is part of the control group' do
+ before do
+ stub_experiment(signup_flow: true)
+ stub_experiment_for_user(signup_flow: false)
+ allow_any_instance_of(described_class).to receive(:experimentation_subject_id).and_return('uuid')
+ end
+
+ it 'passes the right tracking parameters to the frontend' do
+ get(:new)
+ expect(Gon.tracking_data).to eq(
+ {
+ category: 'Growth::Acquisition::Experiment::SignUpFlow',
+ action: 'start',
+ label: 'uuid',
+ property: 'control_group'
+ }
+ )
+ end
+ end
+ end
end
describe '#create' do