Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from reillyse/master
Browse files Browse the repository at this point in the history
Adding circleci services
  • Loading branch information
pbiggar committed Feb 9, 2013
2 parents fb77f5b + d349785 commit f921d5e
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/circleci
@@ -0,0 +1,13 @@
CircleCI continuous integration

[CircleCi](https://circleci.com) will add this hook automatically to projects which you test using CircleCi. To sign up, go to https://circleci.com, sign in, and start testing!

Install Notes
-------------

1. Sign up at https://circleci.com with your github credentials
2. Follow your repository
3. You're done!

For more details about CircleCI go to https://circleci.com

27 changes: 27 additions & 0 deletions lib/services/circleci.rb
@@ -0,0 +1,27 @@
class Service::Circleci < Service

url "https://circleci.com"
logo_url "https://circleci.com/favicon.ico"

maintained_by :github => 'circleci'
supported_by :web => 'https://circleci.com/about',
:email => 'sayhi@circleci.com'

default_events Service::ALL_EVENTS


def receive_event

http.headers['content-type'] = 'application/x-www-form-urlencoded'
http.params.merge!(:payload => JSON.generate(payload) , :event_type => JSON.generate({ :event_type => self.event }))
http_post circleci_url, payload.to_json

end


private

def circleci_url
"https://circleci.com/hooks/github"
end
end
119 changes: 119 additions & 0 deletions test/circleci_test.rb
@@ -0,0 +1,119 @@
require File.expand_path('../helper', __FILE__)

class CircleciTest < Service::TestCase


def setup
@stubs = Faraday::Adapter::Test::Stubs.new
end


# currently supported events

# commit_comment create delete download follow fork fork_apply gist gollum
# issue_comment issues member public pull_request push team_add watch
# pull_request_review_comment status

def test_commit_comment
post_to_service(:commit_comment)
end

def test_create
post_to_service(:create)
end

def test_delete
post_to_service(:delete)
end

def test_download
post_to_service(:download)
end

def test_follow
post_to_service(:follow)
end

def test_fork
post_to_service(:fork)
end

def test_fork_apply
post_to_service(:fork_apply)
end

def test_gist
post_to_service(:gist)
end

def test_gollum
post_to_service(:gollum)
end

def test_issue_comment
post_to_service(:issue_comment)
end

def test_issues
post_to_service(:issues)
end

def test_member
post_to_service(:member)
end

def test_public
post_to_service(:public)
end



def test_push
post_to_service(:push)
end


def test_team_add
post_to_service(:team_add)
end

def test_watch
post_to_service(:watch)
end

def test_pull_request_review_comment
post_to_service(:pull_request_review_comment)
end

def test_status
post_to_service(:status)
end

def test_supported_events
assert_equal Service::Circleci.supported_events.sort , Service::ALL_EVENTS.sort
end


private

def service(*args)
super Service::Circleci, *args
end

def post_to_service(event_name)
assert Service::ALL_EVENTS.include? event_name.to_s
svc = service(event_name, {'token' => 'abc'},payload)

@stubs.post "/hooks/github" do |env|
assert_match "https://circleci.com/hooks/github", env[:url].to_s
assert_match 'application/x-www-form-urlencoded', env[:request_headers]['content-type']
assert_equal payload, JSON.parse(env[:params]["payload"])
assert_equal event_name.to_s, JSON.parse(env[:params]["event_type"])["event_type"]
end

svc.receive_event

end

end

0 comments on commit f921d5e

Please sign in to comment.