summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-01-22 18:10:56 +0000
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-02-06 13:35:35 +0000
commitbc78ae6985ee37f9ac2ffc2dbf6f445078d16038 (patch)
tree1b53d4292becd29f1fe37a4fbb3e1562b3b80c40 /lib/api
parent32b2ff26011a5274bdb8a3dd41ad360a67c3148a (diff)
downloadgitlab-ce-bc78ae6985ee37f9ac2ffc2dbf6f445078d16038.tar.gz
Add specs
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/helpers/internal_helpers.rb17
-rw-r--r--lib/api/internal.rb9
2 files changed, 15 insertions, 11 deletions
diff --git a/lib/api/helpers/internal_helpers.rb b/lib/api/helpers/internal_helpers.rb
index c0fcae43638..fd568c5ef30 100644
--- a/lib/api/helpers/internal_helpers.rb
+++ b/lib/api/helpers/internal_helpers.rb
@@ -64,6 +64,15 @@ module API
false
end
+ def project_params
+ {
+ description: "",
+ path: Project.parse_project_id(project_match[:project_id]),
+ namespace_id: project_namespace&.id,
+ visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s
+ }
+ end
+
private
def project_path_regex
@@ -71,11 +80,13 @@ module API
end
def project_match
- @match ||= params[:project].match(project_path_regex).captures
+ @project_match ||= params[:project].match(project_path_regex)
end
- def namespace
- @namespace ||= Namespace.find_by_path_or_name(project_match[:namespace_id])
+ def project_namespace
+ return unless project_match
+
+ @project_namespace ||= Namespace.find_by_path_or_name(project_match[:namespace_id])
end
# rubocop:disable Gitlab/ModuleWithInstanceVariables
diff --git a/lib/api/internal.rb b/lib/api/internal.rb
index f641ef457a3..b7475af2044 100644
--- a/lib/api/internal.rb
+++ b/lib/api/internal.rb
@@ -43,7 +43,7 @@ module API
access_checker_klass = wiki? ? Gitlab::GitAccessWiki : Gitlab::GitAccess
access_checker = access_checker_klass
- .new(actor, project, protocol, authentication_abilities: ssh_authentication_abilities, redirected_path: redirected_path, target_namespace: namespace)
+ .new(actor, project, protocol, authentication_abilities: ssh_authentication_abilities, redirected_path: redirected_path, target_namespace: project_namespace)
begin
access_checker.check(params[:action], params[:changes])
@@ -52,13 +52,6 @@ module API
end
if user && project.blank? && receive_pack?
- project_params = {
- description: "",
- path: Project.parse_project_id(project_match[:project_name]),
- namespace_id: namespace&.id,
- visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s
- }
-
@project = ::Projects::CreateService.new(user, project_params).execute
if @project.saved?