diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-08 13:55:03 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-08 13:55:03 +0000 |
commit | cd1cc23153ed8115bc565f62b5a9f4eddc0942ca (patch) | |
tree | b379b2c66a70ffbb0d3baf71bdcc89eba8e434f2 /spec | |
parent | 755aa9544e3f5595cdc4f7a9d746758670d2393b (diff) | |
download | gitlab-ce-cd1cc23153ed8115bc565f62b5a9f4eddc0942ca.tar.gz |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec')
10 files changed, 128 insertions, 24 deletions
diff --git a/spec/features/merge_request/maintainer_edits_fork_spec.rb b/spec/features/merge_request/maintainer_edits_fork_spec.rb index 4db1633abe6..7573553b3fb 100644 --- a/spec/features/merge_request/maintainer_edits_fork_spec.rb +++ b/spec/features/merge_request/maintainer_edits_fork_spec.rb @@ -20,7 +20,7 @@ RSpec.describe 'a maintainer edits files on a source-branch of an MR from a fork end before do - stub_feature_flags(web_ide_default: false, single_mr_diff_view: false, code_navigation: false) + stub_feature_flags(web_ide_default: false, single_mr_diff_view: false) target_project.add_maintainer(user) sign_in(user) diff --git a/spec/features/projects/blobs/blob_show_spec.rb b/spec/features/projects/blobs/blob_show_spec.rb index c738c5ee5fa..cce656a1260 100644 --- a/spec/features/projects/blobs/blob_show_spec.rb +++ b/spec/features/projects/blobs/blob_show_spec.rb @@ -13,10 +13,6 @@ RSpec.describe 'File blob', :js do wait_for_requests end - before do - stub_feature_flags(code_navigation: false) - end - context 'Ruby file' do before do visit_blob('files/ruby/popen.rb') diff --git a/spec/features/projects/blobs/edit_spec.rb b/spec/features/projects/blobs/edit_spec.rb index 56bf31f24ba..a369bacc4dd 100644 --- a/spec/features/projects/blobs/edit_spec.rb +++ b/spec/features/projects/blobs/edit_spec.rb @@ -69,8 +69,6 @@ RSpec.describe 'Editing file blob', :js do context 'from blob file path' do before do - stub_feature_flags(code_navigation: false) - visit project_blob_path(project, tree_join(branch, file_path)) end diff --git a/spec/features/projects/blobs/user_creates_new_blob_in_new_project_spec.rb b/spec/features/projects/blobs/user_creates_new_blob_in_new_project_spec.rb index f54bceec2b3..d250a01c050 100644 --- a/spec/features/projects/blobs/user_creates_new_blob_in_new_project_spec.rb +++ b/spec/features/projects/blobs/user_creates_new_blob_in_new_project_spec.rb @@ -8,7 +8,6 @@ RSpec.describe 'User creates blob in new project', :js do shared_examples 'creating a file' do before do - stub_feature_flags(code_navigation: false) sign_in(user) visit project_path(project) end diff --git a/spec/features/projects/files/user_creates_files_spec.rb b/spec/features/projects/files/user_creates_files_spec.rb index 7d412730115..cc90f0cf294 100644 --- a/spec/features/projects/files/user_creates_files_spec.rb +++ b/spec/features/projects/files/user_creates_files_spec.rb @@ -14,7 +14,7 @@ RSpec.describe 'Projects > Files > User creates files', :js do let(:user) { create(:user) } before do - stub_feature_flags(web_ide_default: false, code_navigation: false) + stub_feature_flags(web_ide_default: false) project.add_maintainer(user) sign_in(user) diff --git a/spec/features/projects/files/user_deletes_files_spec.rb b/spec/features/projects/files/user_deletes_files_spec.rb index 70f125560e0..4df23b852ff 100644 --- a/spec/features/projects/files/user_deletes_files_spec.rb +++ b/spec/features/projects/files/user_deletes_files_spec.rb @@ -14,8 +14,6 @@ RSpec.describe 'Projects > Files > User deletes files', :js do let(:user) { create(:user) } before do - stub_feature_flags(code_navigation: false) - sign_in(user) end diff --git a/spec/features/projects/files/user_replaces_files_spec.rb b/spec/features/projects/files/user_replaces_files_spec.rb index 1d4085ef21c..b11cf732c95 100644 --- a/spec/features/projects/files/user_replaces_files_spec.rb +++ b/spec/features/projects/files/user_replaces_files_spec.rb @@ -16,8 +16,6 @@ RSpec.describe 'Projects > Files > User replaces files', :js do let(:user) { create(:user) } before do - stub_feature_flags(code_navigation: false) - sign_in(user) end diff --git a/spec/migrations/add_repository_storages_weighted_to_application_settings_spec.rb b/spec/migrations/add_repository_storages_weighted_to_application_settings_spec.rb new file mode 100644 index 00000000000..6c6c63d8614 --- /dev/null +++ b/spec/migrations/add_repository_storages_weighted_to_application_settings_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'migrate', '20200508203901_add_repository_storages_weighted_to_application_settings.rb') + +RSpec.describe AddRepositoryStoragesWeightedToApplicationSettings, :migration do + let(:storages) { { "foo" => {}, "baz" => {} } } + let(:application_settings) do + table(:application_settings).tap do |klass| + klass.class_eval do + serialize :repository_storages + end + end + end + + before do + allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) + end + + let(:application_setting) { application_settings.create! } + let(:repository_storages) { ["foo"] } + + it 'populates repository_storages_weighted properly' do + application_setting.repository_storages = repository_storages + application_setting.save! + + migrate! + + expect(application_settings.find(application_setting.id).repository_storages_weighted).to eq({ "foo" => 100, "baz" => 0 }) + end +end diff --git a/spec/migrations/reseed_repository_storages_weighted_spec.rb b/spec/migrations/reseed_repository_storages_weighted_spec.rb new file mode 100644 index 00000000000..8abad3c0d93 --- /dev/null +++ b/spec/migrations/reseed_repository_storages_weighted_spec.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'migrate', '20200509203901_reseed_repository_storages_weighted.rb') + +RSpec.describe ReseedRepositoryStoragesWeighted do + let(:storages) { { "foo" => {}, "baz" => {} } } + let(:application_settings) do + table(:application_settings).tap do |klass| + klass.class_eval do + serialize :repository_storages + end + end + end + + before do + allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) + end + + let(:repository_storages) { ["foo"] } + let!(:application_setting) { application_settings.create!(repository_storages: repository_storages) } + + context 'with empty repository_storages_weighted column' do + it 'populates repository_storages_weighted properly' do + migrate! + + expect(application_settings.find(application_setting.id).repository_storages_weighted).to eq({ "foo" => 100, "baz" => 0 }) + end + end + + context 'with already-populated repository_storages_weighted column' do + let(:existing_weights) { { "foo" => 100, "baz" => 50 } } + + it 'does not change repository_storages_weighted properly' do + application_setting.repository_storages_weighted = existing_weights + application_setting.save! + + migrate! + + expect(application_settings.find(application_setting.id).repository_storages_weighted).to eq(existing_weights) + end + end +end diff --git a/spec/migrations/update_routes_for_lost_and_found_group_and_orphaned_projects_spec.rb b/spec/migrations/update_routes_for_lost_and_found_group_and_orphaned_projects_spec.rb index 4cf096b9df6..103b6f114c4 100644 --- a/spec/migrations/update_routes_for_lost_and_found_group_and_orphaned_projects_spec.rb +++ b/spec/migrations/update_routes_for_lost_and_found_group_and_orphaned_projects_spec.rb @@ -62,8 +62,8 @@ describe UpdateRoutesForLostAndFoundGroupAndOrphanedProjects, :migration do source_type: 'Project', path: 'orphaned_project', name: 'orphaned_project', - created_at: Time.zone.now, - updated_at: Time.zone.now + created_at: Time.current, + updated_at: Time.current ) # Create another user named ghost which is not the Ghost User @@ -90,10 +90,10 @@ describe UpdateRoutesForLostAndFoundGroupAndOrphanedProjects, :migration do routes.create!( source_id: fake_ghost_user_namespace.id, source_type: 'Namespace', - path: 'Ghost User', - name: 'ghost1', - created_at: Time.zone.now, - updated_at: Time.zone.now + path: 'ghost1', + name: 'Ghost User', + created_at: Time.current, + updated_at: Time.current ) fake_lost_and_found_group = namespaces.create!( @@ -109,8 +109,8 @@ describe UpdateRoutesForLostAndFoundGroupAndOrphanedProjects, :migration do source_type: 'Namespace', path: described_class::User::LOST_AND_FOUND_GROUP, # same path as the lost-and-found group name: 'Lost and Found', - created_at: Time.zone.now, - updated_at: Time.zone.now + created_at: Time.current, + updated_at: Time.current ) members.create!( @@ -135,17 +135,58 @@ describe UpdateRoutesForLostAndFoundGroupAndOrphanedProjects, :migration do source_type: 'Project', path: "#{described_class::User::LOST_AND_FOUND_GROUP}/normal_project", name: 'Lost and Found / normal_project', - created_at: Time.zone.now, - updated_at: Time.zone.now + created_at: Time.current, + updated_at: Time.current ) + + # Add a project whose route conflicts with the ghost username + # and should force the data migration to pick a new Ghost username and path + ghost_project = projects.create!( + name: 'Ghost Project', + path: 'ghost', + visibility_level: 20, + archived: false, + namespace_id: fake_lost_and_found_group.id + ) + + routes.create!( + source_id: ghost_project.id, + source_type: 'Project', + path: 'ghost', + name: 'Ghost Project', + created_at: Time.current, + updated_at: Time.current + ) + end + + it 'fixes the ghost user username and namespace path' do + ghost_user = users.find_by(user_type: described_class::User::USER_TYPE_GHOST) + ghost_namespace = namespaces.find_by(owner_id: ghost_user.id) + + expect(ghost_user.username).to eq('ghost') + expect(ghost_namespace.path).to eq('ghost') + + disable_migrations_output { migrate! } + + ghost_user = users.find_by(user_type: described_class::User::USER_TYPE_GHOST) + ghost_namespace = namespaces.find_by(owner_id: ghost_user.id) + ghost_namespace_route = routes.find_by(source_id: ghost_namespace.id, source_type: 'Namespace') + + expect(ghost_user.username).to eq('ghost2') + expect(ghost_namespace.path).to eq('ghost2') + expect(ghost_namespace_route.path).to eq('ghost2') end it 'creates the route for the ghost user namespace' do - expect(routes.where(path: 'ghost').count).to eq(0) + expect(routes.where(path: 'ghost').count).to eq(1) + expect(routes.where(path: 'ghost1').count).to eq(1) + expect(routes.where(path: 'ghost2').count).to eq(0) disable_migrations_output { migrate! } expect(routes.where(path: 'ghost').count).to eq(1) + expect(routes.where(path: 'ghost1').count).to eq(1) + expect(routes.where(path: 'ghost2').count).to eq(1) end it 'fixes the path for the lost-and-found group by generating a unique one' do |