summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-08-04 00:39:20 +0000
committerRobert Speicher <robert@gitlab.com>2016-08-04 00:39:20 +0000
commit532202a5278a622de874b9dfc1c4f7fe9ddf5ce4 (patch)
tree01c52630c9b20b42ada5fe454cb16e81a2962e32
parent8890376f0f72f713a7530bd7989e71442c69dc91 (diff)
parent443ae8c4e6682cd66eab0a2a7ec6ef913c0d684c (diff)
downloadgitlab-ce-532202a5278a622de874b9dfc1c4f7fe9ddf5ce4.tar.gz
Merge branch 'fix-project-destroy-skip-repo' into 'master'
Fix skip_repo parameter being ignored when destroying a namespace When destroying a namespace, the `skip_repo` parameter is supposed to prevent the repository directory from being destroyed and allow the namespace after_destroy hook to run. If the namespace fails to be deleted for some reason, we could be left with repositories that are deleted with existing projects. See merge request !5654
-rw-r--r--CHANGELOG1
-rw-r--r--app/workers/project_destroy_worker.rb2
-rw-r--r--spec/workers/project_destroy_worker_spec.rb24
3 files changed, 26 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 25911e02ec6..73812e16d6f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -52,6 +52,7 @@ v 8.11.0 (unreleased)
- Add commit stats in commit api. !5517 (dixpac)
- Add CI configuration button on project page
- Make error pages responsive (Takuya Noguchi)
+ - Fix skip_repo parameter being ignored when destroying a namespace
- Change requests_profiles resource constraint to catch virtually any file
- Reduce number of queries made for merge_requests/:id/diffs
- Sensible state specific default sort order for issues and merge requests !5453 (tomb0y)
diff --git a/app/workers/project_destroy_worker.rb b/app/workers/project_destroy_worker.rb
index b51c6a266c9..3062301a9b1 100644
--- a/app/workers/project_destroy_worker.rb
+++ b/app/workers/project_destroy_worker.rb
@@ -12,6 +12,6 @@ class ProjectDestroyWorker
user = User.find(user_id)
- ::Projects::DestroyService.new(project, user, params).execute
+ ::Projects::DestroyService.new(project, user, params.symbolize_keys).execute
end
end
diff --git a/spec/workers/project_destroy_worker_spec.rb b/spec/workers/project_destroy_worker_spec.rb
new file mode 100644
index 00000000000..1b910d9b91e
--- /dev/null
+++ b/spec/workers/project_destroy_worker_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe ProjectDestroyWorker do
+ let(:project) { create(:project) }
+ let(:path) { project.repository.path_to_repo }
+
+ subject { ProjectDestroyWorker.new }
+
+ describe "#perform" do
+ it "deletes the project" do
+ subject.perform(project.id, project.owner, {})
+
+ expect(Project.all).not_to include(project)
+ expect(Dir.exist?(path)).to be_falsey
+ end
+
+ it "deletes the project but skips repo deletion" do
+ subject.perform(project.id, project.owner, { "skip_repo" => true })
+
+ expect(Project.all).not_to include(project)
+ expect(Dir.exist?(path)).to be_truthy
+ end
+ end
+end