diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 03:11:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 03:11:06 +0300 |
commit | 96740a3316f0846e7092dbd9c575f22a0db09845 (patch) | |
tree | 2b85d9f8bf6fbab612ebb50541f3a453e452c751 /spec | |
parent | 98f1353fcd07e45ef995c3cee14b659711a63221 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
16 files changed, 79 insertions, 90 deletions
diff --git a/spec/factories/namespaces.rb b/spec/factories/namespaces.rb index f4b57369678..957ec88420d 100644 --- a/spec/factories/namespaces.rb +++ b/spec/factories/namespaces.rb @@ -5,22 +5,7 @@ FactoryBot.define do sequence(:name) { |n| "namespace#{n}" } path { name.downcase.gsub(/\s/, '_') } - # This is a workaround to avoid the user creating another namespace via - # User#ensure_namespace_correct. We should try to remove it and then - # we could remove this workaround - association :owner, factory: :user, strategy: :build - before(:create) do |namespace| - owner = namespace.owner - - if owner - # We're changing the username here because we want to keep our path, - # and User#ensure_namespace_correct would change the path based on - # username, so we're forced to do this otherwise we'll need to change - # a lot of existing tests. - owner.username = namespace.path - owner.namespace = namespace - end - end + owner { association(:user, strategy: :build, namespace: instance, username: path) } trait :with_aggregation_schedule do after(:create) do |namespace| diff --git a/spec/features/populate_new_pipeline_vars_with_params_spec.rb b/spec/features/populate_new_pipeline_vars_with_params_spec.rb index 37fea5331a3..937f99558ad 100644 --- a/spec/features/populate_new_pipeline_vars_with_params_spec.rb +++ b/spec/features/populate_new_pipeline_vars_with_params_spec.rb @@ -8,7 +8,6 @@ RSpec.describe "Populate new pipeline CI variables with url params", :js do let(:page_path) { new_project_pipeline_path(project) } before do - stub_feature_flags(new_pipeline_form: false) sign_in(user) project.add_maintainer(user) @@ -16,18 +15,18 @@ RSpec.describe "Populate new pipeline CI variables with url params", :js do end it "var[key1]=value1 populates env_var variable correctly" do - page.within('.ci-variable-list .js-row:nth-child(1)') do - expect(find('.js-ci-variable-input-variable-type').value).to eq('env_var') - expect(find('.js-ci-variable-input-key').value).to eq('key1') - expect(find('.js-ci-variable-input-value').text).to eq('value1') + page.within(all("[data-testid='ci-variable-row']")[0]) do + expect(find("[data-testid='pipeline-form-ci-variable-type']").value).to eq('env_var') + expect(find("[data-testid='pipeline-form-ci-variable-key']").value).to eq('key1') + expect(find("[data-testid='pipeline-form-ci-variable-value']").value).to eq('value1') end end it "file_var[key2]=value2 populates file variable correctly" do - page.within('.ci-variable-list .js-row:nth-child(2)') do - expect(find('.js-ci-variable-input-variable-type').value).to eq('file') - expect(find('.js-ci-variable-input-key').value).to eq('key2') - expect(find('.js-ci-variable-input-value').text).to eq('value2') + page.within(all("[data-testid='ci-variable-row']")[1]) do + expect(find("[data-testid='pipeline-form-ci-variable-type']").value).to eq('file') + expect(find("[data-testid='pipeline-form-ci-variable-key']").value).to eq('key2') + expect(find("[data-testid='pipeline-form-ci-variable-value']").value).to eq('value2') end end end diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index e375bc10dbf..0ffb6d14cb3 100644 --- a/spec/features/projects/pipelines/pipelines_spec.rb +++ b/spec/features/projects/pipelines/pipelines_spec.rb @@ -657,26 +657,28 @@ RSpec.describe 'Pipelines', :js do let(:project) { create(:project, :repository) } before do - stub_feature_flags(new_pipeline_form: false) visit new_project_pipeline_path(project) end context 'for valid commit', :js do before do click_button project.default_branch + wait_for_requests - page.within '.dropdown-menu' do - click_link 'master' - end + find('p', text: 'master').click + wait_for_requests end - context 'with gitlab-ci.yml' do + context 'with gitlab-ci.yml', :js do before do stub_ci_pipeline_to_return_yaml_file end it 'creates a new pipeline' do - expect { click_on 'Run pipeline' } + expect do + click_on 'Run pipeline' + wait_for_requests + end .to change { Ci::Pipeline.count }.by(1) expect(Ci::Pipeline.last).to be_web @@ -684,12 +686,15 @@ RSpec.describe 'Pipelines', :js do context 'when variables are specified' do it 'creates a new pipeline with variables' do - page.within '.ci-variable-row-body' do - fill_in "Input variable key", with: "key_name" - fill_in "Input variable value", with: "value" + page.within(find("[data-testid='ci-variable-row']")) do + find("[data-testid='pipeline-form-ci-variable-key']").set('key_name') + find("[data-testid='pipeline-form-ci-variable-value']").set('value') end - expect { click_on 'Run pipeline' } + expect do + click_on 'Run pipeline' + wait_for_requests + end .to change { Ci::Pipeline.count }.by(1) expect(Ci::Pipeline.last.variables.map { |var| var.slice(:key, :secret_value) }) @@ -701,19 +706,17 @@ RSpec.describe 'Pipelines', :js do context 'without gitlab-ci.yml' do before do click_on 'Run pipeline' + wait_for_requests end it { expect(page).to have_content('Missing CI config file') } it 'creates a pipeline after first request failed and a valid gitlab-ci.yml file is available when trying again' do - click_button project.default_branch - stub_ci_pipeline_to_return_yaml_file - page.within '.dropdown-menu' do - click_link 'master' + expect do + click_on 'Run pipeline' + wait_for_requests end - - expect { click_on 'Run pipeline' } .to change { Ci::Pipeline.count }.by(1) end end @@ -760,14 +763,13 @@ RSpec.describe 'Pipelines', :js do let(:project) { create(:project, :repository) } before do - stub_feature_flags(new_pipeline_form: false) visit new_project_pipeline_path(project) end describe 'new pipeline page' do it 'has field to add a new pipeline' do - expect(page).to have_selector('.js-branch-select') - expect(find('.js-branch-select')).to have_content project.default_branch + expect(page).to have_selector('[data-testid="ref-select"]') + expect(find('[data-testid="ref-select"]')).to have_content project.default_branch expect(page).to have_content('Run for') end end @@ -776,10 +778,10 @@ RSpec.describe 'Pipelines', :js do it 'shows filtered pipelines', :js do click_button project.default_branch - page.within '.dropdown-menu' do - find('.dropdown-input-field').native.send_keys('fix') + page.within '[data-testid="ref-select"]' do + find('[data-testid="search-refs"]').native.send_keys('fix') - page.within '.dropdown-content' do + page.within '.gl-new-dropdown-contents' do expect(page).to have_content('fix') end end diff --git a/spec/frontend/boards/stores/actions_spec.js b/spec/frontend/boards/stores/actions_spec.js index 460e77a3f03..e0224dac736 100644 --- a/spec/frontend/boards/stores/actions_spec.js +++ b/spec/frontend/boards/stores/actions_spec.js @@ -66,20 +66,32 @@ describe('setInitialBoardData', () => { }); describe('setFilters', () => { - it('should commit mutation SET_FILTERS', (done) => { + it.each([ + [ + 'with correct filters as payload', + { + filters: { labelName: 'label' }, + updatedFilters: { labelName: 'label', not: {} }, + }, + ], + [ + 'and updates assigneeWildcardId', + { + filters: { assigneeId: 'None' }, + updatedFilters: { assigneeWildcardId: 'NONE', not: {} }, + }, + ], + ])('should commit mutation SET_FILTERS %s', (_, { filters, updatedFilters }) => { const state = { filters: {}, }; - const filters = { labelName: 'label' }; - testAction( actions.setFilters, filters, state, - [{ type: types.SET_FILTERS, payload: { ...filters, not: {} } }], + [{ type: types.SET_FILTERS, payload: updatedFilters }], [], - done, ); }); }); diff --git a/spec/lib/gitlab/database/partitioning_migration_helpers/foreign_key_helpers_spec.rb b/spec/lib/gitlab/database/partitioning_migration_helpers/foreign_key_helpers_spec.rb index 93dbd9d7c30..83f2436043c 100644 --- a/spec/lib/gitlab/database/partitioning_migration_helpers/foreign_key_helpers_spec.rb +++ b/spec/lib/gitlab/database/partitioning_migration_helpers/foreign_key_helpers_spec.rb @@ -10,6 +10,7 @@ RSpec.describe Gitlab::Database::PartitioningMigrationHelpers::ForeignKeyHelpers end let_it_be(:connection) { ActiveRecord::Base.connection } + let(:referenced_table) { :issues } let(:function_name) { '_test_partitioned_foreign_keys_function' } let(:trigger_name) { '_test_partitioned_foreign_keys_trigger' } diff --git a/spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb b/spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb index 5b2a29d1d2d..79ddb450d7a 100644 --- a/spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb +++ b/spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Gitlab::Database::PartitioningMigrationHelpers::TableManagementHe end let_it_be(:connection) { ActiveRecord::Base.connection } + let(:source_table) { :_test_original_table } let(:partitioned_table) { '_test_migration_partitioned_table' } let(:function_name) { '_test_migration_function_name' } diff --git a/spec/lib/gitlab/repository_cache_spec.rb b/spec/lib/gitlab/repository_cache_spec.rb index 80285a6c732..3277135246d 100644 --- a/spec/lib/gitlab/repository_cache_spec.rb +++ b/spec/lib/gitlab/repository_cache_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Gitlab::RepositoryCache do let_it_be(:project) { create(:project) } + let(:backend) { double('backend').as_null_object } let(:repository) { project.repository } let(:namespace) { "#{repository.full_path}:#{project.id}" } @@ -38,6 +39,7 @@ RSpec.describe Gitlab::RepositoryCache do describe 'personal snippet repository' do let_it_be(:personal_snippet) { create(:personal_snippet) } + let(:namespace) { repository.full_path } it_behaves_like 'cache_key examples' do diff --git a/spec/lib/gitlab/repository_hash_cache_spec.rb b/spec/lib/gitlab/repository_hash_cache_spec.rb index 9b4ca3f9dca..6b52c315a70 100644 --- a/spec/lib/gitlab/repository_hash_cache_spec.rb +++ b/spec/lib/gitlab/repository_hash_cache_spec.rb @@ -4,6 +4,7 @@ require "spec_helper" RSpec.describe Gitlab::RepositoryHashCache, :clean_gitlab_redis_cache do let_it_be(:project) { create(:project) } + let(:repository) { project.repository } let(:namespace) { "#{repository.full_path}:#{project.id}" } let(:cache) { described_class.new(repository) } diff --git a/spec/lib/gitlab/repository_set_cache_spec.rb b/spec/lib/gitlab/repository_set_cache_spec.rb index eaecbb0233d..881591ae805 100644 --- a/spec/lib/gitlab/repository_set_cache_spec.rb +++ b/spec/lib/gitlab/repository_set_cache_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Gitlab::RepositorySetCache, :clean_gitlab_redis_cache do let_it_be(:project) { create(:project) } + let(:repository) { project.repository } let(:namespace) { "#{repository.full_path}:#{project.id}" } let(:cache) { described_class.new(repository) } @@ -34,6 +35,7 @@ RSpec.describe Gitlab::RepositorySetCache, :clean_gitlab_redis_cache do describe 'personal snippet repository' do let_it_be(:personal_snippet) { create(:personal_snippet) } + let(:namespace) { repository.full_path } it_behaves_like 'cache_key examples' do diff --git a/spec/lib/gitlab/repository_size_checker_spec.rb b/spec/lib/gitlab/repository_size_checker_spec.rb index 20c08da6c54..559f5fa66c6 100644 --- a/spec/lib/gitlab/repository_size_checker_spec.rb +++ b/spec/lib/gitlab/repository_size_checker_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Gitlab::RepositorySizeChecker do let_it_be(:namespace) { nil } + let(:current_size) { 0 } let(:limit) { 50 } let(:enabled) { true } diff --git a/spec/lib/gitlab/repository_size_error_message_spec.rb b/spec/lib/gitlab/repository_size_error_message_spec.rb index 78504d201d4..633ec41ab00 100644 --- a/spec/lib/gitlab/repository_size_error_message_spec.rb +++ b/spec/lib/gitlab/repository_size_error_message_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Gitlab::RepositorySizeErrorMessage do let_it_be(:namespace) { build(:namespace) } + let(:checker) do Gitlab::RepositorySizeChecker.new( current_size_proc: -> { 15.megabytes }, diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index 96ecc9836d4..ad3ff1598df 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -141,7 +141,7 @@ RSpec.describe Namespace do end it 'allows updating other attributes for existing record' do - namespace = build(:namespace, path: 'j') + namespace = build(:namespace, path: 'j', owner: create(:user)) namespace.save(validate: false) namespace.reload diff --git a/spec/models/project_services/slack_service_spec.rb b/spec/models/project_services/slack_service_spec.rb index 688a59fcf09..2dd683bd44a 100644 --- a/spec/models/project_services/slack_service_spec.rb +++ b/spec/models/project_services/slack_service_spec.rb @@ -65,10 +65,16 @@ RSpec.describe SlackService do end context 'wiki_page notification' do - let_it_be(:wiki_page) { create(:wiki_page, wiki: project.wiki, message: 'user created page: Awesome wiki_page') } + let(:wiki_page) { create(:wiki_page, wiki: project.wiki, message: 'user created page: Awesome wiki_page') } let(:data) { Gitlab::DataBuilder::WikiPage.build(wiki_page, user, 'create') } + before do + # Skip this method that is not relevant to this test to prevent having + # to update project which is frozen + allow(project.wiki).to receive(:after_wiki_activity) + end + it_behaves_like 'increases the usage data counter', 'i_ecosystem_slack_service_wiki_page_notification' end diff --git a/spec/support/factory_default.rb b/spec/support/factory_default.rb index e116c28f132..31af022f6c0 100644 --- a/spec/support/factory_default.rb +++ b/spec/support/factory_default.rb @@ -1,5 +1,17 @@ # frozen_string_literal: true +module Gitlab + module FreezeFactoryDefault + def set_factory_default(name, obj, preserve_traits: nil) + obj.freeze unless obj.frozen? + + super + end + end +end + +TestProf::FactoryDefault::DefaultSyntax.prepend Gitlab::FreezeFactoryDefault + RSpec.configure do |config| config.after do |ex| TestProf::FactoryDefault.reset unless ex.metadata[:factory_default] == :keep diff --git a/spec/views/projects/pipelines/new.html.haml_spec.rb b/spec/views/projects/pipelines/new.html.haml_spec.rb deleted file mode 100644 index 9c5e46b6a17..00000000000 --- a/spec/views/projects/pipelines/new.html.haml_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'projects/pipelines/new' do - include Devise::Test::ControllerHelpers - let_it_be(:project) { create(:project, :repository) } - let(:pipeline) { create(:ci_pipeline, project: project) } - - before do - assign(:project, project) - assign(:pipeline, pipeline) - - stub_feature_flags(new_pipeline_form: false) - end - - describe 'warning messages' do - let(:warning_messages) do - [double(content: 'warning 1'), double(content: 'warning 2')] - end - - before do - allow(pipeline).to receive(:warning_messages).and_return(warning_messages) - end - - it 'displays the warnings' do - render - - expect(rendered).to have_css('div.bs-callout-warning') - expect(rendered).to have_content('warning 1') - expect(rendered).to have_content('warning 2') - end - end -end diff --git a/spec/views/projects/pipelines/show.html.haml_spec.rb b/spec/views/projects/pipelines/show.html.haml_spec.rb index b998023b40e..5b5c05527de 100644 --- a/spec/views/projects/pipelines/show.html.haml_spec.rb +++ b/spec/views/projects/pipelines/show.html.haml_spec.rb @@ -12,8 +12,6 @@ RSpec.describe 'projects/pipelines/show' do before do assign(:project, project) assign(:pipeline, presented_pipeline) - - stub_feature_flags(new_pipeline_form: false) end context 'when pipeline has errors' do |