Created
February 9, 2012 17:28
-
-
Save jorilallo/1781415 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Service::Grove < Service | |
| string :channel_token | |
| def receive_push | |
| raise_config_error "Missing channel token" if data['channel_token'].to_s.empty? | |
| token = data['channel_token'].to_s | |
| res = http_post "https://grove.io/api/services/github/#{token}", | |
| :payload => JSON.generate(payload) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require File.expand_path('../helper', __FILE__) | |
| class GroveTest < Service::TestCase | |
| def setup | |
| @stubs = Faraday::Adapter::Test::Stubs.new | |
| @channel_token = "test_token" | |
| end | |
| def test_push | |
| @stubs.post "/api/services/github/#{@channel_token}" do |env| | |
| assert_equal 'grove.io', env[:url].host | |
| [200, {}, ''] | |
| end | |
| svc = service( | |
| {'channel_token' => 'test_token'}, payload) | |
| svc.receive_push | |
| end | |
| def service(*args) | |
| super Service::Grove, *args | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment