Skip to content

Commit

Permalink
Merge pull request github#354 from appharbor/update-appharbor-service
Browse files Browse the repository at this point in the history
Update appharbor service
  • Loading branch information
technoweenie committed Jun 18, 2012
2 parents 6ba2343 + fc72366 commit 7827221
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions services/appharbor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def receive_push

def post_appharbor_message(slug, token)
return unless commit = distinct_commits.last
create_build_url = "https://appharbor.com/application/#{slug}/build?authorization=#{token}"
create_build_url = "https://appharbor.com/applications/#{slug}/builds"

appharbor_message = {
:branches => {
Expand All @@ -31,6 +31,9 @@ def post_appharbor_message(slug, token)
}
}

http_post create_build_url, appharbor_message.to_json, 'Accept' => 'application/json'
http.headers['Accept'] = 'application/json'
http.headers['Authorization'] = "BEARER #{token}"

http_post create_build_url, appharbor_message.to_json
end
end
4 changes: 2 additions & 2 deletions test/appharbor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def service(*args)

def test_push(application_slugs, token)
application_slugs.split(",").each do |slug|
@stubs.post "/application/#{slug}/build" do |env|
@stubs.post "/applications/#{slug}/builds" do |env|
verify_appharbor_payload(token, env)
end
end
Expand All @@ -33,7 +33,7 @@ def test_push(application_slugs, token)
end

def verify_appharbor_payload(token, env)
assert_equal token, env[:params]['authorization']
assert_equal "BEARER #{token}", env[:request_headers]['authorization']
assert_equal 'application/json', env[:request_headers]['accept']

branches = JSON.parse(env[:body])['branches']
Expand Down

0 comments on commit 7827221

Please sign in to comment.