bitbucket_rest_api2 0.9.1 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -12
- data/lib/bitbucket_rest_api/api.rb +1 -6
- data/lib/bitbucket_rest_api/api_factory.rb +0 -1
- data/lib/bitbucket_rest_api/configuration.rb +7 -1
- data/lib/bitbucket_rest_api/connection.rb +7 -4
- data/lib/bitbucket_rest_api/error/refresh_token.rb +12 -0
- data/lib/bitbucket_rest_api/error.rb +1 -0
- data/lib/bitbucket_rest_api/helpers/repository_helper.rb +13 -0
- data/lib/bitbucket_rest_api/invitations.rb +1 -1
- data/lib/bitbucket_rest_api/issues/comments.rb +5 -5
- data/lib/bitbucket_rest_api/issues/components.rb +5 -5
- data/lib/bitbucket_rest_api/issues/milestones.rb +5 -5
- data/lib/bitbucket_rest_api/issues.rb +5 -5
- data/lib/bitbucket_rest_api/repos/changesets.rb +2 -2
- data/lib/bitbucket_rest_api/repos/commits.rb +8 -2
- data/lib/bitbucket_rest_api/repos/following.rb +2 -2
- data/lib/bitbucket_rest_api/repos/forks.rb +1 -1
- data/lib/bitbucket_rest_api/repos/keys.rb +32 -12
- data/lib/bitbucket_rest_api/repos/pull_request.rb +1 -1
- data/lib/bitbucket_rest_api/repos/services.rb +14 -7
- data/lib/bitbucket_rest_api/repos/sources.rb +2 -2
- data/lib/bitbucket_rest_api/repos/statuses.rb +51 -0
- data/lib/bitbucket_rest_api/repos/webhooks.rb +35 -16
- data/lib/bitbucket_rest_api/repos.rb +35 -12
- data/lib/bitbucket_rest_api/request.rb +43 -15
- data/lib/bitbucket_rest_api/response/raise_error.rb +5 -0
- data/lib/bitbucket_rest_api/user.rb +7 -7
- data/lib/bitbucket_rest_api/users/account.rb +8 -8
- data/lib/bitbucket_rest_api/version.rb +1 -1
- data/lib/bitbucket_rest_api.rb +1 -25
- data/spec/bitbucket_rest_api/core_ext/hash_spec.rb +1 -1
- data/spec/bitbucket_rest_api/helpers/repository_helper_spec.rb +30 -0
- data/spec/bitbucket_rest_api/invitations_spec.rb +1 -1
- data/spec/bitbucket_rest_api/issues/comments_spec.rb +5 -5
- data/spec/bitbucket_rest_api/issues/components_spec.rb +5 -5
- data/spec/bitbucket_rest_api/issues/milestones_spec.rb +5 -5
- data/spec/bitbucket_rest_api/issues_spec.rb +5 -5
- data/spec/bitbucket_rest_api/repos/changesets_spec.rb +2 -2
- data/spec/bitbucket_rest_api/repos/following_spec.rb +2 -2
- data/spec/bitbucket_rest_api/repos/forks_spec.rb +1 -1
- data/spec/bitbucket_rest_api/repos/keys_spec.rb +5 -5
- data/spec/bitbucket_rest_api/repos/pull_request_spec.rb +1 -1
- data/spec/bitbucket_rest_api/repos/sources_spec.rb +3 -3
- data/spec/bitbucket_rest_api/repos/statuses_spec.rb +48 -0
- data/spec/bitbucket_rest_api/repos/webhooks_spec.rb +3 -3
- data/spec/bitbucket_rest_api/repos_spec.rb +7 -7
- data/spec/bitbucket_rest_api/request_spec.rb +11 -11
- data/spec/bitbucket_rest_api/user_spec.rb +8 -8
- metadata +11 -8
- data/lib/bitbucket_rest_api/response/helpers.rb +0 -21
- data/lib/bitbucket_rest_api/result.rb +0 -140
@@ -7,7 +7,7 @@ describe BitBucket::Issues::Components do
|
|
7
7
|
before do
|
8
8
|
expect(subject).to receive(:request).with(
|
9
9
|
:get,
|
10
|
-
'/
|
10
|
+
'/1.0/repositories/mock_username/mock_repo/issues/components',
|
11
11
|
{},
|
12
12
|
{}
|
13
13
|
).and_return(['component1', 'component2', 'component3'])
|
@@ -30,7 +30,7 @@ describe BitBucket::Issues::Components do
|
|
30
30
|
before do
|
31
31
|
expect(subject).to receive(:request).with(
|
32
32
|
:get,
|
33
|
-
'/
|
33
|
+
'/1.0/repositories/mock_username/mock_repo/issues/components/mock_component_id',
|
34
34
|
{},
|
35
35
|
{}
|
36
36
|
)
|
@@ -45,7 +45,7 @@ describe BitBucket::Issues::Components do
|
|
45
45
|
before do
|
46
46
|
expect(subject).to receive(:request).with(
|
47
47
|
:post,
|
48
|
-
'/
|
48
|
+
'/1.0/repositories/mock_username/mock_repo/issues/components',
|
49
49
|
{ 'name' => 'mock_name' },
|
50
50
|
{}
|
51
51
|
)
|
@@ -60,7 +60,7 @@ describe BitBucket::Issues::Components do
|
|
60
60
|
before do
|
61
61
|
expect(subject).to receive(:request).with(
|
62
62
|
:put,
|
63
|
-
'/
|
63
|
+
'/1.0/repositories/mock_username/mock_repo/issues/components/mock_component_id',
|
64
64
|
{ 'name' => 'mock_name' },
|
65
65
|
{}
|
66
66
|
)
|
@@ -75,7 +75,7 @@ describe BitBucket::Issues::Components do
|
|
75
75
|
before do
|
76
76
|
expect(subject).to receive(:request).with(
|
77
77
|
:delete,
|
78
|
-
'/
|
78
|
+
'/1.0/repositories/mock_username/mock_repo/issues/components/mock_component_id',
|
79
79
|
{},
|
80
80
|
{}
|
81
81
|
)
|
@@ -7,7 +7,7 @@ describe BitBucket::Issues::Milestones do
|
|
7
7
|
before do
|
8
8
|
expect(subject).to receive(:request).with(
|
9
9
|
:get,
|
10
|
-
'/
|
10
|
+
'/1.0/repositories/mock_username/mock_repo/issues/milestones',
|
11
11
|
{},
|
12
12
|
{}
|
13
13
|
).and_return(['milsetone1', 'milestone2', 'milestone3'])
|
@@ -30,7 +30,7 @@ describe BitBucket::Issues::Milestones do
|
|
30
30
|
before do
|
31
31
|
expect(subject).to receive(:request).with(
|
32
32
|
:get,
|
33
|
-
'/
|
33
|
+
'/1.0/repositories/mock_username/mock_repo/issues/milestones/mock_milestone_id',
|
34
34
|
{},
|
35
35
|
{}
|
36
36
|
)
|
@@ -45,7 +45,7 @@ describe BitBucket::Issues::Milestones do
|
|
45
45
|
before do
|
46
46
|
expect(subject).to receive(:request).with(
|
47
47
|
:post,
|
48
|
-
'/
|
48
|
+
'/1.0/repositories/mock_username/mock_repo/issues/milestones',
|
49
49
|
{ 'name' => 'mock_name' },
|
50
50
|
{}
|
51
51
|
)
|
@@ -60,7 +60,7 @@ describe BitBucket::Issues::Milestones do
|
|
60
60
|
before do
|
61
61
|
expect(subject).to receive(:request).with(
|
62
62
|
:put,
|
63
|
-
'/
|
63
|
+
'/1.0/repositories/mock_username/mock_repo/issues/milestones/mock_milestone_id',
|
64
64
|
{ 'name' => 'mock_name' },
|
65
65
|
{}
|
66
66
|
)
|
@@ -75,7 +75,7 @@ describe BitBucket::Issues::Milestones do
|
|
75
75
|
before do
|
76
76
|
expect(subject).to receive(:request).with(
|
77
77
|
:delete,
|
78
|
-
'/
|
78
|
+
'/1.0/repositories/mock_username/mock_repo/issues/milestones/mock_milestone_id',
|
79
79
|
{},
|
80
80
|
{}
|
81
81
|
)
|
@@ -8,7 +8,7 @@ describe BitBucket::Issues do
|
|
8
8
|
before do
|
9
9
|
expect(issue).to receive(:request).with(
|
10
10
|
:post,
|
11
|
-
'/
|
11
|
+
'/1.0/repositories/mock_username/mock_repo/issues/',
|
12
12
|
{ 'title' => 'mock_issue' },
|
13
13
|
{}
|
14
14
|
)
|
@@ -23,7 +23,7 @@ describe BitBucket::Issues do
|
|
23
23
|
before do
|
24
24
|
expect(issue).to receive(:request).with(
|
25
25
|
:put,
|
26
|
-
'/
|
26
|
+
'/1.0/repositories/mock_username/mock_repo/issues/1/',
|
27
27
|
{ 'title' => 'new_title' },
|
28
28
|
{}
|
29
29
|
)
|
@@ -38,7 +38,7 @@ describe BitBucket::Issues do
|
|
38
38
|
before do
|
39
39
|
expect(issue).to receive(:request).with(
|
40
40
|
:get,
|
41
|
-
'/
|
41
|
+
'/1.0/repositories/mock_username/mock_repo/issues/1',
|
42
42
|
{},
|
43
43
|
{}
|
44
44
|
)
|
@@ -53,7 +53,7 @@ describe BitBucket::Issues do
|
|
53
53
|
before do
|
54
54
|
expect(issue).to receive(:request).with(
|
55
55
|
:delete,
|
56
|
-
'/
|
56
|
+
'/1.0/repositories/mock_username/mock_repo/issues/1',
|
57
57
|
{},
|
58
58
|
{}
|
59
59
|
)
|
@@ -68,7 +68,7 @@ describe BitBucket::Issues do
|
|
68
68
|
before do
|
69
69
|
expect(issue).to receive(:request).with(
|
70
70
|
:get,
|
71
|
-
'/
|
71
|
+
'/1.0/repositories/mock_username/mock_repo/issues',
|
72
72
|
{},
|
73
73
|
{}
|
74
74
|
).and_return(OpenStruct.new(:issues => [])).twice
|
@@ -7,7 +7,7 @@ describe BitBucket::Repos::Changesets do
|
|
7
7
|
before do
|
8
8
|
expect(changesets).to receive(:request).with(
|
9
9
|
:get,
|
10
|
-
'/
|
10
|
+
'/1.0/repositories/mock_username/mock_repo/changesets',
|
11
11
|
{},
|
12
12
|
{}
|
13
13
|
).and_return(['changset1', 'changeset2', 'changeset3'])
|
@@ -30,7 +30,7 @@ describe BitBucket::Repos::Changesets do
|
|
30
30
|
before do
|
31
31
|
expect(changesets).to receive(:request).with(
|
32
32
|
:get,
|
33
|
-
'/
|
33
|
+
'/1.0/repositories/mock_username/mock_repo/changesets/test_sha',
|
34
34
|
{},
|
35
35
|
{}
|
36
36
|
)
|
@@ -7,7 +7,7 @@ describe BitBucket::Repos::Following do
|
|
7
7
|
before do
|
8
8
|
expect(following).to receive(:request).with(
|
9
9
|
:get,
|
10
|
-
'/
|
10
|
+
'/1.0/repositories/mock_username/mock_repo/followers/',
|
11
11
|
{},
|
12
12
|
{}
|
13
13
|
).and_return(['follower1', 'follower2', 'follower3'])
|
@@ -31,7 +31,7 @@ describe BitBucket::Repos::Following do
|
|
31
31
|
before do
|
32
32
|
expect(following).to receive(:request).with(
|
33
33
|
:get,
|
34
|
-
'/
|
34
|
+
'/1.0/user/follows',
|
35
35
|
{},
|
36
36
|
{}
|
37
37
|
).and_return(['followed1', 'followed2', 'followed3'])
|
@@ -6,7 +6,7 @@ describe BitBucket::Repos::Keys do
|
|
6
6
|
before do
|
7
7
|
expect(deploy_keys).to receive(:request).with(
|
8
8
|
:get,
|
9
|
-
'/
|
9
|
+
'/1.0/repositories/mock_username/mock_repo/deploy-keys/',
|
10
10
|
{},
|
11
11
|
{}
|
12
12
|
).and_return(['key1', 'key2', 'key3'])
|
@@ -29,9 +29,9 @@ describe BitBucket::Repos::Keys do
|
|
29
29
|
before do
|
30
30
|
expect(deploy_keys).to receive(:request).with(
|
31
31
|
:post,
|
32
|
-
'/
|
32
|
+
'/1.0/repositories/mock_username/mock_repo/deploy-keys/',
|
33
33
|
{ 'key' => 'mock_ssh_key', 'label' => 'mock_label' },
|
34
|
-
{}
|
34
|
+
{ headers: { "Content-Type" => "application/json" } }
|
35
35
|
)
|
36
36
|
end
|
37
37
|
|
@@ -44,7 +44,7 @@ describe BitBucket::Repos::Keys do
|
|
44
44
|
before do
|
45
45
|
expect(deploy_keys).to receive(:request).with(
|
46
46
|
:put,
|
47
|
-
'/
|
47
|
+
'/1.0/repositories/mock_username/mock_repo/deploy-keys/1',
|
48
48
|
{ 'key' => 'mock_ssh_key', 'label' => 'mock_label' },
|
49
49
|
{}
|
50
50
|
)
|
@@ -59,7 +59,7 @@ describe BitBucket::Repos::Keys do
|
|
59
59
|
before do
|
60
60
|
expect(deploy_keys).to receive(:request).with(
|
61
61
|
:delete,
|
62
|
-
'/
|
62
|
+
'/1.0/repositories/mock_username/mock_repo/deploy-keys/mock_id',
|
63
63
|
{ 'key' => 'mock_ssh_key', 'label' => 'mock_label' },
|
64
64
|
{}
|
65
65
|
)
|
@@ -29,7 +29,7 @@ describe BitBucket::Repos::PullRequest do
|
|
29
29
|
before do
|
30
30
|
expect(subject).to receive(:request).with(
|
31
31
|
:get,
|
32
|
-
"/
|
32
|
+
"/1.0/repositories/mock_user/mock_repo/pullrequests/mock_pull_request_id/participants",
|
33
33
|
{},
|
34
34
|
{}
|
35
35
|
).and_return(['participant1', 'participant2', 'participant3'])
|
@@ -19,7 +19,7 @@ describe BitBucket::Repos::Sources do
|
|
19
19
|
before do
|
20
20
|
expect(subject).to receive(:request).with(
|
21
21
|
:get,
|
22
|
-
'/
|
22
|
+
'/1.0/repositories/mock_username/mock_repo/src/moch_sha/',
|
23
23
|
{},
|
24
24
|
{}
|
25
25
|
)
|
@@ -34,7 +34,7 @@ describe BitBucket::Repos::Sources do
|
|
34
34
|
before do
|
35
35
|
expect(subject).to receive(:request).with(
|
36
36
|
:get,
|
37
|
-
'/
|
37
|
+
'/1.0/repositories/mock_username/mock_repo/src/moch_sha/app/controller',
|
38
38
|
{},
|
39
39
|
{}
|
40
40
|
)
|
@@ -63,7 +63,7 @@ describe BitBucket::Repos::Sources do
|
|
63
63
|
before do
|
64
64
|
expect(subject).to receive(:request).with(
|
65
65
|
:get,
|
66
|
-
'/
|
66
|
+
'/1.0/repositories/mock_username/mock_repo/raw/moch_sha/app/assets/images/logo.jpg',
|
67
67
|
{},
|
68
68
|
{}
|
69
69
|
)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'bitbucket_rest_api'
|
2
|
+
|
3
|
+
describe BitBucket::Repos::Statuses do
|
4
|
+
let(:repo_name) { 'wrath' }
|
5
|
+
let(:sha) { '123456' }
|
6
|
+
let(:state) { 'FAILED' }
|
7
|
+
let(:key) { 'my-build-key' }
|
8
|
+
let(:url) { 'http://somewhere/build' }
|
9
|
+
|
10
|
+
let(:statuses) { described_class.new }
|
11
|
+
|
12
|
+
before { allow(statuses).to receive(:post_request) }
|
13
|
+
|
14
|
+
subject(:status_create) do
|
15
|
+
statuses.create('khan', repo_name, sha, state, key, url, { 'extra-stuff' => 'hello'})
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'create' do
|
19
|
+
it 'should send request if parameters are valid' do
|
20
|
+
expect(statuses).to receive(:post_request).with("/2.0/repositories/khan/wrath/commit/123456/statuses/build",
|
21
|
+
{
|
22
|
+
"extra-stuff"=>"hello",
|
23
|
+
"state"=> state,
|
24
|
+
"key"=> key,
|
25
|
+
"url"=> url
|
26
|
+
},
|
27
|
+
{:headers=>{"Content-Type"=>"application/json"}})
|
28
|
+
|
29
|
+
status_create
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should sanitize_repository_name' do
|
33
|
+
expect(statuses).to receive(:sanitize_repository_name).with(repo_name) { 'radio-edit' }
|
34
|
+
expect(statuses).to receive(:post_request).with("/2.0/repositories/khan/radio-edit/commit/123456/statuses/build",
|
35
|
+
anything,
|
36
|
+
anything)
|
37
|
+
|
38
|
+
status_create
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should validate presence of sha, state, key, url' do
|
42
|
+
expect(statuses).to receive(:_validate_presence_of).with(sha, state, key, url)
|
43
|
+
|
44
|
+
status_create
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -112,7 +112,7 @@ describe BitBucket::Repos::Webhooks, wip: true do
|
|
112
112
|
:post,
|
113
113
|
'/2.0/repositories/mock_username/mock_repo/hooks',
|
114
114
|
post_put_params,
|
115
|
-
{}
|
115
|
+
{ headers: { "Content-Type" => "application/json" } }
|
116
116
|
)
|
117
117
|
|
118
118
|
subject.create(
|
@@ -127,7 +127,7 @@ describe BitBucket::Repos::Webhooks, wip: true do
|
|
127
127
|
it 'makes a GET request for all the webhooks beloning to the given repo' do
|
128
128
|
expect(subject).to receive(:request).with(
|
129
129
|
:get,
|
130
|
-
'/2.0/repositories/mock_username/mock_repo/hooks',
|
130
|
+
'/2.0/repositories/mock_username/mock_repo/hooks?pagelen=100',
|
131
131
|
{},
|
132
132
|
{}
|
133
133
|
)
|
@@ -218,7 +218,7 @@ describe BitBucket::Repos::Webhooks, wip: true do
|
|
218
218
|
:put,
|
219
219
|
'/2.0/repositories/mock_username/mock_repo/hooks/mock_uuid',
|
220
220
|
post_put_params,
|
221
|
-
{}
|
221
|
+
{ headers: { "Content-Type" => "application/json" } }
|
222
222
|
)
|
223
223
|
|
224
224
|
subject.edit(
|
@@ -15,7 +15,7 @@ describe BitBucket::Repos do
|
|
15
15
|
before do
|
16
16
|
expect(repo).to receive(:request).with(
|
17
17
|
:post,
|
18
|
-
'/
|
18
|
+
'/1.0/repositories/',
|
19
19
|
BitBucket::Repos::DEFAULT_REPO_OPTIONS.merge({ 'owner' => 'mock_owner', 'name' => 'mock_repo' }),
|
20
20
|
{}
|
21
21
|
)
|
@@ -30,7 +30,7 @@ describe BitBucket::Repos do
|
|
30
30
|
before do
|
31
31
|
expect(repo).to receive(:request).with(
|
32
32
|
:delete,
|
33
|
-
'/
|
33
|
+
'/1.0/repositories/mock_username/mock_repo',
|
34
34
|
{},
|
35
35
|
{}
|
36
36
|
)
|
@@ -46,7 +46,7 @@ describe BitBucket::Repos do
|
|
46
46
|
before do
|
47
47
|
expect(repo).to receive(:request).with(
|
48
48
|
:get,
|
49
|
-
'/
|
49
|
+
'/1.0/repositories/mock_username/mock_repo/branches/',
|
50
50
|
{},
|
51
51
|
{}
|
52
52
|
).and_return(['branch1', 'branch2', 'branch3'])
|
@@ -69,7 +69,7 @@ describe BitBucket::Repos do
|
|
69
69
|
before do
|
70
70
|
expect(repo).to receive(:request).with(
|
71
71
|
:put,
|
72
|
-
'/
|
72
|
+
'/1.0/repositories/mock_username/mock_repo/',
|
73
73
|
BitBucket::Repos::DEFAULT_REPO_OPTIONS.merge({ 'owner' => 'mock_owner' }),
|
74
74
|
{}
|
75
75
|
)
|
@@ -85,7 +85,7 @@ describe BitBucket::Repos do
|
|
85
85
|
before do
|
86
86
|
expect(repo).to receive(:request).with(
|
87
87
|
:get,
|
88
|
-
'/
|
88
|
+
'/1.0/repositories/mock_username/mock_repo',
|
89
89
|
{},
|
90
90
|
{}
|
91
91
|
)
|
@@ -100,7 +100,7 @@ describe BitBucket::Repos do
|
|
100
100
|
before do
|
101
101
|
expect(repo).to receive(:request).with(
|
102
102
|
:get,
|
103
|
-
'/
|
103
|
+
'/1.0/user/repositories',
|
104
104
|
{},
|
105
105
|
{}
|
106
106
|
).and_return(['repo1', 'repo2' ,'repo3'])
|
@@ -124,7 +124,7 @@ describe BitBucket::Repos do
|
|
124
124
|
before do
|
125
125
|
expect(repo).to receive(:request).with(
|
126
126
|
:get,
|
127
|
-
'/
|
127
|
+
'/1.0/repositories/mock_username/mock_repo/tags/',
|
128
128
|
{},
|
129
129
|
{}
|
130
130
|
).and_return(['tag1', 'tag2' ,'tag3'])
|
@@ -17,19 +17,19 @@ describe BitBucket::Request do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "supports get" do
|
20
|
-
stub_request(:get, "https://api.bitbucket.org/
|
20
|
+
stub_request(:get, "https://api.bitbucket.org/1.0/endpoint").
|
21
21
|
with(:headers => {
|
22
22
|
'Accept' => '*/*',
|
23
|
-
'Accept-Encoding' => 'gzip;q=
|
23
|
+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
24
24
|
'Authorization' => 'Bearer 12345',
|
25
25
|
'User-Agent' => 'Faraday v0.9.2'
|
26
26
|
})
|
27
27
|
|
28
|
-
fake_api.new.request(:get, '/
|
28
|
+
fake_api.new.request(:get, '/1.0/endpoint', {}, {})
|
29
29
|
end
|
30
30
|
|
31
31
|
it "supports put" do
|
32
|
-
stub_request(:put, "https://api.bitbucket.org/
|
32
|
+
stub_request(:put, "https://api.bitbucket.org/1.0/endpoint").
|
33
33
|
with(:body => "{\"data\":{\"key\":\"value\"}}",
|
34
34
|
:headers => {
|
35
35
|
'Accept' => '*/*',
|
@@ -38,11 +38,11 @@ describe BitBucket::Request do
|
|
38
38
|
'User-Agent' => 'Faraday v0.9.2'
|
39
39
|
})
|
40
40
|
|
41
|
-
fake_api.new.request(:put, '/
|
41
|
+
fake_api.new.request(:put, '/1.0/endpoint', { 'data' => { 'key' => 'value'} }, {})
|
42
42
|
end
|
43
43
|
|
44
44
|
it "supports patch" do
|
45
|
-
stub_request(:patch, "https://api.bitbucket.org/
|
45
|
+
stub_request(:patch, "https://api.bitbucket.org/1.0/endpoint").
|
46
46
|
with(:body => "{\"data\":{\"key\":\"value\"}}",
|
47
47
|
:headers => {
|
48
48
|
'Accept' => '*/*',
|
@@ -51,21 +51,21 @@ describe BitBucket::Request do
|
|
51
51
|
'User-Agent' => 'Faraday v0.9.2'
|
52
52
|
})
|
53
53
|
|
54
|
-
fake_api.new.request(:patch, '/
|
54
|
+
fake_api.new.request(:patch, '/1.0/endpoint', { 'data' => { 'key' => 'value'} }, {})
|
55
55
|
end
|
56
56
|
|
57
57
|
it "supports delete" do
|
58
|
-
stub_request(:delete, "https://api.bitbucket.org/
|
58
|
+
stub_request(:delete, "https://api.bitbucket.org/1.0/endpoint").
|
59
59
|
with(:headers => {
|
60
60
|
'Accept' => '*/*',
|
61
61
|
'Authorization' => 'Bearer 12345',
|
62
62
|
'User-Agent' => 'Faraday v0.9.2'
|
63
63
|
})
|
64
|
-
fake_api.new.request(:delete, '/
|
64
|
+
fake_api.new.request(:delete, '/1.0/endpoint', {}, {})
|
65
65
|
end
|
66
66
|
|
67
67
|
it "supports post" do
|
68
|
-
stub_request(:post, "https://api.bitbucket.org/
|
68
|
+
stub_request(:post, "https://api.bitbucket.org/1.0/endpoint").
|
69
69
|
with(:body => "{\"data\":{\"key\":\"value\"}}",
|
70
70
|
:headers => {
|
71
71
|
'Accept' => '*/*',
|
@@ -74,7 +74,7 @@ describe BitBucket::Request do
|
|
74
74
|
'User-Agent' => 'Faraday v0.9.2'
|
75
75
|
})
|
76
76
|
|
77
|
-
fake_api.new.request(:post, '/
|
77
|
+
fake_api.new.request(:post, '/1.0/endpoint', { 'data' => { 'key' => 'value'} }, {})
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -17,7 +17,7 @@ describe BitBucket::User do
|
|
17
17
|
|
18
18
|
describe '#profile' do
|
19
19
|
it 'sends the request to the right url' do
|
20
|
-
expect(@user).to receive(:request).with(:get, '/
|
20
|
+
expect(@user).to receive(:request).with(:get, '/1.0/user', {}, {})
|
21
21
|
@user.profile
|
22
22
|
end
|
23
23
|
end
|
@@ -28,49 +28,49 @@ describe BitBucket::User do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'sends the request to the right url' do
|
31
|
-
expect(@user).to receive(:request).with(:put, '/
|
31
|
+
expect(@user).to receive(:request).with(:put, '/1.0/user', params, {})
|
32
32
|
@user.update(params)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe '#privileges' do
|
37
37
|
it 'sends the request to the right url' do
|
38
|
-
expect(@user).to receive(:request).with(:get, '/
|
38
|
+
expect(@user).to receive(:request).with(:get, '/1.0/user/privileges', {}, {})
|
39
39
|
@user.privileges
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
describe '#follows' do
|
44
44
|
it 'sends the request to the right url' do
|
45
|
-
expect(@user).to receive(:request).with(:get, '/
|
45
|
+
expect(@user).to receive(:request).with(:get, '/1.0/user/follows', {}, {})
|
46
46
|
@user.follows
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
describe '#repositories' do
|
51
51
|
it 'sends the request to the right url' do
|
52
|
-
expect(@user).to receive(:request).with(:get, '/
|
52
|
+
expect(@user).to receive(:request).with(:get, '/1.0/user/repositories', {}, {})
|
53
53
|
@user.repositories
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
describe '#repos' do
|
58
58
|
it 'sends the request to the right url' do
|
59
|
-
expect(@user).to receive(:request).with(:get, '/
|
59
|
+
expect(@user).to receive(:request).with(:get, '/1.0/user/repositories', {}, {})
|
60
60
|
@user.repos
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
describe '#overview' do
|
65
65
|
it 'sends the request to the right url' do
|
66
|
-
expect(@user).to receive(:request).with(:get, '/
|
66
|
+
expect(@user).to receive(:request).with(:get, '/1.0/user/repositories/overview', {}, {})
|
67
67
|
@user.overview
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
describe '#dashboard' do
|
72
72
|
it 'sends the request to the right url' do
|
73
|
-
expect(@user).to receive(:request).with(:get, '/
|
73
|
+
expect(@user).to receive(:request).with(:get, '/1.0/user/repositories/dashboard', {}, {})
|
74
74
|
@user.dashboard
|
75
75
|
end
|
76
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitbucket_rest_api2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Cochran
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -90,16 +90,16 @@ dependencies:
|
|
90
90
|
name: simple_oauth
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- - "
|
93
|
+
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
95
|
+
version: 0.2.0
|
96
96
|
type: :runtime
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- - "
|
100
|
+
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
102
|
+
version: 0.2.0
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: rspec
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -256,6 +256,7 @@ files:
|
|
256
256
|
- lib/bitbucket_rest_api/error/invalid_options.rb
|
257
257
|
- lib/bitbucket_rest_api/error/no_events.rb
|
258
258
|
- lib/bitbucket_rest_api/error/not_found.rb
|
259
|
+
- lib/bitbucket_rest_api/error/refresh_token.rb
|
259
260
|
- lib/bitbucket_rest_api/error/required_params.rb
|
260
261
|
- lib/bitbucket_rest_api/error/service_error.rb
|
261
262
|
- lib/bitbucket_rest_api/error/service_unavailable.rb
|
@@ -263,6 +264,7 @@ files:
|
|
263
264
|
- lib/bitbucket_rest_api/error/unknown_value.rb
|
264
265
|
- lib/bitbucket_rest_api/error/unprocessable_entity.rb
|
265
266
|
- lib/bitbucket_rest_api/error/validations.rb
|
267
|
+
- lib/bitbucket_rest_api/helpers/repository_helper.rb
|
266
268
|
- lib/bitbucket_rest_api/invitations.rb
|
267
269
|
- lib/bitbucket_rest_api/issues.rb
|
268
270
|
- lib/bitbucket_rest_api/issues/comments.rb
|
@@ -281,18 +283,17 @@ files:
|
|
281
283
|
- lib/bitbucket_rest_api/repos/pull_request.rb
|
282
284
|
- lib/bitbucket_rest_api/repos/services.rb
|
283
285
|
- lib/bitbucket_rest_api/repos/sources.rb
|
286
|
+
- lib/bitbucket_rest_api/repos/statuses.rb
|
284
287
|
- lib/bitbucket_rest_api/repos/webhooks.rb
|
285
288
|
- lib/bitbucket_rest_api/request.rb
|
286
289
|
- lib/bitbucket_rest_api/request/basic_auth.rb
|
287
290
|
- lib/bitbucket_rest_api/request/jsonize.rb
|
288
291
|
- lib/bitbucket_rest_api/request/oauth.rb
|
289
292
|
- lib/bitbucket_rest_api/response.rb
|
290
|
-
- lib/bitbucket_rest_api/response/helpers.rb
|
291
293
|
- lib/bitbucket_rest_api/response/jsonize.rb
|
292
294
|
- lib/bitbucket_rest_api/response/mashify.rb
|
293
295
|
- lib/bitbucket_rest_api/response/raise_error.rb
|
294
296
|
- lib/bitbucket_rest_api/response/xmlize.rb
|
295
|
-
- lib/bitbucket_rest_api/result.rb
|
296
297
|
- lib/bitbucket_rest_api/user.rb
|
297
298
|
- lib/bitbucket_rest_api/users.rb
|
298
299
|
- lib/bitbucket_rest_api/users/account.rb
|
@@ -314,6 +315,7 @@ files:
|
|
314
315
|
- spec/bitbucket_rest_api/error/bad_events_spec.rb
|
315
316
|
- spec/bitbucket_rest_api/error/blank_value_spec.rb
|
316
317
|
- spec/bitbucket_rest_api/error/no_events_spec.rb
|
318
|
+
- spec/bitbucket_rest_api/helpers/repository_helper_spec.rb
|
317
319
|
- spec/bitbucket_rest_api/invitations_spec.rb
|
318
320
|
- spec/bitbucket_rest_api/issues/comments_spec.rb
|
319
321
|
- spec/bitbucket_rest_api/issues/components_spec.rb
|
@@ -330,6 +332,7 @@ files:
|
|
330
332
|
- spec/bitbucket_rest_api/repos/keys_spec.rb
|
331
333
|
- spec/bitbucket_rest_api/repos/pull_request_spec.rb
|
332
334
|
- spec/bitbucket_rest_api/repos/sources_spec.rb
|
335
|
+
- spec/bitbucket_rest_api/repos/statuses_spec.rb
|
333
336
|
- spec/bitbucket_rest_api/repos/webhooks_spec.rb
|
334
337
|
- spec/bitbucket_rest_api/repos_spec.rb
|
335
338
|
- spec/bitbucket_rest_api/request/jsonize_spec.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'faraday'
|
4
|
-
|
5
|
-
module BitBucket
|
6
|
-
class Response::Helpers < Response
|
7
|
-
|
8
|
-
def on_complete(env)
|
9
|
-
env[:body].class.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
|
10
|
-
include BitBucket::Result
|
11
|
-
|
12
|
-
def env
|
13
|
-
@env
|
14
|
-
end
|
15
|
-
|
16
|
-
RUBY_EVAL
|
17
|
-
env[:body].instance_eval { @env = env }
|
18
|
-
end
|
19
|
-
|
20
|
-
end # Response::Helpers
|
21
|
-
end # BitBucket
|