Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

change payload

  • Loading branch information...
commit 95cd5a7e5c9cc6403b147bb9b19c2d1636f75884 1 parent b4aeb73
@hostalerye hostalerye authored
Showing with 15 additions and 5 deletions.
  1. +6 −5 services/hubci.rb
  2. +9 −0 test/hubci_test.rb
View
11 services/hubci.rb
@@ -3,23 +3,24 @@ class Service::HubCI < Service
def receive_push
http.ssl[:verify] = false
- http_post hubci_url, :commits=>payload['commits'].to_json
+ http.headers['Content-Type'] = 'application/json'
+ http_post hubci_url, {:commits => payload['commits']}.to_json
end
def hubci_url
- "http://hub.ci/repository/"+repoOwner+"/"+repoName+"/onCommit/"+token
+ "http://hub.ci/repository/#{repoOwner}/#{repoName}/onCommit/#{token}"
end
def repoName
- payload['repository']['name'].strip
+ payload['repository']['name']
end
def repoOwner
- payload['repository']['owner']['name'].strip
+ payload['repository']['owner']['name']
end
def token
- data['token'].strip
+ data['token'].to_s.strip
end
end
View
9 test/hubci_test.rb
@@ -24,6 +24,15 @@ def test_strips_whitespace_from_form_values
assert_equal '5373dd4a3648b88fa9acb8e46ebc188a', svc.token
end
+ def test_pull_request_payload
+ @svc = service(data, payload)
+ @stubs.post '/repository/mojombo/grit/onCommit/5373dd4a3648b88fa9acb8e46ebc188a' do |env|
+ assert_equal 'application/json', env[:request_headers]['Content-Type']
+ assert_equal payload['commits'], JSON.parse(env[:body])['commits']
+ end
+ @svc.receive_push
+ end
+
def service(*args)
super Service::HubCI, *args
end
Please sign in to comment.
Something went wrong with that request. Please try again.