diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-28 15:08:36 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-28 15:08:36 +0000 |
commit | fedf978f9aa1909ed7bb3fad767ad120a1c6bd7b (patch) | |
tree | 1bd0f0b301ad96feda1910abe34eb89c46cc55cd /spec | |
parent | db24ab2b72dbff24c201410a0561e929ae7e8061 (diff) | |
download | gitlab-ce-fedf978f9aa1909ed7bb3fad767ad120a1c6bd7b.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
19 files changed, 286 insertions, 101 deletions
diff --git a/spec/controllers/projects/releases_controller_spec.rb b/spec/controllers/projects/releases_controller_spec.rb index 750e9aabef0..6abb58e1aa6 100644 --- a/spec/controllers/projects/releases_controller_spec.rb +++ b/spec/controllers/projects/releases_controller_spec.rb @@ -144,14 +144,6 @@ describe Projects::ReleasesController do end end - context 'when feature flag `release_edit_page` is disabled' do - before do - stub_feature_flags(release_edit_page: false) - end - - it_behaves_like 'not found' - end - context 'when release does not exist' do let!(:release) { } let(:tag) { 'non-existent-tag' } diff --git a/spec/factories/pages_domains.rb b/spec/factories/pages_domains.rb index 91423832888..282783dee3a 100644 --- a/spec/factories/pages_domains.rb +++ b/spec/factories/pages_domains.rb @@ -374,5 +374,10 @@ x6zG6WoibsbsJMj70nwseUnPTBQNDP+j61RJjC/r -----END EC PRIVATE KEY-----' end end + + trait :instance_serverless do + wildcard { true } + domain_type { :instance } + end end end diff --git a/spec/factories/serverless/domain_cluster.rb b/spec/factories/serverless/domain_cluster.rb index 24893f4a613..c44295e2405 100644 --- a/spec/factories/serverless/domain_cluster.rb +++ b/spec/factories/serverless/domain_cluster.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true FactoryBot.define do - factory :serverless_domain_cluster, class: 'Serverless::DomainCluster' do + factory :serverless_domain_cluster, class: '::Serverless::DomainCluster' do pages_domain { create(:pages_domain) } knative { create(:clusters_applications_knative) } creator { create(:user) } diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb index 056795a50d0..7a102cb479e 100644 --- a/spec/finders/issues_finder_spec.rb +++ b/spec/finders/issues_finder_spec.rb @@ -33,17 +33,22 @@ describe IssuesFinder do before do project2.add_developer(user3) - issue3.assignees = [user2, user3] + issue2.assignees = [user2] + issue3.assignees = [user3] end it_behaves_like 'assignee username filter' do - let(:params) { { assignee_username: [user2.username, user3.username] } } - let(:expected_issuables) { [issue3] } + let(:params) { { assignee_username: [user2.username] } } + let(:expected_issuables) { [issue2] } end it_behaves_like 'assignee NOT username filter' do - let(:params) { { not: { assignee_username: [user2.username, user3.username] } } } - let(:expected_issuables) { [issue1, issue2, issue4] } + before do + issue2.assignees = [user2] + end + + let(:params) { { not: { assignee_username: [user.username, user2.username] } } } + let(:expected_issuables) { [issue3, issue4] } end end @@ -395,8 +400,8 @@ describe IssuesFinder do context 'using NOT' do let(:params) { { not: { label_name: [label.title, label2.title].join(',') } } } - it 'returns issues that do not have ALL labels provided' do - expect(issues).to contain_exactly(issue1, issue3, issue4) + it 'returns issues that do not have any of the labels provided' do + expect(issues).to contain_exactly(issue1, issue4) end end end @@ -417,8 +422,8 @@ describe IssuesFinder do context 'using NOT' do let(:params) { { not: { label_name: [label.title, label2.title].join(',') } } } - it 'returns issues that do not have ALL labels provided' do - expect(issues).to contain_exactly(issue1, issue3, issue4) + it 'returns issues that do not have ANY ONE of the labels provided' do + expect(issues).to contain_exactly(issue1, issue4) end end end diff --git a/spec/helpers/application_settings_helper_spec.rb b/spec/helpers/application_settings_helper_spec.rb index 41008ff8eaf..c2f3e26f97b 100644 --- a/spec/helpers/application_settings_helper_spec.rb +++ b/spec/helpers/application_settings_helper_spec.rb @@ -107,7 +107,7 @@ describe ApplicationSettingsHelper do let(:project) { build(:project) } before do - stub_application_setting(instance_administration_project: project) + stub_application_setting(self_monitoring_project: project) end it 'returns self_monitoring_project_exists true' do diff --git a/spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb b/spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb index 10efdd44f20..e425acd4ae5 100644 --- a/spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb +++ b/spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb @@ -103,7 +103,7 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do end it 'creates project with correct name and description' do - path = 'administration/monitoring/gitlab_instance_administration_project/index' + path = 'administration/monitoring/gitlab_self_monitoring_project/index' docs_path = Rails.application.routes.url_helpers.help_page_path(path) expect(result[:status]).to eq(:success) @@ -122,13 +122,13 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do it 'saves the project id' do expect(result[:status]).to eq(:success) - expect(application_setting.instance_administration_project_id).to eq(project.id) + expect(application_setting.self_monitoring_project_id).to eq(project.id) end it 'returns error when saving project ID fails' do allow(application_setting).to receive(:update).and_call_original allow(application_setting).to receive(:update) - .with(instance_administration_project_id: anything) + .with(self_monitoring_project_id: anything) .and_return(false) expect(result).to eq( @@ -144,7 +144,7 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do before do application_setting.instance_administrators_group_id = existing_group.id - application_setting.instance_administration_project_id = existing_project.id + application_setting.self_monitoring_project_id = existing_project.id end it 'returns success' do diff --git a/spec/lib/gitlab/database_importers/self_monitoring/project/delete_service_spec.rb b/spec/lib/gitlab/database_importers/self_monitoring/project/delete_service_spec.rb index 6446ab1beb4..89d816c0cf7 100644 --- a/spec/lib/gitlab/database_importers/self_monitoring/project/delete_service_spec.rb +++ b/spec/lib/gitlab/database_importers/self_monitoring/project/delete_service_spec.rb @@ -24,7 +24,7 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::DeleteService do let(:application_setting) do create( :application_setting, - instance_administration_project_id: project.id, + self_monitoring_project_id: project.id, instance_administrators_group_id: group.id ) end @@ -38,7 +38,7 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::DeleteService do it 'deletes project ID from application settings' do subject.execute - expect(application_setting.reload.instance_administration_project_id).to be_nil + expect(application_setting.reload.self_monitoring_project_id).to be_nil end it 'does not delete group' do diff --git a/spec/lib/gitlab/prometheus/queries/knative_invocation_query_spec.rb b/spec/lib/gitlab/prometheus/queries/knative_invocation_query_spec.rb index fa2dccc7c92..ad254d3c50a 100644 --- a/spec/lib/gitlab/prometheus/queries/knative_invocation_query_spec.rb +++ b/spec/lib/gitlab/prometheus/queries/knative_invocation_query_spec.rb @@ -6,7 +6,7 @@ describe Gitlab::Prometheus::Queries::KnativeInvocationQuery do include PrometheusHelpers let(:project) { create(:project) } - let(:serverless_func) { Serverless::Function.new(project, 'test-name', 'test-ns') } + let(:serverless_func) { ::Serverless::Function.new(project, 'test-name', 'test-ns') } let(:client) { double('prometheus_client') } subject { described_class.new(client) } diff --git a/spec/lib/gitlab/serverless/function_uri_spec.rb b/spec/lib/gitlab/serverless/function_uri_spec.rb new file mode 100644 index 00000000000..cd4abeb89f5 --- /dev/null +++ b/spec/lib/gitlab/serverless/function_uri_spec.rb @@ -0,0 +1,81 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::Serverless::FunctionURI do + let(:function) { 'test-function' } + let(:domain) { 'serverless.gitlab.io' } + let(:pages_domain) { create(:pages_domain, :instance_serverless, domain: domain) } + let!(:cluster) { create(:serverless_domain_cluster, uuid: 'abcdef12345678', pages_domain: pages_domain) } + let(:valid_cluster) { 'aba1cdef123456f278' } + let(:invalid_cluster) { 'aba1cdef123456f178' } + let!(:environment) { create(:environment, name: 'test') } + + let(:valid_uri) { "https://#{function}-#{valid_cluster}#{"%x" % environment.id}-#{environment.slug}.#{domain}" } + let(:valid_fqdn) { "#{function}-#{valid_cluster}#{"%x" % environment.id}-#{environment.slug}.#{domain}" } + let(:invalid_uri) { "https://#{function}-#{invalid_cluster}#{"%x" % environment.id}-#{environment.slug}.#{domain}" } + + shared_examples 'a valid FunctionURI class' do + describe '#to_s' do + it 'matches valid URI' do + expect(subject.to_s).to eq valid_uri + end + end + + describe '#function' do + it 'returns function' do + expect(subject.function).to eq function + end + end + + describe '#cluster' do + it 'returns cluster' do + expect(subject.cluster).to eq cluster + end + end + + describe '#environment' do + it 'returns environment' do + expect(subject.environment).to eq environment + end + end + end + + describe '.new' do + context 'with valid arguments' do + subject { described_class.new(function: function, cluster: cluster, environment: environment) } + + it_behaves_like 'a valid FunctionURI class' + end + + context 'with invalid arguments' do + subject { described_class.new(function: function, environment: environment) } + + it 'raises an exception' do + expect { subject }.to raise_error(ArgumentError) + end + end + end + + describe '.parse' do + context 'with valid URI' do + subject { described_class.parse(valid_uri) } + + it_behaves_like 'a valid FunctionURI class' + end + + context 'with valid FQDN' do + subject { described_class.parse(valid_fqdn) } + + it_behaves_like 'a valid FunctionURI class' + end + + context 'with invalid URI' do + subject { described_class.parse(invalid_uri) } + + it 'returns nil' do + expect(subject).to be_nil + end + end + end +end diff --git a/spec/lib/gitlab/sidekiq_config/cli_methods_spec.rb b/spec/lib/gitlab/sidekiq_config/cli_methods_spec.rb new file mode 100644 index 00000000000..60d946db744 --- /dev/null +++ b/spec/lib/gitlab/sidekiq_config/cli_methods_spec.rb @@ -0,0 +1,116 @@ +# frozen_string_literal: true + +require 'fast_spec_helper' + +describe Gitlab::SidekiqConfig::CliMethods do + let(:dummy_root) { '/tmp/' } + + describe '.worker_queues' do + def expand_path(path) + File.join(dummy_root, path) + end + + def stub_exists(exists: true) + ['app/workers/all_queues.yml', 'ee/app/workers/all_queues.yml'].each do |path| + allow(File).to receive(:exist?).with(expand_path(path)).and_return(exists) + end + end + + def stub_contents(foss_queues, ee_queues) + allow(YAML).to receive(:load_file) + .with(expand_path('app/workers/all_queues.yml')) + .and_return(foss_queues) + + allow(YAML).to receive(:load_file) + .with(expand_path('ee/app/workers/all_queues.yml')) + .and_return(ee_queues) + end + + before do + described_class.clear_memoization! + end + + context 'when the file exists' do + before do + stub_exists(exists: true) + end + + shared_examples 'valid file contents' do + it 'memoizes the result' do + result = described_class.worker_queues(dummy_root) + + stub_exists(exists: false) + + expect(described_class.worker_queues(dummy_root)).to eq(result) + end + + it 'flattens and joins the contents' do + expected_queues = %w[queue_a queue_b] + expected_queues = expected_queues.first(1) unless Gitlab.ee? + + expect(described_class.worker_queues(dummy_root)) + .to match_array(expected_queues) + end + end + + context 'when the file contains an array of strings' do + before do + stub_contents(['queue_a'], ['queue_b']) + end + + include_examples 'valid file contents' + end + + context 'when the file contains an array of hashes' do + before do + stub_contents([{ name: 'queue_a' }], [{ name: 'queue_b' }]) + end + + include_examples 'valid file contents' + end + end + + context 'when the file does not exist' do + before do + stub_exists(exists: false) + end + + it 'returns an empty array' do + expect(described_class.worker_queues(dummy_root)).to be_empty + end + end + end + + describe '.expand_queues' do + let(:all_queues) do + ['cronjob:stuck_import_jobs', 'cronjob:stuck_merge_jobs', 'post_receive'] + end + + it 'defaults the value of the second argument to .worker_queues' do + allow(described_class).to receive(:worker_queues).and_return([]) + + expect(described_class.expand_queues(['cronjob'])) + .to contain_exactly('cronjob') + + allow(described_class).to receive(:worker_queues).and_return(all_queues) + + expect(described_class.expand_queues(['cronjob'])) + .to contain_exactly('cronjob', 'cronjob:stuck_import_jobs', 'cronjob:stuck_merge_jobs') + end + + it 'expands queue namespaces to concrete queue names' do + expect(described_class.expand_queues(['cronjob'], all_queues)) + .to contain_exactly('cronjob', 'cronjob:stuck_import_jobs', 'cronjob:stuck_merge_jobs') + end + + it 'lets concrete queue names pass through' do + expect(described_class.expand_queues(['post_receive'], all_queues)) + .to contain_exactly('post_receive') + end + + it 'lets unknown queues pass through' do + expect(described_class.expand_queues(['unknown'], all_queues)) + .to contain_exactly('unknown') + end + end +end diff --git a/spec/lib/gitlab/sidekiq_config/worker_spec.rb b/spec/lib/gitlab/sidekiq_config/worker_spec.rb index ba6760f38b5..38edd0f5eeb 100644 --- a/spec/lib/gitlab/sidekiq_config/worker_spec.rb +++ b/spec/lib/gitlab/sidekiq_config/worker_spec.rb @@ -3,9 +3,17 @@ require 'fast_spec_helper' describe Gitlab::SidekiqConfig::Worker do - def create_worker(queue:, weight: 0) + def create_worker(queue:, **attributes) namespace = queue.include?(':') && queue.split(':').first - inner_worker = double(queue: queue, queue_namespace: namespace, get_weight: weight) + inner_worker = double( + queue: queue, + queue_namespace: namespace, + get_feature_category: attributes[:feature_category], + get_weight: attributes[:weight], + get_worker_resource_boundary: attributes[:resource_boundary], + latency_sensitive_worker?: attributes[:latency_sensitive], + worker_has_external_dependencies?: attributes[:has_external_dependencies] + ) described_class.new(inner_worker, ee: false) end @@ -75,13 +83,32 @@ describe Gitlab::SidekiqConfig::Worker do end describe 'YAML encoding' do - it 'encodes the worker in YAML as a string of the queue' do - worker_a = create_worker(queue: 'a') - worker_b = create_worker(queue: 'b') + it 'encodes the worker in YAML as a hash of the queue' do + attributes_a = { + feature_category: :source_code_management, + has_external_dependencies: false, + latency_sensitive: false, + resource_boundary: :memory, + weight: 2 + } + + attributes_b = { + feature_category: :not_owned, + has_external_dependencies: true, + latency_sensitive: true, + resource_boundary: :unknown, + weight: 1 + } + + worker_a = create_worker(queue: 'a', **attributes_a) + worker_b = create_worker(queue: 'b', **attributes_b) + + expect(YAML.dump(worker_a)) + .to eq(YAML.dump(attributes_a.reverse_merge(name: 'a'))) - expect(YAML.dump(worker_a)).to eq(YAML.dump('a')) expect(YAML.dump([worker_a, worker_b])) - .to eq(YAML.dump(%w[a b])) + .to eq(YAML.dump([attributes_a.reverse_merge(name: 'a'), + attributes_b.reverse_merge(name: 'b')])) end end diff --git a/spec/lib/gitlab/sidekiq_config_spec.rb b/spec/lib/gitlab/sidekiq_config_spec.rb index 20690a35dc8..85de1d029c3 100644 --- a/spec/lib/gitlab/sidekiq_config_spec.rb +++ b/spec/lib/gitlab/sidekiq_config_spec.rb @@ -24,27 +24,6 @@ describe Gitlab::SidekiqConfig do end end - describe '.expand_queues' do - it 'expands queue namespaces to concrete queue names' do - queues = described_class.expand_queues(%w[cronjob]) - - expect(queues).to include('cronjob:stuck_import_jobs') - expect(queues).to include('cronjob:stuck_merge_jobs') - end - - it 'lets concrete queue names pass through' do - queues = described_class.expand_queues(%w[post_receive]) - - expect(queues).to include('post_receive') - end - - it 'lets unknown queues pass through' do - queues = described_class.expand_queues(%w[unknown]) - - expect(queues).to include('unknown') - end - end - describe '.workers_for_all_queues_yml' do it 'returns a tuple with FOSS workers first' do expect(described_class.workers_for_all_queues_yml.first) @@ -53,29 +32,31 @@ describe Gitlab::SidekiqConfig do end describe '.all_queues_yml_outdated?' do - before do - workers = [ - PostReceive, + let(:workers) do + [ MergeWorker, + PostReceive, ProcessCommitWorker ].map { |worker| described_class::Worker.new(worker, ee: false) } + end + before do allow(described_class).to receive(:workers).and_return(workers) allow(Gitlab).to receive(:ee?).and_return(false) end - it 'returns true if the YAML file does not match the application code' do - allow(File).to receive(:read) + it 'returns true if the YAML file does not matcph the application code' do + allow(YAML).to receive(:load_file) .with(described_class::FOSS_QUEUE_CONFIG_PATH) - .and_return(YAML.dump(%w[post_receive merge])) + .and_return(workers.first(2).map(&:to_yaml)) expect(described_class.all_queues_yml_outdated?).to be(true) end it 'returns false if the YAML file matches the application code' do - allow(File).to receive(:read) + allow(YAML).to receive(:load_file) .with(described_class::FOSS_QUEUE_CONFIG_PATH) - .and_return(YAML.dump(%w[merge post_receive process_commit])) + .and_return(workers.map(&:to_yaml)) expect(described_class.all_queues_yml_outdated?).to be(false) end @@ -125,17 +106,17 @@ describe Gitlab::SidekiqConfig do end it 'returns true if the YAML file does not match the application code' do - allow(File).to receive(:read) + allow(YAML).to receive(:load_file) .with(described_class::SIDEKIQ_QUEUES_PATH) - .and_return(YAML.dump(queues: expected_queues.reverse)) + .and_return(queues: expected_queues.reverse) expect(described_class.sidekiq_queues_yml_outdated?).to be(true) end it 'returns false if the YAML file matches the application code' do - allow(File).to receive(:read) + allow(YAML).to receive(:load_file) .with(described_class::SIDEKIQ_QUEUES_PATH) - .and_return(YAML.dump(queues: expected_queues)) + .and_return(queues: expected_queues) expect(described_class.sidekiq_queues_yml_outdated?).to be(false) end diff --git a/spec/models/clusters/applications/knative_spec.rb b/spec/models/clusters/applications/knative_spec.rb index 68ac3f0d483..993cc7d0203 100644 --- a/spec/models/clusters/applications/knative_spec.rb +++ b/spec/models/clusters/applications/knative_spec.rb @@ -17,7 +17,7 @@ describe Clusters::Applications::Knative do end describe 'associations' do - it { is_expected.to have_one(:serverless_domain_cluster).class_name('Serverless::DomainCluster').with_foreign_key('clusters_applications_knative_id').inverse_of(:knative) } + it { is_expected.to have_one(:serverless_domain_cluster).class_name('::Serverless::DomainCluster').with_foreign_key('clusters_applications_knative_id').inverse_of(:knative) } end describe 'when cloud run is enabled' do diff --git a/spec/models/project_services/prometheus_service_spec.rb b/spec/models/project_services/prometheus_service_spec.rb index 5934510fdda..49005d8c681 100644 --- a/spec/models/project_services/prometheus_service_spec.rb +++ b/spec/models/project_services/prometheus_service_spec.rb @@ -70,7 +70,7 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do before do service.api_url = 'http://localhost:9090' - stub_application_setting(instance_administration_project_id: project.id) + stub_application_setting(self_monitoring_project_id: project.id) stub_config(prometheus: { enable: true, listen_address: 'localhost:9090' }) end diff --git a/spec/models/serverless/domain_cluster_spec.rb b/spec/models/serverless/domain_cluster_spec.rb index b5ed1df4f45..9bc5c04678b 100644 --- a/spec/models/serverless/domain_cluster_spec.rb +++ b/spec/models/serverless/domain_cluster_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Serverless::DomainCluster do +describe ::Serverless::DomainCluster do subject { create(:serverless_domain_cluster) } describe 'validations' do @@ -46,4 +46,8 @@ describe Serverless::DomainCluster do end end end + + describe 'domain' do + it { is_expected.to respond_to(:domain) } + end end diff --git a/spec/models/serverless/function_spec.rb b/spec/models/serverless/function_spec.rb index 1854d5f9415..810d4409a34 100644 --- a/spec/models/serverless/function_spec.rb +++ b/spec/models/serverless/function_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Serverless::Function do +describe ::Serverless::Function do let(:project) { create(:project) } let(:func) { described_class.new(project, 'test', 'test-ns') } diff --git a/spec/requests/self_monitoring_project_spec.rb b/spec/requests/self_monitoring_project_spec.rb index d562a34aec4..1da0be882d0 100644 --- a/spec/requests/self_monitoring_project_spec.rb +++ b/spec/requests/self_monitoring_project_spec.rb @@ -84,8 +84,8 @@ describe 'Self-Monitoring project requests' do let(:project) { build(:project) } before do - stub_application_setting(instance_administration_project_id: 1) - stub_application_setting(instance_administration_project: project) + stub_application_setting(self_monitoring_project_id: 1) + stub_application_setting(self_monitoring_project: project) end it 'does not need job_id' do @@ -169,7 +169,7 @@ describe 'Self-Monitoring project requests' do .with(job_id) .and_return(true) - stub_application_setting(instance_administration_project_id: 1) + stub_application_setting(self_monitoring_project_id: 1) end it_behaves_like 'sets polling header and returns accepted' do @@ -179,7 +179,7 @@ describe 'Self-Monitoring project requests' do context 'when self-monitoring project exists and job does not exist' do before do - stub_application_setting(instance_administration_project_id: 1) + stub_application_setting(self_monitoring_project_id: 1) end it 'returns bad_request' do diff --git a/spec/support/shared_examples/requests/self_monitoring_shared_examples.rb b/spec/support/shared_examples/requests/self_monitoring_shared_examples.rb index 949aa079435..f6cb2555450 100644 --- a/spec/support/shared_examples/requests/self_monitoring_shared_examples.rb +++ b/spec/support/shared_examples/requests/self_monitoring_shared_examples.rb @@ -12,7 +12,7 @@ RSpec.shared_examples 'not accessible if feature flag is disabled' do expect(response).to have_gitlab_http_status(:not_implemented) expect(json_response).to eq( 'message' => _('Self-monitoring is not enabled on this GitLab server, contact your administrator.'), - 'documentation_url' => help_page_path('administration/monitoring/gitlab_instance_administration_project/index') + 'documentation_url' => help_page_path('administration/monitoring/gitlab_self_monitoring_project/index') ) end end diff --git a/spec/tasks/gitlab/seed/group_seed_rake_spec.rb b/spec/tasks/gitlab/seed/group_seed_rake_spec.rb deleted file mode 100644 index ecf4e9575ab..00000000000 --- a/spec/tasks/gitlab/seed/group_seed_rake_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -require 'rake_helper' - -describe 'gitlab:seed:group_seed rake task' do - let(:username) { 'group_seed' } - let!(:user) { create(:user, username: username) } - let(:task_params) { [2, username] } - - before do - Rake.application.rake_require('tasks/gitlab/seed/group_seed') - end - - subject { run_rake_task('gitlab:seed:group_seed', task_params) } - - it 'performs group seed successfully' do - expect { subject }.not_to raise_error - - group = user.groups.first - - expect(user.groups.count).to be 3 - expect(group.projects.count).to be 2 - expect(group.members.count).to be 3 - expect(group.milestones.count).to be 2 - end -end |