Commit 4ccc844b1e12ec134ed55f907fd4a06d05260f07
1 parent
ea2965aa
Exists in
master
and in
1 other branch
update octokit, use api v3. closes #149
Showing
4 changed files
with
25 additions
and
25 deletions
Show diff stats
Gemfile
... | ... | @@ -14,7 +14,7 @@ gem 'mongoid_rails_migrations' |
14 | 14 | gem 'useragent', '~> 0.3.1' |
15 | 15 | gem 'pivotal-tracker' |
16 | 16 | gem 'ruby-fogbugz', :require => 'fogbugz' |
17 | -gem 'octokit', '0.6.4' | |
17 | +gem 'octokit', '~> 1.0.0' | |
18 | 18 | gem 'inherited_resources' |
19 | 19 | gem 'SystemTimer', :platform => :ruby_18 |
20 | 20 | gem 'hoptoad_notifier', "~> 2.4" | ... | ... |
Gemfile.lock
... | ... | @@ -59,14 +59,13 @@ GEM |
59 | 59 | addressable (~> 2.2) |
60 | 60 | multipart-post (~> 1.1) |
61 | 61 | rack (~> 1.1) |
62 | - faraday_middleware (0.7.0) | |
63 | - faraday (~> 0.7.3) | |
62 | + faraday_middleware (0.8.6) | |
63 | + faraday (>= 0.7.4, < 0.9) | |
64 | 64 | haml (3.1.5) |
65 | 65 | happymapper (0.4.0) |
66 | 66 | libxml-ruby (~> 2.0) |
67 | 67 | has_scope (0.5.1) |
68 | - hashie (1.0.0) | |
69 | - hike (1.2.1) | |
68 | + hashie (1.2.0) | |
70 | 69 | hoptoad_notifier (2.4.11) |
71 | 70 | activesupport |
72 | 71 | builder |
... | ... | @@ -104,16 +103,16 @@ GEM |
104 | 103 | bundler (>= 1.0.0) |
105 | 104 | rails (>= 3.0.0) |
106 | 105 | railties (>= 3.0.0) |
107 | - multi_json (1.0.4) | |
106 | + multi_json (1.1.0) | |
108 | 107 | multipart-post (1.1.5) |
109 | - nokogiri (1.5.2) | |
110 | - octokit (0.6.4) | |
111 | - addressable (~> 2.2.6) | |
112 | - faraday (~> 0.7.3) | |
113 | - faraday_middleware (~> 0.7.0.rc1) | |
114 | - hashie (~> 1.0.0) | |
115 | - multi_json (~> 1.0.2) | |
116 | - orm_adapter (0.0.7) | |
108 | + nokogiri (1.5.0) | |
109 | + octokit (1.0.0) | |
110 | + addressable (~> 2.2) | |
111 | + faraday (~> 0.7) | |
112 | + faraday_middleware (~> 0.8) | |
113 | + hashie (~> 1.2) | |
114 | + multi_json (~> 1.0) | |
115 | + orm_adapter (0.0.5) | |
117 | 116 | oruen_redmine_client (0.0.1) |
118 | 117 | activeresource (>= 2.3.0) |
119 | 118 | pivotal-tracker (0.5.4) |
... | ... | @@ -225,7 +224,7 @@ DEPENDENCIES |
225 | 224 | mongoid (~> 2.2.2) |
226 | 225 | mongoid_rails_migrations |
227 | 226 | nokogiri |
228 | - octokit (= 0.6.4) | |
227 | + octokit (~> 1.0.0) | |
229 | 228 | oruen_redmine_client |
230 | 229 | pivotal-tracker |
231 | 230 | rack-ssl-enforcer | ... | ... |
app/models/issue_trackers/github_issues_tracker.rb
... | ... | @@ -8,21 +8,21 @@ class IssueTrackers::GithubIssuesTracker < IssueTracker |
8 | 8 | [:username, { |
9 | 9 | :placeholder => "Your username on Github" |
10 | 10 | }], |
11 | - [:api_token, { | |
12 | - :placeholder => "Your Github API Token" | |
11 | + [:password, { | |
12 | + :placeholder => "Password for your account" | |
13 | 13 | }] |
14 | 14 | ] |
15 | 15 | |
16 | 16 | def check_params |
17 | 17 | if Fields.detect {|f| self[f[0]].blank? } |
18 | - errors.add :base, 'You must specify your Github repository, username and API Token' | |
18 | + errors.add :base, 'You must specify your Github repository, username and password' | |
19 | 19 | end |
20 | 20 | end |
21 | 21 | |
22 | 22 | def create_issue(err) |
23 | - client = Octokit::Client.new(:login => username, :token => api_token) | |
23 | + client = Octokit::Client.new(:login => username, :password => password) | |
24 | 24 | issue = client.create_issue(project_id, issue_title(err), body_template.result(binding).unpack('C*').pack('U*'), options = {}) |
25 | - err.update_attribute :issue_link, issue.html_url | |
25 | + err.update_attribute :issue_link, issue.issue.html_url | |
26 | 26 | end |
27 | 27 | |
28 | 28 | def body_template | ... | ... |
spec/models/issue_trackers/github_issues_tracker_spec.rb
... | ... | @@ -24,16 +24,17 @@ describe IssueTrackers::GithubIssuesTracker do |
24 | 24 | } |
25 | 25 | } |
26 | 26 | EOF |
27 | - stub_request(:post, "https://#{tracker.username}%2Ftoken:#{tracker.api_token}@github.com/api/v2/json/issues/open/#{tracker.project_id}"). | |
27 | + | |
28 | + stub_request(:post, "https://#{tracker.username}:#{tracker.password}@api.github.com/repos/#{tracker.project_id}/issues"). | |
28 | 29 | to_return(:status => 201, :headers => {'Location' => @issue_link}, :body => body ) |
29 | 30 | |
30 | 31 | problem.app.issue_tracker.create_issue(problem) |
31 | 32 | problem.reload |
32 | 33 | |
33 | - requested = have_requested(:post, "https://#{tracker.username}%2Ftoken:#{tracker.api_token}@github.com/api/v2/json/issues/open/#{tracker.project_id}") | |
34 | - WebMock.should requested.with(:headers => {'Content-Type' => 'application/x-www-form-urlencoded'}) | |
35 | - WebMock.should requested.with(:body => /title=%5Bproduction%5D%5Bfoo%23bar%5D%20FooError%3A%20Too%20Much%20Bar/) | |
36 | - WebMock.should requested.with(:body => /See%20this%20exception%20on%20Errbit/) | |
34 | + requested = have_requested(:post, "https://#{tracker.username}:#{tracker.password}@api.github.com/repos/#{tracker.project_id}/issues") | |
35 | + WebMock.should requested.with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) | |
36 | + WebMock.should requested.with(:body => /[production][foo#bar] FooError: Too Much Bar/) | |
37 | + WebMock.should requested.with(:body => /See this exception on Errbit/) | |
37 | 38 | |
38 | 39 | problem.issue_link.should == @issue_link |
39 | 40 | end | ... | ... |