tinybucket 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -1
- data/Gemfile +8 -7
- data/README.md +28 -5
- data/Rakefile +1 -0
- data/lib/faraday_middleware/follow_oauth_redirects.rb +5 -2
- data/lib/tinybucket.rb +2 -0
- data/lib/tinybucket/api.rb +3 -0
- data/lib/tinybucket/api/base_api.rb +2 -0
- data/lib/tinybucket/api/branch_restrictions_api.rb +6 -5
- data/lib/tinybucket/api/branches_api.rb +48 -0
- data/lib/tinybucket/api/build_status_api.rb +15 -1
- data/lib/tinybucket/api/comments_api.rb +7 -6
- data/lib/tinybucket/api/commits_api.rb +25 -4
- data/lib/tinybucket/api/diff_api.rb +4 -3
- data/lib/tinybucket/api/helper.rb +3 -0
- data/lib/tinybucket/api/helper/api_helper.rb +2 -0
- data/lib/tinybucket/api/helper/branch_restrictions_helper.rb +2 -0
- data/lib/tinybucket/api/helper/branches_helper.rb +29 -0
- data/lib/tinybucket/api/helper/build_status_helper.rb +11 -0
- data/lib/tinybucket/api/helper/comments_helper.rb +2 -0
- data/lib/tinybucket/api/helper/commits_helper.rb +8 -0
- data/lib/tinybucket/api/helper/diff_helper.rb +2 -0
- data/lib/tinybucket/api/helper/pull_requests_helper.rb +2 -0
- data/lib/tinybucket/api/helper/repo_helper.rb +2 -0
- data/lib/tinybucket/api/helper/repos_helper.rb +2 -0
- data/lib/tinybucket/api/helper/team_helper.rb +2 -0
- data/lib/tinybucket/api/helper/user_helper.rb +2 -0
- data/lib/tinybucket/api/pull_requests_api.rb +4 -3
- data/lib/tinybucket/api/repo_api.rb +4 -3
- data/lib/tinybucket/api/repos_api.rb +3 -1
- data/lib/tinybucket/api/team_api.rb +4 -2
- data/lib/tinybucket/api/user_api.rb +3 -1
- data/lib/tinybucket/api_factory.rb +2 -0
- data/lib/tinybucket/client.rb +3 -2
- data/lib/tinybucket/config.rb +5 -1
- data/lib/tinybucket/connection.rb +21 -8
- data/lib/tinybucket/constants.rb +2 -0
- data/lib/tinybucket/enumerator.rb +2 -0
- data/lib/tinybucket/error.rb +2 -0
- data/lib/tinybucket/error/base_error.rb +2 -0
- data/lib/tinybucket/error/conflict.rb +2 -0
- data/lib/tinybucket/error/not_found.rb +2 -0
- data/lib/tinybucket/error/service_error.rb +2 -0
- data/lib/tinybucket/iterator.rb +4 -2
- data/lib/tinybucket/model.rb +3 -0
- data/lib/tinybucket/model/base.rb +2 -2
- data/lib/tinybucket/model/branch.rb +48 -0
- data/lib/tinybucket/model/branch_restriction.rb +4 -2
- data/lib/tinybucket/model/build_status.rb +3 -1
- data/lib/tinybucket/model/comment.rb +4 -2
- data/lib/tinybucket/model/commit.rb +6 -2
- data/lib/tinybucket/model/concerns.rb +2 -0
- data/lib/tinybucket/model/concerns/acceptable_attributes.rb +2 -0
- data/lib/tinybucket/model/concerns/api_callable.rb +2 -0
- data/lib/tinybucket/model/concerns/enumerable.rb +2 -0
- data/lib/tinybucket/model/concerns/reloadable.rb +2 -0
- data/lib/tinybucket/model/concerns/repository_keys.rb +2 -0
- data/lib/tinybucket/model/error_response.rb +4 -2
- data/lib/tinybucket/model/page.rb +4 -2
- data/lib/tinybucket/model/profile.rb +4 -2
- data/lib/tinybucket/model/pull_request.rb +4 -2
- data/lib/tinybucket/model/repository.rb +31 -5
- data/lib/tinybucket/model/team.rb +4 -2
- data/lib/tinybucket/null_logger.rb +2 -0
- data/lib/tinybucket/parser.rb +5 -0
- data/lib/tinybucket/parser/base_parser.rb +3 -2
- data/lib/tinybucket/parser/branch_parser.rb +13 -0
- data/lib/tinybucket/parser/branch_restriction_parser.rb +2 -0
- data/lib/tinybucket/parser/branch_restrictions_parser.rb +2 -0
- data/lib/tinybucket/parser/branches_parser.rb +11 -0
- data/lib/tinybucket/parser/build_status_parser.rb +2 -0
- data/lib/tinybucket/parser/builds_parser.rb +11 -0
- data/lib/tinybucket/parser/comment_parser.rb +2 -0
- data/lib/tinybucket/parser/comments_parser.rb +2 -0
- data/lib/tinybucket/parser/commit_parser.rb +2 -0
- data/lib/tinybucket/parser/commits_parser.rb +2 -0
- data/lib/tinybucket/parser/profile_parser.rb +2 -0
- data/lib/tinybucket/parser/profiles_parser.rb +2 -0
- data/lib/tinybucket/parser/pull_request_parser.rb +2 -0
- data/lib/tinybucket/parser/pull_requests_parser.rb +2 -0
- data/lib/tinybucket/parser/repo_parser.rb +2 -0
- data/lib/tinybucket/parser/repos_parser.rb +2 -0
- data/lib/tinybucket/parser/team_parser.rb +2 -0
- data/lib/tinybucket/parser/teams_parser.rb +2 -0
- data/lib/tinybucket/request.rb +2 -0
- data/lib/tinybucket/resource.rb +3 -0
- data/lib/tinybucket/resource/base.rb +6 -0
- data/lib/tinybucket/resource/branch_restrictions.rb +2 -0
- data/lib/tinybucket/resource/branches.rb +35 -0
- data/lib/tinybucket/resource/commit/base.rb +2 -0
- data/lib/tinybucket/resource/commit/build_statuses.rb +6 -3
- data/lib/tinybucket/resource/commit/comments.rb +2 -0
- data/lib/tinybucket/resource/commits.rb +13 -0
- data/lib/tinybucket/resource/forks.rb +2 -0
- data/lib/tinybucket/resource/pull_request/base.rb +2 -0
- data/lib/tinybucket/resource/pull_request/comments.rb +2 -0
- data/lib/tinybucket/resource/pull_request/commits.rb +2 -0
- data/lib/tinybucket/resource/pull_requests.rb +2 -0
- data/lib/tinybucket/resource/repos.rb +2 -0
- data/lib/tinybucket/resource/team/base.rb +2 -0
- data/lib/tinybucket/resource/team/followers.rb +2 -0
- data/lib/tinybucket/resource/team/following.rb +2 -0
- data/lib/tinybucket/resource/team/members.rb +2 -0
- data/lib/tinybucket/resource/team/repos.rb +2 -0
- data/lib/tinybucket/resource/user/base.rb +2 -0
- data/lib/tinybucket/resource/user/followers.rb +2 -0
- data/lib/tinybucket/resource/user/following.rb +2 -0
- data/lib/tinybucket/resource/user/repos.rb +2 -0
- data/lib/tinybucket/resource/watchers.rb +2 -0
- data/lib/tinybucket/response.rb +2 -0
- data/lib/tinybucket/response/handler.rb +2 -0
- data/lib/tinybucket/version.rb +3 -1
- data/tinybucket.gemspec +1 -1
- metadata +11 -193
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -33
- data/.rspec +0 -1
- data/.travis.yml +0 -13
- data/Guardfile +0 -13
- data/spec/fixtures/branch_restriction.json +0 -17
- data/spec/fixtures/build_status.json +0 -16
- data/spec/fixtures/comment.json +0 -30
- data/spec/fixtures/commit.json +0 -83
- data/spec/fixtures/profile.json +0 -29
- data/spec/fixtures/pull_request.json +0 -106
- data/spec/fixtures/repositories/get.json +0 -78
- data/spec/fixtures/repositories/test_owner/get.json +0 -78
- data/spec/fixtures/repositories/test_owner/test_repo/branch-restrictions/1/get.json +0 -17
- data/spec/fixtures/repositories/test_owner/test_repo/branch-restrictions/get.json +0 -101
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/approve/post.json +0 -16
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/comments/1/get.json +0 -38
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/comments/get.json +0 -40
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/get.json +0 -83
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/statuses/build/post.json +0 -16
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/statuses/build/test_status/get.json +0 -16
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/statuses/build/test_status/put.json +0 -16
- data/spec/fixtures/repositories/test_owner/test_repo/commits/get.json +0 -73
- data/spec/fixtures/repositories/test_owner/test_repo/diff/1/get.json +0 -21
- data/spec/fixtures/repositories/test_owner/test_repo/forks/get.json +0 -78
- data/spec/fixtures/repositories/test_owner/test_repo/get.json +0 -71
- data/spec/fixtures/repositories/test_owner/test_repo/patch/1/get.json +0 -29
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/approve/delete.json +0 -3
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/approve/post.json +0 -3
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/comments/1/get.json +0 -30
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/comments/get.json +0 -44
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/commits/get.json +0 -66
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/decline/post.json +0 -116
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/diff/get.txt +0 -13
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/get.json +0 -164
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/merge/post.json +0 -123
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get.json +0 -112
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get_state_declined.json +0 -112
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get_state_merged.json +0 -112
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get_state_open.json +0 -112
- data/spec/fixtures/repositories/test_owner/test_repo/watchers/get.json +0 -32
- data/spec/fixtures/repository.json +0 -72
- data/spec/fixtures/team.json +0 -32
- data/spec/fixtures/teams/test_team/followers/get.json +0 -36
- data/spec/fixtures/teams/test_team/following/get.json +0 -39
- data/spec/fixtures/teams/test_team/get.json +0 -32
- data/spec/fixtures/teams/test_team/members/get.json +0 -36
- data/spec/fixtures/teams/test_team/repositories/get.json +0 -125
- data/spec/fixtures/users/test_owner/followers/get.json +0 -65
- data/spec/fixtures/users/test_owner/following/get.json +0 -100
- data/spec/fixtures/users/test_owner/get.json +0 -29
- data/spec/lib/tinybucket/api/branch_restrictions_api_spec.rb +0 -77
- data/spec/lib/tinybucket/api/build_status_api_spec.rb +0 -65
- data/spec/lib/tinybucket/api/comments_api_spec.rb +0 -132
- data/spec/lib/tinybucket/api/commits_api_spec.rb +0 -152
- data/spec/lib/tinybucket/api/diff_api_spec.rb +0 -5
- data/spec/lib/tinybucket/api/pull_requests_api_spec.rb +0 -259
- data/spec/lib/tinybucket/api/repo_api_spec.rb +0 -99
- data/spec/lib/tinybucket/api/repos_api_spec.rb +0 -27
- data/spec/lib/tinybucket/api/team_api_spec.rb +0 -82
- data/spec/lib/tinybucket/api/user_api_spec.rb +0 -73
- data/spec/lib/tinybucket/api_factory_spec.rb +0 -18
- data/spec/lib/tinybucket/client_spec.rb +0 -100
- data/spec/lib/tinybucket/connection_spec.rb +0 -30
- data/spec/lib/tinybucket/error/service_error_spec.rb +0 -23
- data/spec/lib/tinybucket/model/branch_restriction_spec.rb +0 -35
- data/spec/lib/tinybucket/model/build_status_spec.rb +0 -66
- data/spec/lib/tinybucket/model/comment_spec.rb +0 -37
- data/spec/lib/tinybucket/model/commit_spec.rb +0 -108
- data/spec/lib/tinybucket/model/page_spec.rb +0 -28
- data/spec/lib/tinybucket/model/profile_spec.rb +0 -52
- data/spec/lib/tinybucket/model/pull_request_spec.rb +0 -141
- data/spec/lib/tinybucket/model/repository_spec.rb +0 -131
- data/spec/lib/tinybucket/model/team_spec.rb +0 -70
- data/spec/lib/tinybucket/null_logger_spec.rb +0 -53
- data/spec/lib/tinybucket/resource/branch_restrictions_spec.rb +0 -60
- data/spec/lib/tinybucket/resource/commit/build_statuses_spec.rb +0 -50
- data/spec/lib/tinybucket/resource/commit/comments_spec.rb +0 -49
- data/spec/lib/tinybucket/resource/commits_spec.rb +0 -43
- data/spec/lib/tinybucket/resource/forks_spec.rb +0 -36
- data/spec/lib/tinybucket/resource/pull_request/comments_spec.rb +0 -41
- data/spec/lib/tinybucket/resource/pull_request/commits_spec.rb +0 -41
- data/spec/lib/tinybucket/resource/pull_requests_spec.rb +0 -59
- data/spec/lib/tinybucket/resource/repos_spec.rb +0 -76
- data/spec/lib/tinybucket/resource/team/followers_spec.rb +0 -27
- data/spec/lib/tinybucket/resource/team/following_spec.rb +0 -27
- data/spec/lib/tinybucket/resource/team/members_spec.rb +0 -27
- data/spec/lib/tinybucket/resource/team/repos_spec.rb +0 -27
- data/spec/lib/tinybucket/resource/user/followers_spec.rb +0 -27
- data/spec/lib/tinybucket/resource/user/following_spec.rb +0 -27
- data/spec/lib/tinybucket/resource/user/repos_spec.rb +0 -27
- data/spec/lib/tinybucket/resource/watchers_spec.rb +0 -38
- data/spec/lib/tinybucket_spec.rb +0 -42
- data/spec/spec_helper.rb +0 -45
- data/spec/support/api_response_macros.rb +0 -74
- data/spec/support/fixture_macros.rb +0 -5
- data/spec/support/model_macros.rb +0 -103
@@ -1,132 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Tinybucket::Api::CommentsApi do
|
4
|
-
include ApiResponseMacros
|
5
|
-
|
6
|
-
let(:request_path) { nil }
|
7
|
-
let(:owner) { 'test_owner' }
|
8
|
-
let(:slug) { 'test_repo' }
|
9
|
-
let(:options) { {} }
|
10
|
-
|
11
|
-
let(:commit_hash) { '1' }
|
12
|
-
let(:commit) do
|
13
|
-
m = Tinybucket::Model::Commit.new({})
|
14
|
-
m.repo_owner = owner
|
15
|
-
m.repo_slug = slug
|
16
|
-
m.hash = commit_hash
|
17
|
-
m
|
18
|
-
end
|
19
|
-
|
20
|
-
let(:pullreq_id) { '1' }
|
21
|
-
let(:pullreq) do
|
22
|
-
m = Tinybucket::Model::PullRequest.new({})
|
23
|
-
m.repo_owner = owner
|
24
|
-
m.repo_slug = slug
|
25
|
-
m.id = pullreq_id
|
26
|
-
m
|
27
|
-
end
|
28
|
-
|
29
|
-
let(:commented_to) { nil }
|
30
|
-
let(:api) do
|
31
|
-
api = Tinybucket::Api::CommentsApi.new
|
32
|
-
api.repo_owner = owner
|
33
|
-
api.repo_slug = slug
|
34
|
-
api.commented_to = commented_to if commented_to.present?
|
35
|
-
api
|
36
|
-
end
|
37
|
-
|
38
|
-
it { expect(api).to be_a_kind_of(Tinybucket::Api::BaseApi) }
|
39
|
-
|
40
|
-
before { stub_apiresponse(:get, request_path) if request_path }
|
41
|
-
|
42
|
-
describe '#list' do
|
43
|
-
subject { api.list(options) }
|
44
|
-
let(:commented_to) { commit }
|
45
|
-
|
46
|
-
context 'when without owner' do
|
47
|
-
let(:owner) { nil }
|
48
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'when without slug' do
|
52
|
-
let(:slug) { nil }
|
53
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'when without commented_to' do
|
57
|
-
let(:commented_to) { nil }
|
58
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'when with unknown commented_to' do
|
62
|
-
let(:commented_to) { {} }
|
63
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
64
|
-
end
|
65
|
-
|
66
|
-
context 'when commented_to is commit' do
|
67
|
-
let(:commented_to) { commit }
|
68
|
-
let(:request_path) do
|
69
|
-
"/repositories/#{owner}/#{slug}/commit/#{commit_hash}/comments"
|
70
|
-
end
|
71
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'when commented_to is pullreq' do
|
75
|
-
let(:commented_to) { pullreq }
|
76
|
-
let(:request_path) do
|
77
|
-
"/repositories/#{owner}/#{slug}/pullrequests/#{pullreq_id}/comments"
|
78
|
-
end
|
79
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe '#find' do
|
84
|
-
subject { api.find(comment_id, options) }
|
85
|
-
let(:commented_to) { commit }
|
86
|
-
let(:comment_id) { '1' }
|
87
|
-
|
88
|
-
context 'when without owner' do
|
89
|
-
let(:owner) { nil }
|
90
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
91
|
-
end
|
92
|
-
|
93
|
-
context 'when without slug' do
|
94
|
-
let(:slug) { nil }
|
95
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
96
|
-
end
|
97
|
-
|
98
|
-
context 'when without commented_to' do
|
99
|
-
let(:commented_to) { nil }
|
100
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
101
|
-
end
|
102
|
-
|
103
|
-
context 'when with unknown commented_to' do
|
104
|
-
let(:commented_to) { {} }
|
105
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
106
|
-
end
|
107
|
-
|
108
|
-
context 'when commented_to is commit' do
|
109
|
-
let(:commented_to) { commit }
|
110
|
-
let(:request_path) do
|
111
|
-
"/repositories/#{owner}/#{slug}/commit/#{commit_hash}" \
|
112
|
-
"/comments/#{comment_id}"
|
113
|
-
end
|
114
|
-
it 'return Comment model' do
|
115
|
-
expect(subject).to be_an_instance_of(Tinybucket::Model::Comment)
|
116
|
-
expect(subject.commented_to).to eq(commit)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
context 'when commented_to is pull_request' do
|
121
|
-
let(:commented_to) { pullreq }
|
122
|
-
let(:request_path) do
|
123
|
-
"/repositories/#{owner}/#{slug}/pullrequests/#{pullreq_id}" \
|
124
|
-
"/comments/#{comment_id}"
|
125
|
-
end
|
126
|
-
it 'return Comment model' do
|
127
|
-
expect(subject).to be_an_instance_of(Tinybucket::Model::Comment)
|
128
|
-
expect(subject.commented_to).to eq(pullreq)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
@@ -1,152 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Tinybucket::Api::CommitsApi do
|
4
|
-
include ApiResponseMacros
|
5
|
-
|
6
|
-
let(:request_path) { nil }
|
7
|
-
let(:owner) { 'test_owner' }
|
8
|
-
let(:slug) { 'test_repo' }
|
9
|
-
let(:options) { {} }
|
10
|
-
|
11
|
-
let(:api) do
|
12
|
-
api = Tinybucket::Api::CommitsApi.new
|
13
|
-
api.repo_owner = owner
|
14
|
-
api.repo_slug = slug
|
15
|
-
api
|
16
|
-
end
|
17
|
-
|
18
|
-
it { expect(api).to be_a_kind_of(Tinybucket::Api::BaseApi) }
|
19
|
-
|
20
|
-
let(:request_method) { :get }
|
21
|
-
let(:stub_options) { nil }
|
22
|
-
|
23
|
-
before do
|
24
|
-
if request_path
|
25
|
-
opts = stub_options.present? ? stub_options : {}
|
26
|
-
stub_apiresponse(request_method, request_path, opts)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe 'list' do
|
31
|
-
subject { api.list(options) }
|
32
|
-
|
33
|
-
context 'without owner' do
|
34
|
-
let(:owner) { nil }
|
35
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'without slug' do
|
39
|
-
let(:slug) { nil }
|
40
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'with owner and slug' do
|
44
|
-
let(:request_path) { "/repositories/#{owner}/#{slug}/commits" }
|
45
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe 'find' do
|
50
|
-
let(:revision) { '1' }
|
51
|
-
subject { api.find(revision, options) }
|
52
|
-
|
53
|
-
context 'without owner' do
|
54
|
-
let(:owner) { nil }
|
55
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'without slug' do
|
59
|
-
let(:slug) { nil }
|
60
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'with owner and slug' do
|
64
|
-
let(:request_path) do
|
65
|
-
"/repositories/#{owner}/#{slug}/commit/#{revision}"
|
66
|
-
end
|
67
|
-
it { expect(subject).to be_instance_of(Tinybucket::Model::Commit) }
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe 'approve' do
|
72
|
-
let(:revision) { '1' }
|
73
|
-
let(:request_method) { :post }
|
74
|
-
|
75
|
-
subject { api.approve(revision, options) }
|
76
|
-
|
77
|
-
context 'without owner' do
|
78
|
-
let(:owner) { nil }
|
79
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'without slug' do
|
83
|
-
let(:slug) { nil }
|
84
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
85
|
-
end
|
86
|
-
|
87
|
-
context 'when pull request is not yet approved' do
|
88
|
-
let(:request_path) do
|
89
|
-
"/repositories/#{owner}/#{slug}/commit/#{revision}/approve"
|
90
|
-
end
|
91
|
-
|
92
|
-
it { expect(subject).to be_truthy }
|
93
|
-
end
|
94
|
-
|
95
|
-
context 'when pull request is already approved.' do
|
96
|
-
let(:request_path) do
|
97
|
-
"/repositories/#{owner}/#{slug}/commit/#{revision}/approve"
|
98
|
-
end
|
99
|
-
|
100
|
-
let(:stub_options) do
|
101
|
-
{
|
102
|
-
status_code: 409,
|
103
|
-
message: JSON.generate(
|
104
|
-
error: { message: 'You already approved this pull request.' }
|
105
|
-
)
|
106
|
-
}
|
107
|
-
end
|
108
|
-
it { expect(subject).to be_truthy }
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe 'unapprove' do
|
113
|
-
let(:revision) { '1' }
|
114
|
-
let(:request_method) { :delete }
|
115
|
-
subject { api.unapprove(revision) }
|
116
|
-
|
117
|
-
context 'without owner' do
|
118
|
-
let(:owner) { nil }
|
119
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
120
|
-
end
|
121
|
-
|
122
|
-
context 'without slug' do
|
123
|
-
let(:slug) { nil }
|
124
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
125
|
-
end
|
126
|
-
|
127
|
-
context 'when commit is not yet approved' do
|
128
|
-
let(:request_path) do
|
129
|
-
"/repositories/#{owner}/#{slug}/commit/#{revision}/approve"
|
130
|
-
end
|
131
|
-
|
132
|
-
let(:stub_options) do
|
133
|
-
{
|
134
|
-
status_code: 404,
|
135
|
-
message: JSON.generate(
|
136
|
-
error: { message: 'You haven\'t approve this pull request.' }
|
137
|
-
)
|
138
|
-
}
|
139
|
-
end
|
140
|
-
it { expect(subject).to be_truthy }
|
141
|
-
end
|
142
|
-
|
143
|
-
context 'when commit is already approved' do
|
144
|
-
let(:request_path) do
|
145
|
-
"/repositories/#{owner}/#{slug}/commit/#{revision}/approve"
|
146
|
-
end
|
147
|
-
let(:stub_options) { { status_code: 204, message: '' } }
|
148
|
-
|
149
|
-
it { expect(subject).to be_truthy }
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
@@ -1,259 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Tinybucket::Api::PullRequestsApi do
|
4
|
-
include ApiResponseMacros
|
5
|
-
|
6
|
-
let(:api) do
|
7
|
-
api = Tinybucket::Api::PullRequestsApi.new
|
8
|
-
api.repo_owner = owner
|
9
|
-
api.repo_slug = slug
|
10
|
-
api
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:owner) { 'test_owner' }
|
14
|
-
let(:slug) { 'test_repo' }
|
15
|
-
let(:request_path) { nil }
|
16
|
-
let(:request_method) { :get }
|
17
|
-
let(:stub_options) { nil }
|
18
|
-
|
19
|
-
it { expect(api).to be_a_kind_of(Tinybucket::Api::BaseApi) }
|
20
|
-
|
21
|
-
before do
|
22
|
-
if request_path
|
23
|
-
opts = stub_options.present? ? stub_options : {}
|
24
|
-
stub_apiresponse(request_method, request_path, opts)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe 'list' do
|
29
|
-
let(:options) { {} }
|
30
|
-
|
31
|
-
subject { api.list(options) }
|
32
|
-
|
33
|
-
context 'without repo_owner and repo_slug' do
|
34
|
-
let(:owner) { nil }
|
35
|
-
let(:slug) { nil }
|
36
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'without repo_owner' do
|
40
|
-
let(:owner) { nil }
|
41
|
-
let(:slug) { 'test_repo' }
|
42
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'without repo_slug' do
|
46
|
-
let(:owner) { 'test_owner' }
|
47
|
-
let(:slug) { nil }
|
48
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'with repo_owner and repo_slug' do
|
52
|
-
let(:request_path) { "/repositories/#{owner}/#{slug}/pullrequests" }
|
53
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'when request with state' do
|
57
|
-
let(:options) { { state: state } }
|
58
|
-
let(:request_path) do
|
59
|
-
"/repositories/#{owner}/#{slug}/pullrequests?state=#{state}"
|
60
|
-
end
|
61
|
-
|
62
|
-
context 'when state is OPEN' do
|
63
|
-
let(:state) { 'open' }
|
64
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'when state is DECLINED' do
|
68
|
-
let(:state) { 'declined' }
|
69
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'when state is MERGED' do
|
73
|
-
let(:state) { 'merged' }
|
74
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe 'find' do
|
80
|
-
let(:pr_id) { 1 }
|
81
|
-
subject { api.find(pr_id) }
|
82
|
-
|
83
|
-
context 'when without repo_owner and repo_slug' do
|
84
|
-
let(:owner) { nil }
|
85
|
-
let(:slug) { nil }
|
86
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
87
|
-
end
|
88
|
-
|
89
|
-
context 'when without repo_owner' do
|
90
|
-
let(:owner) { nil }
|
91
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
92
|
-
end
|
93
|
-
|
94
|
-
context 'when without repo_slug' do
|
95
|
-
let(:slug) { nil }
|
96
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
97
|
-
end
|
98
|
-
|
99
|
-
context 'when with repo_owner and repo_slug' do
|
100
|
-
let(:request_path) do
|
101
|
-
"/repositories/#{owner}/#{slug}/pullrequests/#{pr_id}"
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'return pull request model' do
|
105
|
-
expect(subject).to be_an_instance_of(Tinybucket::Model::PullRequest)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe 'commits' do
|
111
|
-
let(:pr_id) { 1 }
|
112
|
-
subject { api.commits(pr_id) }
|
113
|
-
|
114
|
-
context 'when without repo_owner and repo_slug' do
|
115
|
-
let(:owner) { nil }
|
116
|
-
let(:slug) { nil }
|
117
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
118
|
-
end
|
119
|
-
|
120
|
-
context 'when without repo_owner' do
|
121
|
-
let(:owner) { nil }
|
122
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
123
|
-
end
|
124
|
-
|
125
|
-
context 'when without repo_slug' do
|
126
|
-
let(:slug) { nil }
|
127
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
128
|
-
end
|
129
|
-
|
130
|
-
context 'when with repo_owner and repo_slug' do
|
131
|
-
let(:request_path) do
|
132
|
-
"/repositories/#{owner}/#{slug}/pullrequests/1/commits"
|
133
|
-
end
|
134
|
-
it 'return page model which contains commit models' do
|
135
|
-
expect(subject).to be_an_instance_of(Tinybucket::Model::Page)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
describe 'approve' do
|
141
|
-
let(:pr_id) { 1 }
|
142
|
-
let(:request_method) { :post }
|
143
|
-
subject { api.approve(pr_id) }
|
144
|
-
|
145
|
-
context 'when without repo_owner and repo_slug' do
|
146
|
-
let(:owner) { nil }
|
147
|
-
let(:slug) { nil }
|
148
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
149
|
-
end
|
150
|
-
|
151
|
-
context 'when without repo_owner' do
|
152
|
-
let(:owner) { nil }
|
153
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
154
|
-
end
|
155
|
-
|
156
|
-
context 'when without repo_slug' do
|
157
|
-
let(:slug) { nil }
|
158
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
159
|
-
end
|
160
|
-
|
161
|
-
context 'when with repo_owner and repo_slug' do
|
162
|
-
let(:request_path) do
|
163
|
-
"/repositories/#{owner}/#{slug}/pullrequests/1/approve"
|
164
|
-
end
|
165
|
-
context 'when pull request is not yet approved.' do
|
166
|
-
it { expect(subject).to be_truthy }
|
167
|
-
end
|
168
|
-
context 'when pull request is already approved.' do
|
169
|
-
let(:stub_options) do
|
170
|
-
{
|
171
|
-
status_code: 409,
|
172
|
-
message: JSON.generate(
|
173
|
-
error: { message: 'You already approved this pull request.' }
|
174
|
-
)
|
175
|
-
}
|
176
|
-
end
|
177
|
-
it { expect(subject).to be_truthy }
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
describe 'unapprove' do
|
183
|
-
let(:pr_id) { 1 }
|
184
|
-
let(:request_method) { :delete }
|
185
|
-
subject { api.unapprove(pr_id) }
|
186
|
-
|
187
|
-
context 'when without repo_owner and repo_slug' do
|
188
|
-
let(:owner) { nil }
|
189
|
-
let(:slug) { nil }
|
190
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
191
|
-
end
|
192
|
-
|
193
|
-
context 'when without repo_owner' do
|
194
|
-
let(:owner) { nil }
|
195
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
196
|
-
end
|
197
|
-
|
198
|
-
context 'when without repo_slug' do
|
199
|
-
let(:slug) { nil }
|
200
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
201
|
-
end
|
202
|
-
|
203
|
-
context 'when with repo_owner and repo_slug' do
|
204
|
-
let(:request_path) do
|
205
|
-
"/repositories/#{owner}/#{slug}/pullrequests/1/approve"
|
206
|
-
end
|
207
|
-
|
208
|
-
context 'when pull request is approved' do
|
209
|
-
# In this case, bitbucket api respond '204 No content'.
|
210
|
-
let(:stub_options) { { status_code: 204, message: '' } }
|
211
|
-
it { expect(subject).to be_truthy }
|
212
|
-
end
|
213
|
-
|
214
|
-
context 'when pull request is not approved yet.' do
|
215
|
-
# In this case, bitbucket api respond '404 NotFound'.
|
216
|
-
let(:stub_options) do
|
217
|
-
{
|
218
|
-
status_code: 404,
|
219
|
-
message: JSON.generate(
|
220
|
-
error: { message: 'You haven\'t approve this pull request.' }
|
221
|
-
)
|
222
|
-
}
|
223
|
-
end
|
224
|
-
it { expect(subject).to be_truthy }
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
describe 'diff' do
|
230
|
-
let(:pr_id) { 1 }
|
231
|
-
subject { api.diff(pr_id) }
|
232
|
-
|
233
|
-
context 'when without repo_owner and repo_slug' do
|
234
|
-
let(:owner) { nil }
|
235
|
-
let(:slug) { nil }
|
236
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
237
|
-
end
|
238
|
-
|
239
|
-
context 'when without repo_owner' do
|
240
|
-
let(:owner) { nil }
|
241
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
242
|
-
end
|
243
|
-
|
244
|
-
context 'when without repo_slug' do
|
245
|
-
let(:slug) { nil }
|
246
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
247
|
-
end
|
248
|
-
|
249
|
-
context 'when with repo_owner and repo_slug' do
|
250
|
-
let(:stub_options) do
|
251
|
-
{ content_type: 'plain/text' }
|
252
|
-
end
|
253
|
-
let(:request_path) do
|
254
|
-
"/repositories/#{owner}/#{slug}/pullrequests/1/diff"
|
255
|
-
end
|
256
|
-
it { expect(subject).to be_instance_of(String) }
|
257
|
-
end
|
258
|
-
end
|
259
|
-
end
|