diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-21 21:07:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-21 21:07:31 +0300 |
commit | d91f5211693e913da5df110b8de841fad87e3653 (patch) | |
tree | d1483aeb8fe3d2b9579b0e44f2e74979c4b8d17a /spec/lib | |
parent | c859c3bfd242288065fe5e2d887f7204f09e2335 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/experimentation_spec.rb | 31 | ||||
-rw-r--r-- | spec/lib/gitlab/phabricator_import/base_worker_spec.rb | 74 | ||||
-rw-r--r-- | spec/lib/gitlab/phabricator_import/import_tasks_worker_spec.rb | 16 | ||||
-rw-r--r-- | spec/lib/gitlab/usage_data_spec.rb | 3 |
4 files changed, 24 insertions, 100 deletions
diff --git a/spec/lib/gitlab/experimentation_spec.rb b/spec/lib/gitlab/experimentation_spec.rb index e4624accd58..1506794cbb5 100644 --- a/spec/lib/gitlab/experimentation_spec.rb +++ b/spec/lib/gitlab/experimentation_spec.rb @@ -96,10 +96,10 @@ describe Gitlab::Experimentation do expect(Gitlab::Tracking).to receive(:event).with( 'Team', 'start', - label: nil, - property: 'experimental_group' + property: 'experimental_group', + value: 'team_id' ) - controller.track_experiment_event(:test_experiment, 'start') + controller.track_experiment_event(:test_experiment, 'start', 'team_id') end end @@ -112,10 +112,10 @@ describe Gitlab::Experimentation do expect(Gitlab::Tracking).to receive(:event).with( 'Team', 'start', - label: nil, - property: 'control_group' + property: 'control_group', + value: 'team_id' ) - controller.track_experiment_event(:test_experiment, 'start') + controller.track_experiment_event(:test_experiment, 'start', 'team_id') end end end @@ -144,13 +144,13 @@ describe Gitlab::Experimentation do end it 'pushes the right parameters to gon' do - controller.frontend_experimentation_tracking_data(:test_experiment, 'start') + controller.frontend_experimentation_tracking_data(:test_experiment, 'start', 'team_id') expect(Gon.tracking_data).to eq( { category: 'Team', action: 'start', - label: nil, - property: 'experimental_group' + property: 'experimental_group', + value: 'team_id' } ) end @@ -164,12 +164,23 @@ describe Gitlab::Experimentation do end it 'pushes the right parameters to gon' do + controller.frontend_experimentation_tracking_data(:test_experiment, 'start', 'team_id') + expect(Gon.tracking_data).to eq( + { + category: 'Team', + action: 'start', + property: 'control_group', + value: 'team_id' + } + ) + end + + it 'does not send nil value to gon' do controller.frontend_experimentation_tracking_data(:test_experiment, 'start') expect(Gon.tracking_data).to eq( { category: 'Team', action: 'start', - label: nil, property: 'control_group' } ) diff --git a/spec/lib/gitlab/phabricator_import/base_worker_spec.rb b/spec/lib/gitlab/phabricator_import/base_worker_spec.rb deleted file mode 100644 index d46d908a3e3..00000000000 --- a/spec/lib/gitlab/phabricator_import/base_worker_spec.rb +++ /dev/null @@ -1,74 +0,0 @@ -# frozen_string_literal: true -require 'spec_helper' - -describe Gitlab::PhabricatorImport::BaseWorker do - let(:subclass) do - # Creating an anonymous class for a worker is complicated, as we generate the - # queue name from the class name. - Gitlab::PhabricatorImport::ImportTasksWorker - end - - describe '.schedule' do - let(:arguments) { %w[project_id the_next_page] } - - it 'schedules the job' do - expect(subclass).to receive(:perform_async).with(*arguments) - - subclass.schedule(*arguments) - end - - it 'counts the scheduled job', :clean_gitlab_redis_shared_state do - state = Gitlab::PhabricatorImport::WorkerState.new('project_id') - - allow(subclass).to receive(:remove_job) # otherwise the job is removed before we saw it - - expect { subclass.schedule(*arguments) }.to change { state.running_count }.by(1) - end - end - - describe '#perform' do - let(:project) { create(:project, :import_started, import_url: "https://a.phab.instance") } - let(:worker) { subclass.new } - let(:state) { Gitlab::PhabricatorImport::WorkerState.new(project.id) } - - before do - allow(worker).to receive(:import) - end - - it 'does not break for a non-existing project' do - expect { worker.perform('not a thing') }.not_to raise_error - end - - it 'does not do anything when the import is not in progress' do - project = create(:project, :import_failed) - - expect(worker).not_to receive(:import) - - worker.perform(project.id) - end - - it 'calls import for the project' do - expect(worker).to receive(:import).with(project, 'other_arg') - - worker.perform(project.id, 'other_arg') - end - - it 'marks the project as imported if there was only one job running' do - worker.perform(project.id) - - expect(project.import_state.reload).to be_finished - end - - it 'does not mark the job as finished when there are more scheduled jobs' do - 2.times { state.add_job } - - worker.perform(project.id) - - expect(project.import_state.reload).to be_in_progress - end - - it 'decrements the job counter' do - expect { worker.perform(project.id) }.to change { state.running_count }.by(-1) - end - end -end diff --git a/spec/lib/gitlab/phabricator_import/import_tasks_worker_spec.rb b/spec/lib/gitlab/phabricator_import/import_tasks_worker_spec.rb deleted file mode 100644 index 1e38ef8aaa5..00000000000 --- a/spec/lib/gitlab/phabricator_import/import_tasks_worker_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true -require 'spec_helper' - -describe Gitlab::PhabricatorImport::ImportTasksWorker do - describe '#perform' do - it 'calls the correct importer' do - project = create(:project, :import_started, import_url: "https://the.phab.ulr") - fake_importer = instance_double(Gitlab::PhabricatorImport::Issues::Importer) - - expect(Gitlab::PhabricatorImport::Issues::Importer).to receive(:new).with(project).and_return(fake_importer) - expect(fake_importer).to receive(:execute) - - described_class.new.perform(project.id) - end - end -end diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index cf1dacd088e..9a49d334f52 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -49,6 +49,7 @@ describe Gitlab::UsageData do create(:clusters_applications_runner, :installed, cluster: gcp_cluster) create(:clusters_applications_knative, :installed, cluster: gcp_cluster) create(:clusters_applications_elastic_stack, :installed, cluster: gcp_cluster) + create(:clusters_applications_jupyter, :installed, cluster: gcp_cluster) create(:grafana_integration, project: projects[0], enabled: true) create(:grafana_integration, project: projects[1], enabled: true) @@ -149,6 +150,7 @@ describe Gitlab::UsageData do clusters_applications_runner clusters_applications_knative clusters_applications_elastic_stack + clusters_applications_jupyter in_review_folder grafana_integrated_projects groups @@ -242,6 +244,7 @@ describe Gitlab::UsageData do expect(count_data[:clusters_applications_knative]).to eq(1) expect(count_data[:clusters_applications_elastic_stack]).to eq(1) expect(count_data[:grafana_integrated_projects]).to eq(2) + expect(count_data[:clusters_applications_jupyter]).to eq(1) end it 'works when queries time out' do |