diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/controllers/projects/blob_controller_spec.rb | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/controllers/projects/blob_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/blob_controller_spec.rb | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/spec/controllers/projects/blob_controller_spec.rb b/spec/controllers/projects/blob_controller_spec.rb index a56425c2a22..16be7394174 100644 --- a/spec/controllers/projects/blob_controller_spec.rb +++ b/spec/controllers/projects/blob_controller_spec.rb @@ -7,6 +7,82 @@ RSpec.describe Projects::BlobController do let(:project) { create(:project, :public, :repository) } + describe "GET new" do + context 'with no jobs' do + let_it_be(:user) { create(:user) } + let_it_be(:file_name) { '.gitlab-ci.yml' } + + def request + get(:new, params: { namespace_id: project.namespace, project_id: project, id: 'master', file_name: file_name } ) + end + + before do + project.add_maintainer(user) + sign_in(user) + + stub_experiment(ci_syntax_templates: experiment_active) + stub_experiment_for_subject(ci_syntax_templates: in_experiment_group) + end + + context 'when the experiment is not active' do + let(:experiment_active) { false } + let(:in_experiment_group) { false } + + it 'does not record the experiment user' do + expect(Experiment).not_to receive(:add_user) + + request + end + end + + context 'when the experiment is active and the user is in the control group' do + let(:experiment_active) { true } + let(:in_experiment_group) { false } + + it 'records the experiment user in the control group' do + expect(Experiment).to receive(:add_user) + .with(:ci_syntax_templates, :control, user, namespace_id: project.namespace_id) + + request + end + end + + context 'when the experiment is active and the user is in the experimental group' do + let(:experiment_active) { true } + let(:in_experiment_group) { true } + + it 'records the experiment user in the experimental group' do + expect(Experiment).to receive(:add_user) + .with(:ci_syntax_templates, :experimental, user, namespace_id: project.namespace_id) + + request + end + + context 'when requesting a non default config file type' do + let(:file_name) { '.non_default_ci_config' } + let(:project) { create(:project, :public, :repository, ci_config_path: file_name) } + + it 'records the experiment user in the experimental group' do + expect(Experiment).to receive(:add_user) + .with(:ci_syntax_templates, :experimental, user, namespace_id: project.namespace_id) + + request + end + end + + context 'when requesting a different file type' do + let(:file_name) { '.gitignore' } + + it 'does not record the experiment user' do + expect(Experiment).not_to receive(:add_user) + + request + end + end + end + end + end + describe "GET show" do def request get(:show, params: { namespace_id: project.namespace, project_id: project, id: id }) |