diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-03-31 14:37:21 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-03-31 14:37:21 +0300 |
commit | 91761b06851832be643258f390ea7593beacae16 (patch) | |
tree | e4b7819dd34b3dd5090342f0dfdf263dea20cf10 /app | |
parent | 2fdae52fd1048779a84770b39fe2961f31b1bd79 (diff) |
Add tests.
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/repositories_controller.rb | 6 | ||||
-rw-r--r-- | app/services/archive_repository_service.rb | 6 | ||||
-rw-r--r-- | app/workers/repository_archive_worker.rb | 1 |
3 files changed, 6 insertions, 7 deletions
diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb index 112365ba91a..96defb0c721 100644 --- a/app/controllers/projects/repositories_controller.rb +++ b/app/controllers/projects/repositories_controller.rb @@ -11,14 +11,10 @@ class Projects::RepositoriesController < Projects::ApplicationController end def archive - unless can?(current_user, :download_code, @project) - render_404 and return - end - begin file_path = ArchiveRepositoryService.new(@project, params[:ref], params[:format]).execute rescue - return render_404 + return head :not_found end if file_path diff --git a/app/services/archive_repository_service.rb b/app/services/archive_repository_service.rb index 40b0a64fb73..e1b41527d8d 100644 --- a/app/services/archive_repository_service.rb +++ b/app/services/archive_repository_service.rb @@ -6,7 +6,7 @@ class ArchiveRepositoryService @project, @ref, @format = project, ref, format.downcase end - def execute + def execute(options = {}) project.repository.clean_old_archives raise "No archive file path" unless file_path @@ -17,7 +17,7 @@ class ArchiveRepositoryService RepositoryArchiveWorker.perform_async(project.id, ref, format) end - archived = wait_until_archived + archived = wait_until_archived(options[:timeout] || 5.0) file_path if archived end @@ -45,6 +45,8 @@ class ArchiveRepositoryService end def wait_until_archived(timeout = 5.0) + return archived? if timeout == 0.0 + t1 = Time.now begin diff --git a/app/workers/repository_archive_worker.rb b/app/workers/repository_archive_worker.rb index 42ac77c588e..021c1139568 100644 --- a/app/workers/repository_archive_worker.rb +++ b/app/workers/repository_archive_worker.rb @@ -13,6 +13,7 @@ class RepositoryArchiveWorker repository.clean_old_archives + return unless file_path return if archived? || archiving? repository.archive_repo(ref, storage_path, format) |