diff --git a/docs/test_pilot b/docs/test_pilot new file mode 100644 index 000000000..16870b901 --- /dev/null +++ b/docs/test_pilot @@ -0,0 +1,27 @@ +TestPilot CI +====== + +TestPilot CI is a fully managed distributed Continuous Integration and Deployment Service +for Ruby, Node.js, Clojure, Java, Python, and Scala applications. + +Install Notes +------------- + + 1. Create an account at http://testpilot.me + 2. Authorize TestPilot to connect with your Github account. + 3. After your repositories have been synced, activate the repository you want to test. + TestPilot will automatically add necessary token above for your project, alternatively you can + find the token under your account page at http://testpilot.me/my/account + + 4. Check the "Active" checkbox and click "Update Settings". + 5. Push some changes to this repository and TestPilot will automatically start your build process. + 6. You should receive an email from TestPilot once the build has completed + +For more details about TestPilot, go to http://testpilot.me + +Developer Notes +--------------- + +data + - token + diff --git a/services/talker.rb b/services/talker.rb index af46ff3e5..716f6c24d 100644 --- a/services/talker.rb +++ b/services/talker.rb @@ -12,8 +12,8 @@ def receive_push http.headers["X-Talker-Token"] = token http.url_prefix = data['url'] - if data['digest'].to_i == 1 and commits.size > 1 - http_post 'messages.json', :message => "#{summary_message} – #{summary_url}" + if (data['digest'].to_i == 1 and commits.size > 1) + http_post 'messages.json', :message => "#{summary_message} - #{summary_url}" else http_post 'messages.json', :message => "#{pusher_name} pushed the following commits:" commit_messages.each do |message| diff --git a/services/test_pilot.rb b/services/test_pilot.rb new file mode 100644 index 000000000..d145e8a86 --- /dev/null +++ b/services/test_pilot.rb @@ -0,0 +1,26 @@ +class Service::TestPilot < Service + string :token + + def receive_push + http.ssl[:verify] = false + http.params.merge!(authentication_param) + http_post test_pilot_url, :payload => payload.to_json + end + + def test_pilot_url + "http://testpilot.me/callbacks/github" + end + + def token + data['token'].to_s.strip + end + + def authentication_param + if token.empty? + raise_config_error "Needs a token" + end + + {:token => token} + end +end + diff --git a/test/test_pilot_test.rb b/test/test_pilot_test.rb new file mode 100644 index 000000000..00b4f4153 --- /dev/null +++ b/test/test_pilot_test.rb @@ -0,0 +1,53 @@ +require File.expand_path('../helper', __FILE__) + +class TestPilotTest < Service::TestCase + def setup + @stubs = Faraday::Adapter::Test::Stubs.new + @svc = service(data, payload) + end + + def service(*args) + super Service::TestPilot, *args + end + + def data + { + 'token' => 'TOKEN' + } + end + + def test_reads_token_from_data + assert_equal "TOKEN", @svc.token + end + + def test_constructs_post_receive_url + assert_equal 'http://testpilot.me/callbacks/github', + @svc.test_pilot_url + end + + def test_posts_payload + @stubs.post '/callbacks/github' do |env| + assert_equal env[:params]['token'], @svc.token + assert_equal payload, JSON.parse(Rack::Utils.parse_query(env[:body])['payload']) + end + @svc.receive_push + end + + def test_it_raises_an_error_if_no_token_is_supplied + data = {'token' => ''} + svc = service(data, payload) + assert_raises Service::ConfigurationError do + svc.receive_push + end + end + + def test_strips_whitespace_from_form_values + data = { + 'token' => 'TOKEN ' + } + + svc = service(data, payload) + assert_equal 'TOKEN', svc.token + end +end +