Skip to content

Instantly share code, notes, and snippets.

@rkh
Created July 30, 2012 16:23
Show Gist options
  • Save rkh/3208179 to your computer and use it in GitHub Desktop.
Save rkh/3208179 to your computer and use it in GitHub Desktop.
require 'travis/support'
Travis::Amqp.connect
def as(user, &block)
Travis::Github.authenticated(User.find_by_login(user), &block)
end
def test_pr(owner, repo_name, id)
repo = Repository.find_by_owner_name_and_name(owner, repo_name)
user = repo.users.first
payload = {
:action => :opened,
:repository => GH["repos/#{owner}/#{repo_name}"].to_hash,
:pull_request => GH["repos/#{owner}/#{repo_name}/pulls/#{id}"].to_hash
}
data = {
:type => 'pull_request',
:credentials => {
:login => user.login,
:token => user.tokens.first.token
},
:payload => payload.to_json,
:uuid => Travis.uuid.to_json
}
queue = Travis::Amqp::Publisher.builds('builds.requests')
queue.publish data, :type => 'request'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment