-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for pull_request endpoint
wip POST request Remove binding.pry Add endpoint to get a particular pull request Finish implement create endpoint Implement updating pull request endpoint Implement pull requests endpoints Fix encoding Remove wip rspec tags
Showing
3 changed files
with
368 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,272 @@ | ||
require 'spec_helper' | ||
|
||
describe BitBucket::Repos::PullRequest do | ||
let(:pull_request) { described_class.new } | ||
describe '.list' do | ||
subject { described_class.new } | ||
describe '#list' do | ||
before do | ||
expect(pull_request).to receive(:request).with( | ||
expect(subject).to receive(:request).with( | ||
:get, | ||
'/2.0/repositories/mock_username/mock_repo/pullrequests', | ||
'/2.0/repositories/mock_user/mock_repo/pullrequests', | ||
{}, | ||
{} | ||
) | ||
end | ||
|
||
it 'should make a GET request for the list of pull requests' do | ||
pull_request.list('mock_username', 'mock_repo') | ||
it 'makes a GET request for all pull requests belonging to the repo' do | ||
subject.list('mock_user', 'mock_repo') | ||
end | ||
end | ||
|
||
describe '.participants' do | ||
describe '#participants' do | ||
before do | ||
expect(pull_request).to receive(:request).with( | ||
expect(subject).to receive(:request).with( | ||
:get, | ||
'/1.0/repositories/mock_username/mock_repo/pullrequests/mock_pull_request_id/participants', | ||
"/1.0/repositories/mock_user/mock_repo/pullrequests/mock_pull_request_id/participants", | ||
{}, | ||
{} | ||
) | ||
end | ||
|
||
it 'should make a GET request for the list of participants' do | ||
pull_request.participants('mock_username', 'mock_repo', 'mock_pull_request_id') | ||
it 'makes a GET request for all participants belonging to the repo' do | ||
subject.participants('mock_user', 'mock_repo', 'mock_pull_request_id') | ||
end | ||
end | ||
|
||
describe '#get' do | ||
before do | ||
expect(subject).to receive(:request).with( | ||
:get, | ||
"/2.0/repositories/mock_user/mock_repo/pullrequests/mock_pull_request_id", | ||
{} | ||
) | ||
end | ||
|
||
it 'makes a GET request for the pull request belonging to the repo' do | ||
subject.get('mock_user', 'mock_repo', 'mock_pull_request_id') | ||
end | ||
end | ||
|
||
describe '#create' do | ||
before do | ||
@params = { | ||
title: "mock_pr_title", | ||
description: "mock_pull_request_description", | ||
source: { | ||
branch: { | ||
name: "mock_source_branch_name" | ||
}, | ||
repository: { | ||
full_name: "mock_owner/mock_repo" | ||
} | ||
}, | ||
destination: { | ||
branch: { | ||
name: "mock_destination_branch_name" | ||
}, | ||
commit: { | ||
hash: "mock_uuid" | ||
} | ||
}, | ||
close_source_branch: true | ||
} | ||
|
||
expect(subject).to receive(:request).with( | ||
:post, | ||
'/2.0/repositories/mock_user/mock_repo/pullrequests', | ||
@params | ||
) | ||
end | ||
|
||
it 'makes a POST request to create a new pull request' do | ||
subject.create('mock_user', 'mock_repo', @params) | ||
end | ||
|
||
xit 'validates presence of required params' do | ||
# expect do | ||
subject.create( | ||
'mock_user', | ||
'mock_repo', | ||
{ | ||
title: "", | ||
description: "mock_pull_request_description", | ||
source: { | ||
branch: { | ||
name: "mock_source_branch_name" | ||
}, | ||
repository: { | ||
full_name: "mock_owner/mock_repo" | ||
} | ||
}, | ||
destination: { | ||
branch: { | ||
name: "mock_destination_branch_name" | ||
}, | ||
commit: { | ||
hash: "mock_uuid" | ||
} | ||
}, | ||
close_source_branch: true | ||
} | ||
) | ||
# end.to(raise_error()) | ||
end | ||
end | ||
|
||
describe '.put' do | ||
before do | ||
expect(subject).to receive(:request).with( | ||
:put, | ||
'/2.0/repositories/mock_user/mock_repo/pullrequests/mock_id', | ||
{} | ||
) | ||
end | ||
|
||
it 'makes a PUT request for the given pull request' do | ||
subject.update('mock_user', 'mock_repo', 'mock_id') | ||
end | ||
end | ||
|
||
describe '.get_commits' do | ||
before do | ||
expect(subject).to receive(:request).with( | ||
:get, | ||
'/2.0/repositories/mock_user/mock_repo/pullrequests/mock_id/commits', | ||
{} | ||
) | ||
end | ||
|
||
it 'makes a GET request for the commits' do | ||
subject.get_commits('mock_user', 'mock_repo', 'mock_id') | ||
end | ||
end | ||
|
||
describe '.get_commits' do | ||
before do | ||
expect(subject).to receive(:request).with( | ||
:post, | ||
'/2.0/repositories/mock_user/mock_repo/pullrequests/mock_id/approve', | ||
{} | ||
) | ||
end | ||
|
||
it 'makes a POST request' do | ||
subject.approve('mock_user', 'mock_repo', 'mock_id') | ||
end | ||
end | ||
|
||
describe '.delete_approval' do | ||
before do | ||
expect(subject).to receive(:request).with( | ||
:delete, | ||
'/2.0/repositories/mock_user/mock_repo/pullrequests/mock_id/approve', | ||
{} | ||
) | ||
end | ||
|
||
it 'makes a DELTE request' do | ||
subject.delete_approval('mock_user', 'mock_repo', 'mock_id') | ||
end | ||
end | ||
|
||
|
||
describe '.diff' do | ||
before do | ||
expect(subject).to receive(:request).with( | ||
:get, | ||
'/2.0/repositories/mock_user/mock_repo/pullrequests/mock_id/diff', | ||
{} | ||
) | ||
end | ||
|
||
it 'makes a GET request for the diff of the pull request' do | ||
subject.diff('mock_user', 'mock_repo', 'mock_id') | ||
end | ||
end | ||
|
||
describe '.all_activity' do | ||
before do | ||
expect(subject).to receive(:request).with( | ||
:get, | ||
'/2.0/repositories/mock_user/mock_repo/pullrequests/activity', | ||
{} | ||
) | ||
end | ||
|
||
it 'makes a GET request' do | ||
subject.all_activity('mock_user', 'mock_repo') | ||
end | ||
end | ||
|
||
|
||
describe '.activity' do | ||
before do | ||
expect(subject).to receive(:request).with( | ||
:get, | ||
'/2.0/repositories/mock_user/mock_repo/pullrequests/mock_id/activity', | ||
{} | ||
) | ||
end | ||
|
||
it 'makes a GET request' do | ||
subject.activity('mock_user', 'mock_repo', 'mock_id') | ||
end | ||
end | ||
|
||
|
||
describe '.accept_and_merge' do | ||
before do | ||
expect(subject).to receive(:request).with( | ||
:post, | ||
'/2.0/repositories/mock_user/mock_repo/pullrequests/mock_id/merge', | ||
{} | ||
) | ||
end | ||
|
||
it 'makes a POST request' do | ||
subject.merge('mock_user', 'mock_repo', 'mock_id') | ||
end | ||
end | ||
|
||
describe '.decline' do | ||
before do | ||
expect(subject).to receive(:request).with( | ||
:post, | ||
'/2.0/repositories/mock_user/mock_repo/pullrequests/mock_id/decline', | ||
{} | ||
) | ||
end | ||
|
||
it 'makes a POST request' do | ||
subject.decline('mock_user', 'mock_repo', 'mock_id') | ||
end | ||
end | ||
|
||
|
||
describe '.comments' do | ||
before do | ||
expect(subject).to receive(:request).with( | ||
:get, | ||
'/2.0/repositories/mock_user/mock_repo/pullrequests/mock_id/comments', | ||
{} | ||
) | ||
end | ||
|
||
it 'makes a GET request' do | ||
subject.comments('mock_user', 'mock_repo', 'mock_id') | ||
end | ||
end | ||
|
||
describe '.comment' do | ||
before do | ||
expect(subject).to receive(:request).with( | ||
:get, | ||
'/2.0/repositories/mock_user/mock_repo/pullrequests/mock_id/comments/comment_id', | ||
{} | ||
) | ||
end | ||
|
||
it 'makes a GET request' do | ||
subject.comment('mock_user', 'mock_repo', 'mock_id', 'comment_id') | ||
end | ||
end | ||
end |
24f6ce6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tagging issue #44 and PR #55