summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-03 15:15:46 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-03 15:15:46 +0200
commit7bab4817f76b5710f5dee3a1b5a6b308ae189355 (patch)
treeed3ea594b4741add2f3221ba00c5100b8c17b638 /spec
parent1edff53444ea493ee010a83220cf13ccb381b411 (diff)
parent58ab8a4a9d0e051cf6355c1b9a4d8dc13fc892cc (diff)
downloadgitlab-ce-7bab4817f76b5710f5dee3a1b5a6b308ae189355.tar.gz
Merge branch 'repo-remove' into fix-group-remove
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> Conflicts: spec/features/projects_spec.rb
Diffstat (limited to 'spec')
-rw-r--r--spec/features/projects_spec.rb7
-rw-r--r--spec/requests/api/projects_spec.rb9
-rw-r--r--spec/services/projects/destroy_service_spec.rb34
3 files changed, 36 insertions, 14 deletions
diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb
index 56523f6e1a8..f8eea70ec4a 100644
--- a/spec/features/projects_spec.rb
+++ b/spec/features/projects_spec.rb
@@ -47,13 +47,6 @@ feature 'Project' do
it 'should remove project' do
expect { remove_project }.to change {Project.count}.by(-1)
end
-
- it 'should delete the project from disk' do
- expect(GitlabShellWorker).to receive(:perform_async).
- with(:remove_repository, /#{project.path_with_namespace}/).twice
-
- remove_project
- end
end
def remove_project
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 46cd26eb927..dbfd72e5f19 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -57,14 +57,14 @@ describe API::API, api: true do
expect(json_response.first['name']).to eq(project.name)
expect(json_response.first['owner']['username']).to eq(user.username)
end
-
+
it 'should include the project labels as the tag_list' do
get api('/projects', user)
response.status.should == 200
json_response.should be_an Array
json_response.first.keys.should include('tag_list')
end
-
+
context 'and using search' do
it 'should return searched project' do
get api('/projects', user), { search: project.name }
@@ -792,11 +792,6 @@ describe API::API, api: true do
describe 'DELETE /projects/:id' do
context 'when authenticated as user' do
it 'should remove project' do
- expect(GitlabShellWorker).to(
- receive(:perform_async).with(:remove_repository,
- /#{project.path_with_namespace}/)
- ).twice
-
delete api("/projects/#{project.id}", user)
expect(response.status).to eq(200)
end
diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb
new file mode 100644
index 00000000000..cdf576cc0c1
--- /dev/null
+++ b/spec/services/projects/destroy_service_spec.rb
@@ -0,0 +1,34 @@
+require 'spec_helper'
+
+describe Projects::DestroyService do
+ let!(:user) { create(:user) }
+ let!(:project) { create(:project, namespace: user.namespace) }
+ let!(:path) { project.repository.path_to_repo }
+ let!(:remove_path) { path.sub(/\.git\Z/, "+#{project.id}+deleted.git") }
+
+ context 'Sidekiq inline' do
+ before do
+ # Run sidekiq immediatly to check that renamed repository will be removed
+ Sidekiq::Testing.inline! { destroy_project(project, user, {}) }
+ end
+
+ it { Project.all.should_not include(project) }
+ it { Dir.exists?(path).should be_falsey }
+ it { Dir.exists?(remove_path).should be_falsey }
+ end
+
+ context 'Sidekiq fake' do
+ before do
+ # Dont run sidekiq to check if renamed repository exists
+ Sidekiq::Testing.fake! { destroy_project(project, user, {}) }
+ end
+
+ it { Project.all.should_not include(project) }
+ it { Dir.exists?(path).should be_falsey }
+ it { Dir.exists?(remove_path).should be_truthy }
+ end
+
+ def destroy_project(project, user, params)
+ Projects::DestroyService.new(project, user, params).execute
+ end
+end