Commit 0cfeb5a5655cff1c0b2b5417e965d21a62b87eb1
1 parent
8d743567
Exists in
master
and in
1 other branch
Fix github issue tracker creation
When creating a issue using octokit, we need to pass a instead of a , as those are changes on the new octokit gem. [fixes #675]
Showing
2 changed files
with
22 additions
and
5 deletions
Show diff stats
app/models/issue_trackers/github_issues_tracker.rb
... | ... | @@ -29,7 +29,7 @@ if defined? Octokit |
29 | 29 | def create_issue(problem, reported_by = nil) |
30 | 30 | # Login using OAuth token, if given. |
31 | 31 | if oauth_token |
32 | - client = Octokit::Client.new(:login => username, :oauth_token => oauth_token) | |
32 | + client = Octokit::Client.new(:login => username, :access_token => oauth_token) | |
33 | 33 | else |
34 | 34 | client = Octokit::Client.new(:login => username, :password => password) |
35 | 35 | end | ... | ... |
spec/models/issue_trackers/github_issues_tracker_spec.rb
... | ... | @@ -17,10 +17,10 @@ describe IssueTrackers::GithubIssuesTracker do |
17 | 17 | Fabricate :github_issues_tracker, app: notice.app |
18 | 18 | end |
19 | 19 | |
20 | - it "should create an issue on GitHub Issues with problem params, and set issue link for problem" do | |
21 | - number = 5 | |
22 | - issue_link = "https://github.com/#{repo}/issues/#{number}" | |
23 | - body = <<EOF | |
20 | + let(:number) { 5 } | |
21 | + let(:issue_link) { "https://github.com/#{repo}/issues/#{number}" } | |
22 | + let(:body) do | |
23 | + <<EOF | |
24 | 24 | { |
25 | 25 | "position": 1.0, |
26 | 26 | "number": #{number}, |
... | ... | @@ -34,7 +34,9 @@ describe IssueTrackers::GithubIssuesTracker do |
34 | 34 | "html_url": "#{issue_link}" |
35 | 35 | } |
36 | 36 | EOF |
37 | +end | |
37 | 38 | |
39 | + it "should create an issue on GitHub Issues with problem params, and set issue link for problem" do | |
38 | 40 | stub_request(:post, |
39 | 41 | "https://#{tracker.username}:#{tracker.password}@api.github.com/repos/#{repo}/issues"). |
40 | 42 | to_return(:status => 201, |
... | ... | @@ -53,4 +55,19 @@ EOF |
53 | 55 | |
54 | 56 | expect(problem.issue_link).to eq issue_link |
55 | 57 | end |
58 | + | |
59 | + it "should create an issue with oauth token" do | |
60 | + issue_tracker = problem.app.issue_tracker | |
61 | + issue_tracker.oauth_token = 'secret_token' | |
62 | + | |
63 | + stub_request(:post, "https://api.github.com/repos/#{repo}/issues"). | |
64 | + to_return({ | |
65 | + status: 201, | |
66 | + headers: {'Location' => issue_link, 'Content-Type' => 'application/json' }, | |
67 | + body: body }) | |
68 | + | |
69 | + issue_tracker.create_issue(problem) | |
70 | + requested = have_requested(:post, "https://api.github.com/repos/#{repo}/issues") | |
71 | + expect(WebMock).to requested.with(headers: {'Authorization'=>'token secret_token'}) | |
72 | + end | |
56 | 73 | end | ... | ... |