bitbuckets 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +7 -0
- data/README.md +169 -0
- data/Rakefile +1 -0
- data/lib/bitbucket_rest_api.rb +86 -0
- data/lib/bitbucket_rest_api/api.rb +104 -0
- data/lib/bitbucket_rest_api/api/actions.rb +32 -0
- data/lib/bitbucket_rest_api/api_factory.rb +29 -0
- data/lib/bitbucket_rest_api/authorization.rb +31 -0
- data/lib/bitbucket_rest_api/client.rb +53 -0
- data/lib/bitbucket_rest_api/configuration.rb +103 -0
- data/lib/bitbucket_rest_api/connection.rb +97 -0
- data/lib/bitbucket_rest_api/constants.rb +57 -0
- data/lib/bitbucket_rest_api/core_ext/array.rb +6 -0
- data/lib/bitbucket_rest_api/core_ext/hash.rb +58 -0
- data/lib/bitbucket_rest_api/deprecation.rb +36 -0
- data/lib/bitbucket_rest_api/error.rb +37 -0
- data/lib/bitbucket_rest_api/error/bad_events.rb +10 -0
- data/lib/bitbucket_rest_api/error/bad_request.rb +11 -0
- data/lib/bitbucket_rest_api/error/blank_value.rb +10 -0
- data/lib/bitbucket_rest_api/error/client_error.rb +19 -0
- data/lib/bitbucket_rest_api/error/forbidden.rb +11 -0
- data/lib/bitbucket_rest_api/error/internal_server_error.rb +11 -0
- data/lib/bitbucket_rest_api/error/invalid_options.rb +17 -0
- data/lib/bitbucket_rest_api/error/no_events.rb +10 -0
- data/lib/bitbucket_rest_api/error/not_found.rb +11 -0
- data/lib/bitbucket_rest_api/error/required_params.rb +17 -0
- data/lib/bitbucket_rest_api/error/service_error.rb +18 -0
- data/lib/bitbucket_rest_api/error/service_unavailable.rb +11 -0
- data/lib/bitbucket_rest_api/error/unauthorized.rb +11 -0
- data/lib/bitbucket_rest_api/error/unknown_value.rb +17 -0
- data/lib/bitbucket_rest_api/error/unprocessable_entity.rb +11 -0
- data/lib/bitbucket_rest_api/error/validations.rb +17 -0
- data/lib/bitbucket_rest_api/invitations.rb +14 -0
- data/lib/bitbucket_rest_api/issues.rb +229 -0
- data/lib/bitbucket_rest_api/issues/comments.rb +116 -0
- data/lib/bitbucket_rest_api/issues/components.rb +105 -0
- data/lib/bitbucket_rest_api/issues/milestones.rb +105 -0
- data/lib/bitbucket_rest_api/normalizer.rb +24 -0
- data/lib/bitbucket_rest_api/parameter_filter.rb +29 -0
- data/lib/bitbucket_rest_api/repos.rb +276 -0
- data/lib/bitbucket_rest_api/repos/changesets.rb +52 -0
- data/lib/bitbucket_rest_api/repos/commits.rb +38 -0
- data/lib/bitbucket_rest_api/repos/components.rb +35 -0
- data/lib/bitbucket_rest_api/repos/default_reviewers.rb +60 -0
- data/lib/bitbucket_rest_api/repos/download.rb +15 -0
- data/lib/bitbucket_rest_api/repos/following.rb +38 -0
- data/lib/bitbucket_rest_api/repos/forks.rb +66 -0
- data/lib/bitbucket_rest_api/repos/keys.rb +86 -0
- data/lib/bitbucket_rest_api/repos/pull_request.rb +158 -0
- data/lib/bitbucket_rest_api/repos/services.rb +101 -0
- data/lib/bitbucket_rest_api/repos/sources.rb +36 -0
- data/lib/bitbucket_rest_api/repos/webhooks.rb +99 -0
- data/lib/bitbucket_rest_api/request.rb +71 -0
- data/lib/bitbucket_rest_api/request/basic_auth.rb +30 -0
- data/lib/bitbucket_rest_api/request/jsonize.rb +39 -0
- data/lib/bitbucket_rest_api/request/oauth.rb +50 -0
- data/lib/bitbucket_rest_api/response.rb +26 -0
- data/lib/bitbucket_rest_api/response/helpers.rb +18 -0
- data/lib/bitbucket_rest_api/response/jsonize.rb +25 -0
- data/lib/bitbucket_rest_api/response/mashify.rb +23 -0
- data/lib/bitbucket_rest_api/response/raise_error.rb +28 -0
- data/lib/bitbucket_rest_api/response/xmlize.rb +25 -0
- data/lib/bitbucket_rest_api/result.rb +136 -0
- data/lib/bitbucket_rest_api/teams.rb +91 -0
- data/lib/bitbucket_rest_api/user.rb +87 -0
- data/lib/bitbucket_rest_api/users.rb +20 -0
- data/lib/bitbucket_rest_api/users/account.rb +50 -0
- data/lib/bitbucket_rest_api/utils/url.rb +61 -0
- data/lib/bitbucket_rest_api/validations.rb +23 -0
- data/lib/bitbucket_rest_api/validations/format.rb +21 -0
- data/lib/bitbucket_rest_api/validations/presence.rb +21 -0
- data/lib/bitbucket_rest_api/validations/required.rb +37 -0
- data/lib/bitbucket_rest_api/validations/token.rb +38 -0
- data/lib/bitbucket_rest_api/version.rb +10 -0
- data/lib/bitbuckets.rb +2 -0
- data/spec/bitbucket_rest_api/api/actions_spec.rb +18 -0
- data/spec/bitbucket_rest_api/api_factory_spec.rb +28 -0
- data/spec/bitbucket_rest_api/api_spec.rb +87 -0
- data/spec/bitbucket_rest_api/authorization_spec.rb +74 -0
- data/spec/bitbucket_rest_api/client_spec.rb +17 -0
- data/spec/bitbucket_rest_api/core_ext/array_spec.rb +13 -0
- data/spec/bitbucket_rest_api/core_ext/hash_spec.rb +47 -0
- data/spec/bitbucket_rest_api/deprecation_spec.rb +31 -0
- data/spec/bitbucket_rest_api/error/bad_events_spec.rb +11 -0
- data/spec/bitbucket_rest_api/error/blank_value_spec.rb +14 -0
- data/spec/bitbucket_rest_api/error/no_events_spec.rb +11 -0
- data/spec/bitbucket_rest_api/invitations_spec.rb +21 -0
- data/spec/bitbucket_rest_api/issues/comments_spec.rb +89 -0
- data/spec/bitbucket_rest_api/issues/components_spec.rb +89 -0
- data/spec/bitbucket_rest_api/issues/milestones_spec.rb +89 -0
- data/spec/bitbucket_rest_api/issues_spec.rb +91 -0
- data/spec/bitbucket_rest_api/normalizer_spec.rb +29 -0
- data/spec/bitbucket_rest_api/parameter_filter_spec.rb +42 -0
- data/spec/bitbucket_rest_api/repos/changesets_spec.rb +44 -0
- data/spec/bitbucket_rest_api/repos/commits_spec.rb +21 -0
- data/spec/bitbucket_rest_api/repos/components_spec.rb +43 -0
- data/spec/bitbucket_rest_api/repos/default_reviewers_spec.rb +65 -0
- data/spec/bitbucket_rest_api/repos/download_spec.rb +10 -0
- data/spec/bitbucket_rest_api/repos/following_spec.rb +53 -0
- data/spec/bitbucket_rest_api/repos/forks_spec.rb +46 -0
- data/spec/bitbucket_rest_api/repos/keys_spec.rb +73 -0
- data/spec/bitbucket_rest_api/repos/pull_request_spec.rb +283 -0
- data/spec/bitbucket_rest_api/repos/sources_spec.rb +78 -0
- data/spec/bitbucket_rest_api/repos/webhooks_spec.rb +245 -0
- data/spec/bitbucket_rest_api/repos_spec.rb +158 -0
- data/spec/bitbucket_rest_api/request/jsonize_spec.rb +19 -0
- data/spec/bitbucket_rest_api/request/oauth_spec.rb +26 -0
- data/spec/bitbucket_rest_api/request_spec.rb +88 -0
- data/spec/bitbucket_rest_api/response/jsonize_spec.rb +13 -0
- data/spec/bitbucket_rest_api/response/mashify_spec.rb +33 -0
- data/spec/bitbucket_rest_api/response/raise_error_spec.rb +42 -0
- data/spec/bitbucket_rest_api/teams_spec.rb +136 -0
- data/spec/bitbucket_rest_api/user_spec.rb +78 -0
- data/spec/bitbucket_rest_api/utils/url_spec.rb +34 -0
- data/spec/bitbucket_rest_api/validations/format_spec.rb +30 -0
- data/spec/bitbucket_rest_api/validations/presence_spec.rb +13 -0
- data/spec/bitbucket_rest_api/validations/required_spec.rb +44 -0
- data/spec/bitbucket_rest_api/validations/token_spec.rb +17 -0
- data/spec/bitbucket_rest_api_spec.rb +17 -0
- data/spec/spec_helper.rb +24 -0
- metadata +358 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe BitBucket::Client do
|
5
|
+
let(:client) { described_class.new }
|
6
|
+
|
7
|
+
it 'returns the a new object of the correct class' do
|
8
|
+
expect(client.issues).to be_a BitBucket::Issues
|
9
|
+
expect(client.repos).to be_a BitBucket::Repos
|
10
|
+
expect(client.users).to be_a BitBucket::Users
|
11
|
+
expect(client.user_api).to be_a BitBucket::User
|
12
|
+
expect(client.invitations).to be_a BitBucket::Invitations
|
13
|
+
expect(client.teams).to be_a BitBucket::Teams
|
14
|
+
expect(client.pull_requests).to be_a BitBucket::Repos::PullRequest
|
15
|
+
expect(client.oauth).to be_a BitBucket::Request::OAuth
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'bitbucket_rest_api/core_ext/array'
|
4
|
+
|
5
|
+
describe Array do
|
6
|
+
let(:array) { [:a, :b, :c, :d, { key: :value }] }
|
7
|
+
|
8
|
+
describe '#extract_options!' do
|
9
|
+
it 'selects a hash from the arguments list' do
|
10
|
+
expect(array.extract_options!).to eq(key: :value)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Hash do
|
5
|
+
before do
|
6
|
+
BitBucket.new
|
7
|
+
@hash = { a: 1, b: 2, c: 'e' }
|
8
|
+
@serialized = 'a=1&b=2&c=e'
|
9
|
+
@nested_hash = { 'a' => { 'b' => { 'c' => 1 } } }
|
10
|
+
@symbols = { a: { b: { c: 1 } } }
|
11
|
+
end
|
12
|
+
|
13
|
+
context '#symbolize_keys' do
|
14
|
+
it 'should respond to symbolize_keys' do
|
15
|
+
expect(@nested_hash).to respond_to :symbolize_keys
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context '#symbolize_keys!' do
|
20
|
+
it 'should respond to symbolize_keys!' do
|
21
|
+
expect(@nested_hash).to respond_to :symbolize_keys!
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should convert nested keys to symbols' do
|
25
|
+
expect(@nested_hash.symbolize_keys!).to eq @symbols
|
26
|
+
|
27
|
+
@nested_hash_with_array = { 'a' => { 'b' => [{ 'c' => 1 }] } }
|
28
|
+
expect(@nested_hash_with_array.symbolize_keys!).to eq(a: { b: [{ c: 1 }] })
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context '#serialize' do
|
33
|
+
it 'should respond to serialize' do
|
34
|
+
expect(@nested_hash).to respond_to :serialize
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should serialize hash' do
|
38
|
+
expect(@hash.serialize).to eq @serialized
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context '#deep_key?' do
|
43
|
+
it 'should find key inside nested hash' do
|
44
|
+
expect(@nested_hash.has_deep_key?('c')).to be_truthy
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end # Hash
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe BitBucket do
|
5
|
+
let(:method) { 'create_repos' }
|
6
|
+
let(:alt_method) { 'repos.create' }
|
7
|
+
|
8
|
+
it { expect(described_class.constants).to include :DEPRECATION_PREFIX }
|
9
|
+
|
10
|
+
context '.deprecate' do
|
11
|
+
before do
|
12
|
+
BitBucket.deprecation_tracker = []
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'tracks messages' do
|
16
|
+
expect(BitBucket).to receive(:warn).once
|
17
|
+
BitBucket.deprecate(method)
|
18
|
+
BitBucket.deprecate(method)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'prints the message through Kernel' do
|
22
|
+
expect(BitBucket).to receive(:warn).once
|
23
|
+
BitBucket.deprecate method
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'prints the message through Kernel' do
|
28
|
+
expect(BitBucket).to receive(:warn)
|
29
|
+
BitBucket.warn_deprecation method
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe BitBucket::Error::BadEvents do
|
5
|
+
context 'an event that does not exist is passed in BitBucket::Repos::Webhooks#create or BitBucket::Repos::Webhooks#edit' do
|
6
|
+
it 'should raise an error with a message' do
|
7
|
+
expect { raise described_class, 'bad:event' }
|
8
|
+
.to raise_error(BitBucket::Error::BadEvents, "The event: 'bad:event', does not exist :(")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe BitBucket::Error::BlankValue do
|
5
|
+
context 'an event that does not exist is passed in BitBucket::Repos::Webhooks#create or BitBucket::Repos::Webhooks#edit' do
|
6
|
+
it 'should raise an error with a message' do
|
7
|
+
expect { raise described_class, 'required_key' }
|
8
|
+
.to raise_error(
|
9
|
+
BitBucket::Error::BlankValue,
|
10
|
+
"The value for: 'required_key', cannot be blank :("
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe BitBucket::Error::NoEvents do
|
5
|
+
context 'no events are passed in BitBucket::Repos::Webhooks#create or BitBucket::Repos::Webhooks#edit' do
|
6
|
+
it 'should raise an error with a message' do
|
7
|
+
expect { raise described_class }
|
8
|
+
.to raise_error(BitBucket::Error::NoEvents, 'At least one event is required, none given :(')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe BitBucket::Invitations do
|
5
|
+
subject { described_class.new }
|
6
|
+
|
7
|
+
describe '#invitations' do
|
8
|
+
before do
|
9
|
+
expect(subject).to receive(:request).with(
|
10
|
+
:post,
|
11
|
+
'/1.0/invitations/mock_username/mock_repo/mock_email_address',
|
12
|
+
{ permission: 'read' },
|
13
|
+
{}
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'sends a POST request for an invitation belonging to the given repo' do
|
18
|
+
subject.invite('mock_username', 'mock_repo', 'mock_email_address', 'read')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe BitBucket::Issues::Comments do
|
5
|
+
let(:comments) { described_class.new }
|
6
|
+
|
7
|
+
describe '.list' do
|
8
|
+
before do
|
9
|
+
expect(comments).to receive(:request).with(
|
10
|
+
:get,
|
11
|
+
'/1.0/repositories/mock_username/mock_repo/issues/mock_issue_id/comments/',
|
12
|
+
{},
|
13
|
+
{}
|
14
|
+
).and_return(%w[comment1 comment2 comment3])
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'without a block' do
|
18
|
+
it 'should make a GET request for the given issue' do
|
19
|
+
comments.list('mock_username', 'mock_repo', 'mock_issue_id')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'with a block' do
|
24
|
+
it 'should make a GET request for the given issue' do
|
25
|
+
comments.list('mock_username', 'mock_repo', 'mock_issue_id') { |comment| comment }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '.get' do
|
31
|
+
before do
|
32
|
+
expect(comments).to receive(:request).with(
|
33
|
+
:get,
|
34
|
+
'/1.0/repositories/mock_username/mock_repo/issues/comments/mock_comment_id',
|
35
|
+
{},
|
36
|
+
{}
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should make a GET request for the given comment' do
|
41
|
+
comments.get('mock_username', 'mock_repo', 'mock_comment_id')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '.create' do
|
46
|
+
before do
|
47
|
+
expect(comments).to receive(:request).with(
|
48
|
+
:post,
|
49
|
+
'/1.0/repositories/mock_username/mock_repo/issues/mock_issue_id/comments/',
|
50
|
+
{ 'content' => 'mock_comment' },
|
51
|
+
{}
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should send a POST request for the given issue' do
|
56
|
+
comments.create('mock_username', 'mock_repo', 'mock_issue_id', 'content' => 'mock_comment')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '.edit' do
|
61
|
+
before do
|
62
|
+
expect(comments).to receive(:request).with(
|
63
|
+
:put,
|
64
|
+
'/1.0/repositories/mock_username/mock_repo/issues/comments/mock_comment_id',
|
65
|
+
{ 'content' => 'new_mock_comment' },
|
66
|
+
{}
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should send a PUT request for the given comment' do
|
71
|
+
comments.edit('mock_username', 'mock_repo', 'mock_comment_id', 'content' => 'new_mock_comment')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '.delete' do
|
76
|
+
before do
|
77
|
+
expect(comments).to receive(:request).with(
|
78
|
+
:delete,
|
79
|
+
'/1.0/repositories/mock_username/mock_repo/issues/comments/mock_comment_id',
|
80
|
+
{},
|
81
|
+
{}
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should make a DELETE request for the given comment' do
|
86
|
+
comments.delete('mock_username', 'mock_repo', 'mock_comment_id')
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe BitBucket::Issues::Components do
|
5
|
+
subject { described_class.new }
|
6
|
+
|
7
|
+
describe '#list' do
|
8
|
+
before do
|
9
|
+
expect(subject).to receive(:request).with(
|
10
|
+
:get,
|
11
|
+
'/1.0/repositories/mock_username/mock_repo/issues/components',
|
12
|
+
{},
|
13
|
+
{}
|
14
|
+
).and_return(%w[component1 component2 component3])
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'without a block' do
|
18
|
+
it 'makes a GET request for the components belonging to the given repo' do
|
19
|
+
subject.list('mock_username', 'mock_repo')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'with a block' do
|
24
|
+
it 'makes a GET request for the components belonging to the given repo' do
|
25
|
+
subject.list('mock_username', 'mock_repo') { |component| component }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#get' do
|
31
|
+
before do
|
32
|
+
expect(subject).to receive(:request).with(
|
33
|
+
:get,
|
34
|
+
'/1.0/repositories/mock_username/mock_repo/issues/components/mock_component_id',
|
35
|
+
{},
|
36
|
+
{}
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'makes a GET request for the given component belonging to the given repo' do
|
41
|
+
subject.get('mock_username', 'mock_repo', 'mock_component_id')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#create' do
|
46
|
+
before do
|
47
|
+
expect(subject).to receive(:request).with(
|
48
|
+
:post,
|
49
|
+
'/1.0/repositories/mock_username/mock_repo/issues/components',
|
50
|
+
{ 'name' => 'mock_name' },
|
51
|
+
{}
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'makes a POST request for a new component that will belong to the given repo' do
|
56
|
+
subject.create('mock_username', 'mock_repo', name: 'mock_name')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#update' do
|
61
|
+
before do
|
62
|
+
expect(subject).to receive(:request).with(
|
63
|
+
:put,
|
64
|
+
'/1.0/repositories/mock_username/mock_repo/issues/components/mock_component_id',
|
65
|
+
{ 'name' => 'mock_name' },
|
66
|
+
{}
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'makes a PUT request for the given component belonging to the given repo' do
|
71
|
+
subject.update('mock_username', 'mock_repo', 'mock_component_id', name: 'mock_name')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#delete' do
|
76
|
+
before do
|
77
|
+
expect(subject).to receive(:request).with(
|
78
|
+
:delete,
|
79
|
+
'/1.0/repositories/mock_username/mock_repo/issues/components/mock_component_id',
|
80
|
+
{},
|
81
|
+
{}
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'makes a PUT request for the given component belonging to the given repo' do
|
86
|
+
subject.delete('mock_username', 'mock_repo', 'mock_component_id')
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe BitBucket::Issues::Milestones do
|
5
|
+
subject { described_class.new }
|
6
|
+
|
7
|
+
describe '#list' do
|
8
|
+
before do
|
9
|
+
expect(subject).to receive(:request).with(
|
10
|
+
:get,
|
11
|
+
'/1.0/repositories/mock_username/mock_repo/issues/milestones',
|
12
|
+
{},
|
13
|
+
{}
|
14
|
+
).and_return(%w[milsetone1 milestone2 milestone3])
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'without a block' do
|
18
|
+
it 'makes a GET request for the milestones belonging to the given repo' do
|
19
|
+
subject.list('mock_username', 'mock_repo')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'with a block' do
|
24
|
+
it 'makes a GET request for the milestones belonging to the given repo' do
|
25
|
+
subject.list('mock_username', 'mock_repo') { |milestone| milestone }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#get' do
|
31
|
+
before do
|
32
|
+
expect(subject).to receive(:request).with(
|
33
|
+
:get,
|
34
|
+
'/1.0/repositories/mock_username/mock_repo/issues/milestones/mock_milestone_id',
|
35
|
+
{},
|
36
|
+
{}
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'makes a GET request for the given milestone belonging to the given repo' do
|
41
|
+
subject.get('mock_username', 'mock_repo', 'mock_milestone_id')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#create' do
|
46
|
+
before do
|
47
|
+
expect(subject).to receive(:request).with(
|
48
|
+
:post,
|
49
|
+
'/1.0/repositories/mock_username/mock_repo/issues/milestones',
|
50
|
+
{ 'name' => 'mock_name' },
|
51
|
+
{}
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'makes a POST request for a new milestone that will belong to the given repo' do
|
56
|
+
subject.create('mock_username', 'mock_repo', name: 'mock_name')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#update' do
|
61
|
+
before do
|
62
|
+
expect(subject).to receive(:request).with(
|
63
|
+
:put,
|
64
|
+
'/1.0/repositories/mock_username/mock_repo/issues/milestones/mock_milestone_id',
|
65
|
+
{ 'name' => 'mock_name' },
|
66
|
+
{}
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'makes a PUT request for the given milestone belonging to the given repo' do
|
71
|
+
subject.update('mock_username', 'mock_repo', 'mock_milestone_id', name: 'mock_name')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#delete' do
|
76
|
+
before do
|
77
|
+
expect(subject).to receive(:request).with(
|
78
|
+
:delete,
|
79
|
+
'/1.0/repositories/mock_username/mock_repo/issues/milestones/mock_milestone_id',
|
80
|
+
{},
|
81
|
+
{}
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'makes a PUT request for the given milestone belonging to the given repo' do
|
86
|
+
subject.delete('mock_username', 'mock_repo', 'mock_milestone_id')
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|