summaryrefslogtreecommitdiff
path: root/lib/api/helpers.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-09-02 07:23:40 +0000
committerDouwe Maan <douwe@gitlab.com>2015-09-02 07:23:40 +0000
commit6f19e8799e4c8233b01068bf6b5406b0ba1d1105 (patch)
tree14a7085fc1998bbb0d30b7d1e5dca71f6b599193 /lib/api/helpers.rb
parent308c6428aef2a46b0370a24d85a97b0e133283a8 (diff)
parent263abda3fd7ddfb826cd17ae88fb47d0e1d67fae (diff)
downloadgitlab-ce-6f19e8799e4c8233b01068bf6b5406b0ba1d1105.tar.gz
Merge branch 'drone-ci' into 'master'
Drone CI service https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/1184#note_1980652 /cc @DouweM See merge request !1215
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r--lib/api/helpers.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 1ebf9a1f022..76c9cc2e3a4 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -55,6 +55,32 @@ module API
end
end
+ def project_service
+ @project_service ||= begin
+ underscored_service = params[:service_slug].underscore
+
+ if Service.available_services_names.include?(underscored_service)
+ user_project.build_missing_services
+
+ service_method = "#{underscored_service}_service"
+
+ send_service(service_method)
+ end
+ end
+
+ @project_service || not_found!("Service")
+ end
+
+ def send_service(service_method)
+ user_project.send(service_method)
+ end
+
+ def service_attributes
+ @service_attributes ||= project_service.fields.inject([]) do |arr, hash|
+ arr << hash[:name].to_sym
+ end
+ end
+
def find_group(id)
begin
group = Group.find(id)