Commit 41381ee285433dbaa95ecbd3a204edb6c1c1ff30
Exists in
master
and in
1 other branch
Merge branch 'update-octokit' of https://github.com/twinslash/errbit into twinslash-update-octokit
Conflicts: app/models/issue_trackers/github_issues_tracker.rb
Showing
4 changed files
with
25 additions
and
26 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
| ... | ... | @@ -70,14 +70,13 @@ GEM |
| 70 | 70 | addressable (~> 2.2) |
| 71 | 71 | multipart-post (~> 1.1) |
| 72 | 72 | rack (~> 1.1) |
| 73 | - faraday_middleware (0.7.0) | |
| 74 | - faraday (~> 0.7.3) | |
| 73 | + faraday_middleware (0.8.6) | |
| 74 | + faraday (>= 0.7.4, < 0.9) | |
| 75 | 75 | haml (3.1.5) |
| 76 | 76 | happymapper (0.4.0) |
| 77 | 77 | libxml-ruby (~> 2.0) |
| 78 | 78 | has_scope (0.5.1) |
| 79 | - hashie (1.0.0) | |
| 80 | - hike (1.2.1) | |
| 79 | + hashie (1.2.0) | |
| 81 | 80 | hoptoad_notifier (2.4.11) |
| 82 | 81 | activesupport |
| 83 | 82 | builder |
| ... | ... | @@ -116,16 +115,16 @@ GEM |
| 116 | 115 | bundler (>= 1.0.0) |
| 117 | 116 | rails (>= 3.0.0) |
| 118 | 117 | railties (>= 3.0.0) |
| 119 | - multi_json (1.0.4) | |
| 118 | + multi_json (1.1.0) | |
| 120 | 119 | multipart-post (1.1.5) |
| 121 | - nokogiri (1.5.2) | |
| 122 | - octokit (0.6.4) | |
| 123 | - addressable (~> 2.2.6) | |
| 124 | - faraday (~> 0.7.3) | |
| 125 | - faraday_middleware (~> 0.7.0.rc1) | |
| 126 | - hashie (~> 1.0.0) | |
| 127 | - multi_json (~> 1.0.2) | |
| 128 | - orm_adapter (0.0.7) | |
| 120 | + nokogiri (1.5.0) | |
| 121 | + octokit (1.0.0) | |
| 122 | + addressable (~> 2.2) | |
| 123 | + faraday (~> 0.7) | |
| 124 | + faraday_middleware (~> 0.8) | |
| 125 | + hashie (~> 1.2) | |
| 126 | + multi_json (~> 1.0) | |
| 127 | + orm_adapter (0.0.5) | |
| 129 | 128 | oruen_redmine_client (0.0.1) |
| 130 | 129 | activeresource (>= 2.3.0) |
| 131 | 130 | pivotal-tracker (0.5.4) |
| ... | ... | @@ -251,7 +250,7 @@ DEPENDENCIES |
| 251 | 250 | mongoid (~> 2.4.10) |
| 252 | 251 | mongoid_rails_migrations |
| 253 | 252 | nokogiri |
| 254 | - octokit (= 0.6.4) | |
| 253 | + octokit (~> 1.0.0) | |
| 255 | 254 | oruen_redmine_client |
| 256 | 255 | pivotal-tracker |
| 257 | 256 | rack-ssl-enforcer | ... | ... |
app/models/issue_trackers/github_issues_tracker.rb
| ... | ... | @@ -8,25 +8,24 @@ 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(problem, reported_by = nil) |
| 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(problem), body_template.result(binding).unpack('C*').pack('U*'), options = {}) |
| 25 | - problem.update_attribute :issue_link, issue.html_url | |
| 25 | + problem.update_attribute :issue_link, issue.issue.html_url | |
| 26 | 26 | end |
| 27 | 27 | |
| 28 | 28 | def body_template |
| 29 | 29 | @@body_template ||= ERB.new(File.read(Rails.root + "app/views/issue_trackers/github_issues_body.txt.erb").gsub(/^\s*/, '')) |
| 30 | 30 | end |
| 31 | 31 | end |
| 32 | - | ... | ... |
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 | ... | ... |