From bc78ae6985ee37f9ac2ffc2dbf6f445078d16038 Mon Sep 17 00:00:00 2001 From: Tiago Botelho Date: Mon, 22 Jan 2018 18:10:56 +0000 Subject: Add specs --- lib/api/helpers/internal_helpers.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'lib/api/helpers/internal_helpers.rb') 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 -- cgit v1.2.1