Skip to content

Commit

Permalink
Merge pull request #506 from Gonzih/master
Browse files Browse the repository at this point in the history
Fix issue with invalid repo user for api call to bitbucket.
  • Loading branch information
shingara committed Jun 13, 2013
2 parents 425153c + 07274a8 commit afdf9a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/models/issue_trackers/bitbucket_issues_tracker.rb
Expand Up @@ -26,7 +26,9 @@ def create_issue(problem, reported_by = nil)
bitbucket = BitBucket.new :basic_auth => "#{api_token}:#{project_id}"

begin
issue = bitbucket.issues.create api_token, repo_name.split('/')[1], :title => issue_title(problem), :content => body_template.result(binding), :priority => 'critical'
r_user = repo_name.split('/')[0]
r_name = repo_name.split('/')[1]
issue = bitbucket.issues.create r_user, r_name, :title => issue_title(problem), :content => body_template.result(binding), :priority => 'critical'
problem.update_attributes(
:issue_link => "https://bitbucket.org/#{repo_name}/issue/#{issue.local_id}/",
:issue_type => Label
Expand Down
5 changes: 2 additions & 3 deletions spec/models/issue_trackers/bitbucket_issues_tracker_spec.rb
Expand Up @@ -26,16 +26,15 @@
}
EOF

stub_request(:post, "https://#{tracker.api_token}:#{tracker.project_id}@bitbucket.org/api/1.0/repositories/test_username/test_repo/issues/").to_return(:status => 200, :headers => {}, :body => body )
stub_request(:post, "https://#{tracker.api_token}:#{tracker.project_id}@bitbucket.org/api/1.0/repositories/test_user/test_repo/issues/").to_return(:status => 200, :headers => {}, :body => body )

problem.app.issue_tracker.create_issue(problem)
problem.reload

requested = have_requested(:post, "https://#{tracker.api_token}:#{tracker.project_id}@bitbucket.org/api/1.0/repositories/test_username/test_repo/issues/")
requested = have_requested(:post, "https://#{tracker.api_token}:#{tracker.project_id}@bitbucket.org/api/1.0/repositories/test_user/test_repo/issues/")
WebMock.should requested.with(:title => /[production][foo#bar] FooError: Too Much Bar/)
WebMock.should requested.with(:content => /See this exception on Errbit/)

problem.issue_link.should == @issue_link
end
end

0 comments on commit afdf9a5

Please sign in to comment.