summaryrefslogtreecommitdiff
path: root/spec/migrations
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2018-10-12 14:40:44 +0200
committerToon Claes <toon@gitlab.com>2018-11-27 22:48:54 +0100
commitffdb3f26e7f8f9b62fd32b52c30edf167c760793 (patch)
tree9f9db9b7a9caf354405a3cd297e6a437da12fa9a /spec/migrations
parent6c83c2d8b9305fe67fe31cf944c9d83cdbb00b74 (diff)
downloadgitlab-ce-ffdb3f26e7f8f9b62fd32b52c30edf167c760793.tar.gz
Migration to write fullpath in all repository configs
In https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16027 it was added to write `gitlab.fullpath` in the git config of all repositories. But this only writes them on move or migrate to hashed storage. This adds a migration that writes the fullpath to all the repositories. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/41776
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/backfill_store_project_full_path_in_repo_spec.rb70
1 files changed, 70 insertions, 0 deletions
diff --git a/spec/migrations/backfill_store_project_full_path_in_repo_spec.rb b/spec/migrations/backfill_store_project_full_path_in_repo_spec.rb
new file mode 100644
index 00000000000..f2651f8a02f
--- /dev/null
+++ b/spec/migrations/backfill_store_project_full_path_in_repo_spec.rb
@@ -0,0 +1,70 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+require Rails.root.join('db', 'post_migrate', '20181010133639_backfill_store_project_full_path_in_repo.rb')
+
+describe BackfillStoreProjectFullPathInRepo, :migration do
+ let(:namespaces) { table(:namespaces) }
+ let(:projects) { table(:projects) }
+ let(:group) { namespaces.create!(name: 'foo', path: 'foo') }
+ let(:subgroup) { namespaces.create!(name: 'bar', path: 'bar', parent_id: group.id) }
+
+ subject(:migration) { described_class.new }
+
+ describe '#up' do
+ shared_examples_for 'writes the full path to git config' do
+ it 'writes the git config' do
+ expect_any_instance_of(Gitlab::GitalyClient::RepositoryService)
+ .to receive(:set_config).with('gitlab.fullpath' => expected_path)
+
+ migration.up
+ end
+
+ context 'legacy storage' do
+ it 'finds the repository at the correct location' do
+ Project.find(project.id).create_repository
+
+ expect { migration.up }.not_to raise_error
+ end
+ end
+
+ context 'hashed storage' do
+ it 'finds the repository at the correct location' do
+ project.update_attribute(:storage_version, 1)
+
+ Project.find(project.id).create_repository
+
+ expect { migration.up }.not_to raise_error
+ end
+ end
+ end
+
+ context 'project in group' do
+ let!(:project) { projects.create!(namespace_id: group.id, name: 'baz', path: 'baz') }
+ let(:expected_path) { 'foo/baz' }
+
+ it_behaves_like 'writes the full path to git config'
+ end
+
+ context 'project in subgroup' do
+ let!(:project) { projects.create!(namespace_id: subgroup.id, name: 'baz', path: 'baz') }
+ let(:expected_path) { 'foo/bar/baz' }
+
+ it_behaves_like 'writes the full path to git config'
+ end
+ end
+
+ describe '#down' do
+ context 'project in group' do
+ let!(:project) { projects.create!(namespace_id: group.id, name: 'baz', path: 'baz') }
+
+ it 'deletes the gitlab full config value' do
+ expect_any_instance_of(Gitlab::GitalyClient::RepositoryService)
+ .to receive(:delete_config).with(['gitlab.fullpath'])
+
+ migration.down
+ end
+ end
+ end
+end