summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAndre Guedes <andrebsguedes@gmail.com>2017-02-22 11:19:23 -0300
committerAndre Guedes <andrebsguedes@gmail.com>2017-02-23 01:56:30 -0300
commitdb5b4b8b1a9b8aa07c8310dde53b7c3ed391bafd (patch)
tree99448c42fa45e9bc11ec0a218bcf07abff1abfce /app
parent8294756fc110fdb84036e4ae097940410a8ad6de (diff)
downloadgitlab-ce-db5b4b8b1a9b8aa07c8310dde53b7c3ed391bafd.tar.gz
Creates specs for destroy service and improves namespace container image query performance
Diffstat (limited to 'app')
-rw-r--r--app/models/namespace.rb2
-rw-r--r--app/services/container_images/destroy_service.rb26
-rw-r--r--app/views/admin/container_registry/show.html.haml2
3 files changed, 4 insertions, 26 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index c8e329044e0..a803be2e780 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -155,7 +155,7 @@ class Namespace < ActiveRecord::Base
end
def any_project_has_container_registry_images?
- projects.any? { |project| project.container_images.present? }
+ projects.joins(:container_images).any?
end
def send_update_instructions
diff --git a/app/services/container_images/destroy_service.rb b/app/services/container_images/destroy_service.rb
index c73b6cfefba..15dca227291 100644
--- a/app/services/container_images/destroy_service.rb
+++ b/app/services/container_images/destroy_service.rb
@@ -1,31 +1,9 @@
module ContainerImages
class DestroyService < BaseService
- class DestroyError < StandardError; end
-
def execute(container_image)
- @container_image = container_image
-
- return false unless can?(current_user, :remove_project, project)
-
- ContainerImage.transaction do
- container_image.destroy!
-
- unless remove_container_image_tags
- raise_error('Failed to remove container image tags. Please try again or contact administrator')
- end
- end
-
- true
- end
-
- private
-
- def raise_error(message)
- raise DestroyError.new(message)
- end
+ return false unless can?(current_user, :update_container_image, project)
- def remove_container_image_tags
- container_image.delete_tags
+ container_image.destroy!
end
end
end
diff --git a/app/views/admin/container_registry/show.html.haml b/app/views/admin/container_registry/show.html.haml
index 8803eddda69..ffaa7736d65 100644
--- a/app/views/admin/container_registry/show.html.haml
+++ b/app/views/admin/container_registry/show.html.haml
@@ -17,7 +17,7 @@
X-Registry-Token: [#{@access_token}]
%br
Access token is
- %code{ id: 'registry-token' } #{@access_token}
+ %code{ id: 'registry-token' }= @access_token
.bs-callout.clearfix
.pull-left