Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-12-21 20:31:30 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-12-24 20:39:51 +0300
commitd72b40423c6736fd24ef4371604897871a1b3acc (patch)
tree059e017d8115f4dbc3d74459133c30db97a03afd /spec/migrations
parent79ce691d71e8fcbd198f9c228bc7db1bfd2b6e03 (diff)
Rename projects with reserved path names
We cant have project with name 'project' or 'tree' anymore. This merge request containts a migration that will find and rename all projects using reserved names by adding N digit to the end of the name. Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/rename_reserved_project_names_spec.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/migrations/rename_reserved_project_names_spec.rb b/spec/migrations/rename_reserved_project_names_spec.rb
new file mode 100644
index 00000000000..66f68570b50
--- /dev/null
+++ b/spec/migrations/rename_reserved_project_names_spec.rb
@@ -0,0 +1,45 @@
+# encoding: utf-8
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20161221153951_rename_reserved_project_names.rb')
+
+describe RenameReservedProjectNames do
+ let(:migration) { described_class.new }
+ let!(:project) { create(:project) }
+
+ before do
+ project.path = 'projects'
+ project.save!(validate: false)
+ allow(Thread).to receive(:new).and_yield
+ end
+
+ describe '#up' do
+ context 'when project repository exists' do
+ before { project.create_repository }
+
+ context 'when no exception is raised' do
+ it 'renames project with reserved names' do
+ migration.up
+
+ expect(project.reload.path).to eq('projects0')
+ end
+ end
+
+ context 'when exception is raised during rename' do
+ before do
+ allow(project).to receive(:rename_repo).and_raise(StandardError)
+ end
+
+ it 'captures exception from project rename' do
+ expect { migration.up }.not_to raise_error
+ end
+ end
+ end
+
+ context 'when project repository does not exist' do
+ it 'does not raise error' do
+ expect { migration.up }.not_to raise_error
+ end
+ end
+ end
+end