diff --git a/docs/skydeskprojects b/docs/skydeskprojects new file mode 100644 index 000000000..8ba3000b2 --- /dev/null +++ b/docs/skydeskprojects @@ -0,0 +1,19 @@ +SkyDesk Projects Requirements: + +Log into the SkyDesk portal first. +SkyDesk Portal URL : https://www.skydesk.jp +Then access SkyDesk projects using https://projects.skydesk.jp. + +Project ID and Token is required for configuration which will be available under "Dashboard" --> "Project Settings" --> "Service Hooks". + +This service hook allows you to associate changeset(s) with bug(s) in SkyDesk Projects. To associate changeset(s) with bug(s) in SkyDeskProjects you will need to give the BUG ID in in your commit message. + +Syntax: `OPEN SQUARE BRACKET #BUGID CLOSE SQUARE BRACKET` followed by commit message + +Ex: `[#SDP-23] fixed the memory leak issue.` + +This will associate the changeset with bug with ID SDP-23. + +For more than one bugs, provide the BUG IDS separated by comma. + +Ex: `[#SDP-24,#SDP-25] UI alignment fix done.` diff --git a/lib/services/skydeskprojects.rb b/lib/services/skydeskprojects.rb new file mode 100644 index 000000000..6217d8280 --- /dev/null +++ b/lib/services/skydeskprojects.rb @@ -0,0 +1,30 @@ +# encoding: utf-8 +class Service::SkyDeskProjects < Service::HttpPost + string :project_id, :token + + white_list :project_id + + url "https://www.skydesk.jp" + logo_url "https://www.skydesk.jp/static/common/images/header/ci/ci_skydesk.gif" + + maintained_by :github => 'SkyDeskProjects' + + supported_by :web => 'www.skydesk.jp/en/contact/', + :email => 'support_projects@skydesk.jp' + + def receive_push + token = required_config_value('token') + pId = required_config_value('project_id') + #http.headers['Authorization'] = "Token #{token}" + + #url = "https://projects.skydesk.jp/serviceHook" + res = http_post "https://projects.skydesk.jp/serviceHook", + :pId => pId, + :authtoken => token, + :scope => "projectsapi", + :payload => generate_json(payload) + if res.status != 200 + raise_config_error + end + end +end diff --git a/test/skydeskprojects_test.rb b/test/skydeskprojects_test.rb new file mode 100644 index 000000000..e1c171b52 --- /dev/null +++ b/test/skydeskprojects_test.rb @@ -0,0 +1,30 @@ +require File.expand_path('../helper', __FILE__) + +class SkyDeskProjectsTest < Service::TestCase + def setup + @stubs = Faraday::Adapter::Test::Stubs.new + end + + def test_push + url = "/serviceHook" + data = { + "project_id" => "1234", + "token" => "a13d", + } + svc = service(data, payload) + @stubs.post url do |env| + assert_equal 'projects.skydesk.jp', env[:url].host + params = Faraday::Utils.parse_query(env[:body]) + assert_equal '1234', params['pId'] + assert_equal 'a13d', params['authtoken'] + assert_equal payload, JSON.parse(params['payload']) + [200, {}, ''] + + end + svc.receive + end + + def service(*args) + super Service::SkyDeskProjects, *args + end +end