Permalink
Browse files

adding User-Agent

  • Loading branch information...
pxlpnk committed Apr 29, 2013
1 parent 11720f8 commit feef7ad572edfa46b8e1918542e875c99fc4a96b
Showing with 5 additions and 4 deletions.
  1. +2 −2 lib/kraken-build/github-api.rb
  2. +3 −2 spec/lib/github_api_spec.rb
@@ -5,13 +5,13 @@ def initialize(config)
@oauth_token = config[:token]
@owner = config[:owner]
@repository = config[:repository]
-
+ @headers = {:headers => {"User-Agent" => "Kraken-Build"}}
self.class.base_uri "https://api.github.com"
end
def get_branches(options = {})
+ options.merge!(@headers)
response = self.class.get("/repos/#{@owner}/#{@repository}/branches?access_token=#{@oauth_token}", options)
response.map{|branch| branch["name"]}
end
-
end
@@ -5,7 +5,8 @@
before(:each) do
@options = {:token => '1234',
:owner => "FooBert",
- :repository => "uber-repo"
+ :repository => "uber-repo",
+ :headers => {"User-Agent" => "Kraken-Build"}
}
@api = GithubApi.new(@options)
@@ -15,7 +16,7 @@
response = []
response << {"name" => "foo"}
response << {"name" => "bar"}
- @api.class.should_receive(:get).with("/repos/#{@options[:owner]}/#{@options[:repository]}/branches?access_token=#{@options[:token]}",{}).and_return(response)
+ @api.class.should_receive(:get).with("/repos/#{@options[:owner]}/#{@options[:repository]}/branches?access_token=#{@options[:token]}", :headers => @options[:headers]).and_return(response)
branches = @api.get_branches
branches.should include "foo"

0 comments on commit feef7ad

Please sign in to comment.