brat 0.1.1
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 +7 -0
- data/.gitignore +20 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +24 -0
- data/README.md +103 -0
- data/Rakefile +9 -0
- data/bin/brat +7 -0
- data/brat.gemspec +26 -0
- data/lib/brat.rb +37 -0
- data/lib/brat/api.rb +17 -0
- data/lib/brat/cli.rb +47 -0
- data/lib/brat/cli_helpers.rb +175 -0
- data/lib/brat/client.rb +18 -0
- data/lib/brat/client/branches.rb +79 -0
- data/lib/brat/client/groups.rb +88 -0
- data/lib/brat/client/issues.rb +92 -0
- data/lib/brat/client/merge_requests.rb +107 -0
- data/lib/brat/client/milestones.rb +57 -0
- data/lib/brat/client/notes.rb +106 -0
- data/lib/brat/client/projects.rb +298 -0
- data/lib/brat/client/repositories.rb +78 -0
- data/lib/brat/client/snippets.rb +86 -0
- data/lib/brat/client/system_hooks.rb +58 -0
- data/lib/brat/client/users.rb +123 -0
- data/lib/brat/configuration.rb +40 -0
- data/lib/brat/error.rb +42 -0
- data/lib/brat/help.rb +44 -0
- data/lib/brat/objectified_hash.rb +24 -0
- data/lib/brat/request.rb +101 -0
- data/lib/brat/shell.rb +49 -0
- data/lib/brat/version.rb +3 -0
- data/spec/brat/cli_spec.rb +80 -0
- data/spec/brat/client/branches_spec.rb +103 -0
- data/spec/brat/client/groups_spec.rb +111 -0
- data/spec/brat/client/issues_spec.rb +122 -0
- data/spec/brat/client/merge_requests_spec.rb +124 -0
- data/spec/brat/client/milestones_spec.rb +66 -0
- data/spec/brat/client/notes_spec.rb +156 -0
- data/spec/brat/client/projects_spec.rb +357 -0
- data/spec/brat/client/repositories_spec.rb +92 -0
- data/spec/brat/client/snippets_spec.rb +85 -0
- data/spec/brat/client/system_hooks_spec.rb +69 -0
- data/spec/brat/client/users_spec.rb +192 -0
- data/spec/brat/objectified_hash_spec.rb +23 -0
- data/spec/brat/request_spec.rb +48 -0
- data/spec/brat_spec.rb +65 -0
- data/spec/fixtures/branch.json +1 -0
- data/spec/fixtures/branches.json +1 -0
- data/spec/fixtures/comment_merge_request.json +1 -0
- data/spec/fixtures/create_branch.json +1 -0
- data/spec/fixtures/create_merge_request.json +1 -0
- data/spec/fixtures/error_already_exists.json +1 -0
- data/spec/fixtures/group.json +60 -0
- data/spec/fixtures/group_create.json +1 -0
- data/spec/fixtures/group_member.json +1 -0
- data/spec/fixtures/group_member_delete.json +1 -0
- data/spec/fixtures/group_members.json +1 -0
- data/spec/fixtures/groups.json +2 -0
- data/spec/fixtures/issue.json +1 -0
- data/spec/fixtures/issues.json +1 -0
- data/spec/fixtures/key.json +1 -0
- data/spec/fixtures/keys.json +1 -0
- data/spec/fixtures/merge_request.json +1 -0
- data/spec/fixtures/merge_request_comments.json +1 -0
- data/spec/fixtures/merge_requests.json +1 -0
- data/spec/fixtures/milestone.json +1 -0
- data/spec/fixtures/milestones.json +1 -0
- data/spec/fixtures/note.json +1 -0
- data/spec/fixtures/notes.json +1 -0
- data/spec/fixtures/project.json +1 -0
- data/spec/fixtures/project_commit.json +13 -0
- data/spec/fixtures/project_commit_diff.json +10 -0
- data/spec/fixtures/project_commits.json +1 -0
- data/spec/fixtures/project_delete_key.json +8 -0
- data/spec/fixtures/project_events.json +1 -0
- data/spec/fixtures/project_for_user.json +1 -0
- data/spec/fixtures/project_fork_link.json +1 -0
- data/spec/fixtures/project_hook.json +1 -0
- data/spec/fixtures/project_hooks.json +1 -0
- data/spec/fixtures/project_issues.json +1 -0
- data/spec/fixtures/project_key.json +6 -0
- data/spec/fixtures/project_keys.json +6 -0
- data/spec/fixtures/project_tags.json +1 -0
- data/spec/fixtures/projects.json +1 -0
- data/spec/fixtures/protect_branch.json +1 -0
- data/spec/fixtures/session.json +1 -0
- data/spec/fixtures/snippet.json +1 -0
- data/spec/fixtures/snippets.json +1 -0
- data/spec/fixtures/system_hook.json +1 -0
- data/spec/fixtures/system_hook_test.json +1 -0
- data/spec/fixtures/system_hooks.json +1 -0
- data/spec/fixtures/tag.json +1 -0
- data/spec/fixtures/team_member.json +1 -0
- data/spec/fixtures/team_members.json +1 -0
- data/spec/fixtures/unprotect_branch.json +1 -0
- data/spec/fixtures/update_merge_request.json +1 -0
- data/spec/fixtures/user.json +1 -0
- data/spec/fixtures/users.json +1 -0
- data/spec/spec_helper.rb +74 -0
- metadata +281 -0
data/lib/brat/version.rb
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Brat::CLI do
|
|
4
|
+
describe ".run" do
|
|
5
|
+
context "when command is version" do
|
|
6
|
+
it "should show gem version" do
|
|
7
|
+
output = capture_output { Brat::CLI.run('-v') }
|
|
8
|
+
expect(output).to eq("Brat Ruby Gem #{Brat::VERSION}\n")
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context "when command is info" do
|
|
13
|
+
it "should show environment info" do
|
|
14
|
+
output = capture_output { Brat::CLI.run('info') }
|
|
15
|
+
expect(output).to include("Brat endpoint is")
|
|
16
|
+
expect(output).to include("Brat private token is")
|
|
17
|
+
expect(output).to include("Ruby Version is")
|
|
18
|
+
expect(output).to include("Brat Ruby Gem")
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context "when command is help" do
|
|
23
|
+
it "should show available actions" do
|
|
24
|
+
output = capture_output { Brat::CLI.run('help') }
|
|
25
|
+
expect(output).to include('Available commands')
|
|
26
|
+
expect(output).to include('MergeRequests')
|
|
27
|
+
expect(output).to include('team_members')
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context "when command is user" do
|
|
32
|
+
before do
|
|
33
|
+
stub_get("/user", "user")
|
|
34
|
+
@output = capture_output { Brat::CLI.run('user') }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should show executed command" do
|
|
38
|
+
expect(@output).to include('Brat.user')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should show user data" do
|
|
42
|
+
expect(@output).to include('name')
|
|
43
|
+
expect(@output).to include('John Smith')
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe ".start" do
|
|
49
|
+
context "when command with excluded fields" do
|
|
50
|
+
before do
|
|
51
|
+
stub_get("/user", "user")
|
|
52
|
+
args = ['user', '--except=id,email,name']
|
|
53
|
+
@output = capture_output { Brat::CLI.start(args) }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "should show user data with excluded fields" do
|
|
57
|
+
expect(@output).to_not include('John Smith')
|
|
58
|
+
expect(@output).to include('bio')
|
|
59
|
+
expect(@output).to include('created_at')
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
context "when command with required fields" do
|
|
64
|
+
before do
|
|
65
|
+
stub_get("/user", "user")
|
|
66
|
+
args = ['user', '--only=id,email,name']
|
|
67
|
+
@output = capture_output { Brat::CLI.start(args) }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "should show user data with required fields" do
|
|
71
|
+
expect(@output).to include('id')
|
|
72
|
+
expect(@output).to include('name')
|
|
73
|
+
expect(@output).to include('email')
|
|
74
|
+
expect(@output).to include('John Smith')
|
|
75
|
+
expect(@output).to_not include('bio')
|
|
76
|
+
expect(@output).to_not include('created_at')
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Brat::Client do
|
|
4
|
+
it { should respond_to :repo_branches }
|
|
5
|
+
it { should respond_to :repo_branch }
|
|
6
|
+
it { should respond_to :repo_protect_branch }
|
|
7
|
+
it { should respond_to :repo_unprotect_branch }
|
|
8
|
+
|
|
9
|
+
describe ".branches" do
|
|
10
|
+
before do
|
|
11
|
+
stub_get("/projects/3/repository/branches", "branches")
|
|
12
|
+
@branches = Brat.branches(3)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should get the correct resource" do
|
|
16
|
+
expect(a_get("/projects/3/repository/branches")).to have_been_made
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should return an array of repository branches" do
|
|
20
|
+
expect(@branches).to be_an Array
|
|
21
|
+
expect(@branches.first.name).to eq("api")
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe ".branch" do
|
|
26
|
+
before do
|
|
27
|
+
stub_get("/projects/3/repository/branches/api", "branch")
|
|
28
|
+
@branch = Brat.branch(3, "api")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should get the correct resource" do
|
|
32
|
+
expect(a_get("/projects/3/repository/branches/api")).to have_been_made
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should return information about a repository branch" do
|
|
36
|
+
expect(@branch.name).to eq("api")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe ".protect_branch" do
|
|
41
|
+
before do
|
|
42
|
+
stub_put("/projects/3/repository/branches/api/protect", "protect_branch")
|
|
43
|
+
@branch = Brat.protect_branch(3, "api")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should get the correct resource" do
|
|
47
|
+
expect(a_put("/projects/3/repository/branches/api/protect")).to have_been_made
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should return information about a protected repository branch" do
|
|
51
|
+
expect(@branch.name).to eq("api")
|
|
52
|
+
expect(@branch.protected).to eq(true)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe ".unprotect_branch" do
|
|
57
|
+
before do
|
|
58
|
+
stub_put("/projects/3/repository/branches/api/unprotect", "unprotect_branch")
|
|
59
|
+
@branch = Brat.unprotect_branch(3, "api")
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should get the correct resource" do
|
|
63
|
+
expect(a_put("/projects/3/repository/branches/api/unprotect")).to have_been_made
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "should return information about an unprotected repository branch" do
|
|
67
|
+
expect(@branch.name).to eq("api")
|
|
68
|
+
expect(@branch.protected).to eq(false)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe ".create_branch" do
|
|
73
|
+
context "with branch name" do
|
|
74
|
+
before do
|
|
75
|
+
stub_post("/projects/3/repository/branches", "create_branch")
|
|
76
|
+
@branch = Brat.create_branch(3, "api","master")
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "should get the correct resource" do
|
|
80
|
+
expect(a_post("/projects/3/repository/branches")).to have_been_made
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "should return information about a new repository branch" do
|
|
84
|
+
expect(@branch.name).to eq("api")
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
context "with commit hash" do
|
|
88
|
+
before do
|
|
89
|
+
stub_post("/projects/3/repository/branches", "create_branch")
|
|
90
|
+
@branch = Brat.create_branch(3, "api","949b1df930bedace1dbd755aaa4a82e8c451a616")
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "should get the correct resource" do
|
|
94
|
+
expect(a_post("/projects/3/repository/branches")).to have_been_made
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "should return information about a new repository branch" do
|
|
98
|
+
expect(@branch.name).to eq("api")
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
end
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Brat::Client do
|
|
4
|
+
describe ".groups" do
|
|
5
|
+
before do
|
|
6
|
+
stub_get("/groups", "groups")
|
|
7
|
+
stub_get("/groups/3", "group")
|
|
8
|
+
@group = Brat.group(3)
|
|
9
|
+
@groups = Brat.groups
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should get the correct resource" do
|
|
13
|
+
expect(a_get("/groups")).to have_been_made
|
|
14
|
+
expect(a_get("/groups/3")).to have_been_made
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should return an array of Groups" do
|
|
18
|
+
expect(@groups).to be_an Array
|
|
19
|
+
expect(@groups.first.path).to eq("threegroup")
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe ".create_group" do
|
|
24
|
+
before do
|
|
25
|
+
stub_post("/groups", "group_create")
|
|
26
|
+
@group = Brat.create_group('Brat-Group', 'brat-path')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should get the correct resource" do
|
|
30
|
+
expect(a_post("/groups").
|
|
31
|
+
with(:body => {:path => 'brat-path', :name => 'Brat-Group'})).to have_been_made
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should return information about a created group" do
|
|
35
|
+
expect(@group.name).to eq("Brat-Group")
|
|
36
|
+
expect(@group.path).to eq("brat-group")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe ".transfer_project_to_group" do
|
|
41
|
+
before do
|
|
42
|
+
stub_post("/projects", "project")
|
|
43
|
+
@project = Brat.create_project('Brat')
|
|
44
|
+
stub_post("/groups", "group_create")
|
|
45
|
+
@group = Brat.create_group('Brat-Group', 'brat-path')
|
|
46
|
+
|
|
47
|
+
stub_post("/groups/#{@group.id}/projects/#{@project.id}", "group_create")
|
|
48
|
+
@group_transfer = Brat.transfer_project_to_group(@group.id,@project.id)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should post to the correct resource" do
|
|
52
|
+
expect(a_post("/groups/#{@group.id}/projects/#{@project.id}").with(:body => {:id => @group.id.to_s, :project_id => @project.id.to_s})).to have_been_made
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should return information about the group" do
|
|
56
|
+
expect(@group_transfer.name).to eq(@group.name)
|
|
57
|
+
expect(@group_transfer.path).to eq(@group.path)
|
|
58
|
+
expect(@group_transfer.id).to eq(@group.id)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe ".group_members" do
|
|
63
|
+
before do
|
|
64
|
+
stub_get("/groups/3/members", "group_members")
|
|
65
|
+
@members = Brat.group_members(3)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should get the correct resource" do
|
|
69
|
+
expect(a_get("/groups/3/members")).to have_been_made
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "should return information about a group members" do
|
|
73
|
+
expect(@members).to be_an Array
|
|
74
|
+
expect(@members.size).to eq(2)
|
|
75
|
+
expect(@members[1].name).to eq("John Smith")
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
describe ".add_group_member" do
|
|
80
|
+
before do
|
|
81
|
+
stub_post("/groups/3/members", "group_member")
|
|
82
|
+
@member = Brat.add_group_member(3, 1, 40)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "should get the correct resource" do
|
|
86
|
+
expect(a_post("/groups/3/members").
|
|
87
|
+
with(:body => {:user_id => '1', :access_level => '40'})).to have_been_made
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "should return information about an added member" do
|
|
91
|
+
expect(@member.name).to eq("John Smith")
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
describe ".remove_group_member" do
|
|
96
|
+
before do
|
|
97
|
+
stub_delete("/groups/3/members/1", "group_member_delete")
|
|
98
|
+
@group = Brat.remove_group_member(3, 1)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "should get the correct resource" do
|
|
102
|
+
expect(a_delete("/groups/3/members/1")).to have_been_made
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it "should return information about the group the member was removed from" do
|
|
106
|
+
expect(@group.group_id).to eq(3)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
end
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Brat::Client do
|
|
4
|
+
describe ".issues" do
|
|
5
|
+
context "with project ID passed" do
|
|
6
|
+
before do
|
|
7
|
+
stub_get("/projects/3/issues", "project_issues")
|
|
8
|
+
@issues = Brat.issues(3)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should get the correct resource" do
|
|
12
|
+
expect(a_get("/projects/3/issues")).to have_been_made
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return an array of project's issues" do
|
|
16
|
+
expect(@issues).to be_an Array
|
|
17
|
+
expect(@issues.first.project_id).to eq(3)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context "without project ID passed" do
|
|
22
|
+
before do
|
|
23
|
+
stub_get("/issues", "issues")
|
|
24
|
+
@issues = Brat.issues
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should get the correct resource" do
|
|
28
|
+
expect(a_get("/issues")).to have_been_made
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should return an array of user's issues" do
|
|
32
|
+
expect(@issues).to be_an Array
|
|
33
|
+
expect(@issues.first.closed).to be_falsey
|
|
34
|
+
expect(@issues.first.author.name).to eq("John Smith")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe ".issue" do
|
|
40
|
+
before do
|
|
41
|
+
stub_get("/projects/3/issues/33", "issue")
|
|
42
|
+
@issue = Brat.issue(3, 33)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should get the correct resource" do
|
|
46
|
+
expect(a_get("/projects/3/issues/33")).to have_been_made
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should return information about an issue" do
|
|
50
|
+
expect(@issue.project_id).to eq(3)
|
|
51
|
+
expect(@issue.assignee.name).to eq("Jack Smith")
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe ".create_issue" do
|
|
56
|
+
before do
|
|
57
|
+
stub_post("/projects/3/issues", "issue")
|
|
58
|
+
@issue = Brat.create_issue(3, 'title')
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "should get the correct resource" do
|
|
62
|
+
expect(a_post("/projects/3/issues").
|
|
63
|
+
with(:body => {:title => 'title'})).to have_been_made
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "should return information about a created issue" do
|
|
67
|
+
expect(@issue.project_id).to eq(3)
|
|
68
|
+
expect(@issue.assignee.name).to eq("Jack Smith")
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe ".edit_issue" do
|
|
73
|
+
before do
|
|
74
|
+
stub_put("/projects/3/issues/33", "issue")
|
|
75
|
+
@issue = Brat.edit_issue(3, 33, :title => 'title')
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "should get the correct resource" do
|
|
79
|
+
expect(a_put("/projects/3/issues/33").
|
|
80
|
+
with(:body => {:title => 'title'})).to have_been_made
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "should return information about an edited issue" do
|
|
84
|
+
expect(@issue.project_id).to eq(3)
|
|
85
|
+
expect(@issue.assignee.name).to eq("Jack Smith")
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
describe ".close_issue" do
|
|
90
|
+
before do
|
|
91
|
+
stub_put("/projects/3/issues/33", "issue")
|
|
92
|
+
@issue = Brat.close_issue(3, 33)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "should get the correct resource" do
|
|
96
|
+
expect(a_put("/projects/3/issues/33").
|
|
97
|
+
with(:body => {:state_event => 'close'})).to have_been_made
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it "should return information about an closed issue" do
|
|
101
|
+
expect(@issue.project_id).to eq(3)
|
|
102
|
+
expect(@issue.assignee.name).to eq("Jack Smith")
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
describe ".reopen_issue" do
|
|
107
|
+
before do
|
|
108
|
+
stub_put("/projects/3/issues/33", "issue")
|
|
109
|
+
@issue = Brat.reopen_issue(3, 33)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "should get the correct resource" do
|
|
113
|
+
expect(a_put("/projects/3/issues/33").
|
|
114
|
+
with(:body => {:state_event => 'reopen'})).to have_been_made
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it "should return information about an reopened issue" do
|
|
118
|
+
expect(@issue.project_id).to eq(3)
|
|
119
|
+
expect(@issue.assignee.name).to eq("Jack Smith")
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Brat::Client do
|
|
4
|
+
describe ".merge_requests" do
|
|
5
|
+
before do
|
|
6
|
+
stub_get("/projects/3/merge_requests", "merge_requests")
|
|
7
|
+
@merge_requests = Brat.merge_requests(3)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "should get the correct resource" do
|
|
11
|
+
expect(a_get("/projects/3/merge_requests")).to have_been_made
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should return an array of project's merge requests" do
|
|
15
|
+
expect(@merge_requests).to be_an Array
|
|
16
|
+
expect(@merge_requests.first.project_id).to eq(3)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe ".merge_request" do
|
|
21
|
+
before do
|
|
22
|
+
stub_get("/projects/3/merge_request/1", "merge_request")
|
|
23
|
+
@merge_request = Brat.merge_request(3, 1)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should get the correct resource" do
|
|
27
|
+
expect(a_get("/projects/3/merge_request/1")).to have_been_made
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should return information about a merge request" do
|
|
31
|
+
expect(@merge_request.project_id).to eq(3)
|
|
32
|
+
expect(@merge_request.assignee.name).to eq("Jack Smith")
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe ".create_merge_request" do
|
|
37
|
+
before do
|
|
38
|
+
stub_post("/projects/3/merge_requests", "create_merge_request")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should fail if it doesn't have a source_branch" do
|
|
42
|
+
expect {
|
|
43
|
+
Brat.create_merge_request(3, 'New merge request', :target_branch => 'master')
|
|
44
|
+
}.to raise_error Brat::Error::MissingAttributes
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should fail if it doesn't have a target_branch" do
|
|
48
|
+
expect {
|
|
49
|
+
Brat.create_merge_request(3, 'New merge request', :source_branch => 'dev')
|
|
50
|
+
}.to raise_error Brat::Error::MissingAttributes
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should return information about a merge request" do
|
|
54
|
+
@merge_request = Brat.create_merge_request(3, 'New feature',
|
|
55
|
+
:source_branch => 'api',
|
|
56
|
+
:target_branch => 'master'
|
|
57
|
+
)
|
|
58
|
+
expect(@merge_request.project_id).to eq(3)
|
|
59
|
+
expect(@merge_request.assignee.name).to eq("Jack Smith")
|
|
60
|
+
expect(@merge_request.title).to eq('New feature')
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe ".update_merge_request" do
|
|
65
|
+
before do
|
|
66
|
+
stub_put("/projects/3/merge_request/2", "update_merge_request")
|
|
67
|
+
@merge_request = Brat.update_merge_request(3, 2,
|
|
68
|
+
:assignee_id => '1',
|
|
69
|
+
:target_branch => 'master',
|
|
70
|
+
:title => 'A different new feature'
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "should return information about a merge request" do
|
|
75
|
+
expect(@merge_request.project_id).to eq(3)
|
|
76
|
+
expect(@merge_request.assignee.name).to eq("Jack Smith")
|
|
77
|
+
expect(@merge_request.title).to eq('A different new feature')
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
describe ".merge_request_comments" do
|
|
82
|
+
before do
|
|
83
|
+
stub_get("/projects/3/merge_request/2/comments", "merge_request_comments")
|
|
84
|
+
@merge_request = Brat.merge_request_comments(3, 2)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "should return merge request's comments" do
|
|
88
|
+
expect(@merge_request).to be_an Array
|
|
89
|
+
expect(@merge_request.length).to eq(2)
|
|
90
|
+
expect(@merge_request[0].note).to eq("this is the 1st comment on the 2merge merge request")
|
|
91
|
+
expect(@merge_request[0].author.id).to eq(11)
|
|
92
|
+
expect(@merge_request[1].note).to eq("another discussion point on the 2merge request")
|
|
93
|
+
expect(@merge_request[1].author.id).to eq(12)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
describe ".merge_request_comments" do
|
|
98
|
+
before do
|
|
99
|
+
stub_get("/projects/3/merge_request/2/comments", "merge_request_comments")
|
|
100
|
+
@merge_request = Brat.merge_request_comments(3, 2)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "should return merge request's comments" do
|
|
104
|
+
expect(@merge_request).to be_an Array
|
|
105
|
+
expect(@merge_request.length).to eq(2)
|
|
106
|
+
expect(@merge_request[0].note).to eq("this is the 1st comment on the 2merge merge request")
|
|
107
|
+
expect(@merge_request[0].author.id).to eq(11)
|
|
108
|
+
expect(@merge_request[1].note).to eq("another discussion point on the 2merge request")
|
|
109
|
+
expect(@merge_request[1].author.id).to eq(12)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
describe ".create_merge_request_comment" do
|
|
114
|
+
before do
|
|
115
|
+
stub_post("/projects/3/merge_request/2/comments", "comment_merge_request")
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it "should return information about a merge request" do
|
|
119
|
+
@merge_request = Brat.create_merge_request_comment(3, 2, 'Cool Merge Request!')
|
|
120
|
+
expect(@merge_request.note).to eq('Cool Merge Request!')
|
|
121
|
+
@merge_request.author.id == 1
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|