jira-ruby-dmg 0.1.10
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 +10 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +46 -0
- data/README.rdoc +309 -0
- data/Rakefile +28 -0
- data/example.rb +119 -0
- data/http-basic-example.rb +112 -0
- data/jira-ruby-dmg.gemspec +28 -0
- data/lib/jira/base.rb +497 -0
- data/lib/jira/base_factory.rb +49 -0
- data/lib/jira/client.rb +165 -0
- data/lib/jira/has_many_proxy.rb +43 -0
- data/lib/jira/http_client.rb +69 -0
- data/lib/jira/http_error.rb +16 -0
- data/lib/jira/oauth_client.rb +84 -0
- data/lib/jira/railtie.rb +10 -0
- data/lib/jira/request_client.rb +18 -0
- data/lib/jira/resource/attachment.rb +12 -0
- data/lib/jira/resource/comment.rb +14 -0
- data/lib/jira/resource/component.rb +10 -0
- data/lib/jira/resource/field.rb +10 -0
- data/lib/jira/resource/filter.rb +15 -0
- data/lib/jira/resource/issue.rb +76 -0
- data/lib/jira/resource/issuetype.rb +10 -0
- data/lib/jira/resource/priority.rb +10 -0
- data/lib/jira/resource/project.rb +31 -0
- data/lib/jira/resource/status.rb +10 -0
- data/lib/jira/resource/transition.rb +33 -0
- data/lib/jira/resource/user.rb +14 -0
- data/lib/jira/resource/version.rb +10 -0
- data/lib/jira/resource/worklog.rb +16 -0
- data/lib/jira/tasks.rb +0 -0
- data/lib/jira/version.rb +3 -0
- data/lib/jira.rb +33 -0
- data/lib/tasks/generate.rake +18 -0
- data/spec/integration/attachment_spec.rb +23 -0
- data/spec/integration/comment_spec.rb +55 -0
- data/spec/integration/component_spec.rb +42 -0
- data/spec/integration/field_spec.rb +35 -0
- data/spec/integration/issue_spec.rb +94 -0
- data/spec/integration/issuetype_spec.rb +26 -0
- data/spec/integration/priority_spec.rb +27 -0
- data/spec/integration/project_spec.rb +56 -0
- data/spec/integration/status_spec.rb +27 -0
- data/spec/integration/transition_spec.rb +52 -0
- data/spec/integration/user_spec.rb +25 -0
- data/spec/integration/version_spec.rb +43 -0
- data/spec/integration/worklog_spec.rb +55 -0
- data/spec/jira/base_factory_spec.rb +46 -0
- data/spec/jira/base_spec.rb +586 -0
- data/spec/jira/client_spec.rb +188 -0
- data/spec/jira/has_many_proxy_spec.rb +45 -0
- data/spec/jira/http_client_spec.rb +109 -0
- data/spec/jira/http_error_spec.rb +25 -0
- data/spec/jira/oauth_client_spec.rb +111 -0
- data/spec/jira/request_client_spec.rb +14 -0
- data/spec/jira/resource/attachment_spec.rb +20 -0
- data/spec/jira/resource/filter_spec.rb +97 -0
- data/spec/jira/resource/issue_spec.rb +107 -0
- data/spec/jira/resource/project_factory_spec.rb +13 -0
- data/spec/jira/resource/project_spec.rb +70 -0
- data/spec/jira/resource/worklog_spec.rb +24 -0
- data/spec/mock_responses/attachment/10000.json +20 -0
- data/spec/mock_responses/component/10000.invalid.put.json +5 -0
- data/spec/mock_responses/component/10000.json +39 -0
- data/spec/mock_responses/component/10000.put.json +39 -0
- data/spec/mock_responses/component.post.json +28 -0
- data/spec/mock_responses/field/1.json +15 -0
- data/spec/mock_responses/field.json +32 -0
- data/spec/mock_responses/issue/10002/comment/10000.json +29 -0
- data/spec/mock_responses/issue/10002/comment/10000.put.json +29 -0
- data/spec/mock_responses/issue/10002/comment.json +65 -0
- data/spec/mock_responses/issue/10002/comment.post.json +29 -0
- data/spec/mock_responses/issue/10002/transitions.json +49 -0
- data/spec/mock_responses/issue/10002/transitions.post.json +1 -0
- data/spec/mock_responses/issue/10002/worklog/10000.json +31 -0
- data/spec/mock_responses/issue/10002/worklog/10000.put.json +30 -0
- data/spec/mock_responses/issue/10002/worklog.json +98 -0
- data/spec/mock_responses/issue/10002/worklog.post.json +30 -0
- data/spec/mock_responses/issue/10002.invalid.put.json +6 -0
- data/spec/mock_responses/issue/10002.json +126 -0
- data/spec/mock_responses/issue/10002.put.missing_field_update.json +6 -0
- data/spec/mock_responses/issue.json +1108 -0
- data/spec/mock_responses/issue.post.json +5 -0
- data/spec/mock_responses/issuetype/5.json +8 -0
- data/spec/mock_responses/issuetype.json +42 -0
- data/spec/mock_responses/priority/1.json +8 -0
- data/spec/mock_responses/priority.json +42 -0
- data/spec/mock_responses/project/SAMPLEPROJECT.issues.json +1108 -0
- data/spec/mock_responses/project/SAMPLEPROJECT.json +84 -0
- data/spec/mock_responses/project.json +12 -0
- data/spec/mock_responses/status/1.json +7 -0
- data/spec/mock_responses/status.json +37 -0
- data/spec/mock_responses/user_username=admin.json +17 -0
- data/spec/mock_responses/version/10000.invalid.put.json +5 -0
- data/spec/mock_responses/version/10000.json +11 -0
- data/spec/mock_responses/version/10000.put.json +7 -0
- data/spec/mock_responses/version.post.json +7 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/support/clients_helper.rb +16 -0
- data/spec/support/matchers/have_attributes.rb +11 -0
- data/spec/support/matchers/have_many.rb +9 -0
- data/spec/support/matchers/have_one.rb +5 -0
- data/spec/support/shared_examples/integration.rb +190 -0
- metadata +301 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Component do
|
4
|
+
|
5
|
+
|
6
|
+
with_each_client do |site_url, client|
|
7
|
+
let(:client) { client }
|
8
|
+
let(:site_url) { site_url }
|
9
|
+
|
10
|
+
let(:key) { "10000" }
|
11
|
+
|
12
|
+
let(:expected_attributes) do
|
13
|
+
{
|
14
|
+
'self' => "http://localhost:2990/jira/rest/api/2/component/10000",
|
15
|
+
'id' => key,
|
16
|
+
'name' => "Cheesecake"
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:attributes_for_post) {
|
21
|
+
{"name" => "Test component", "project" => "SAMPLEPROJECT" }
|
22
|
+
}
|
23
|
+
let(:expected_attributes_from_post) {
|
24
|
+
{ "id" => "10001", "name" => "Test component" }
|
25
|
+
}
|
26
|
+
|
27
|
+
let(:attributes_for_put) {
|
28
|
+
{"name" => "Jammy", "project" => "SAMPLEPROJECT" }
|
29
|
+
}
|
30
|
+
let(:expected_attributes_from_put) {
|
31
|
+
{ "id" => "10000", "name" => "Jammy" }
|
32
|
+
}
|
33
|
+
|
34
|
+
it_should_behave_like "a resource"
|
35
|
+
it_should_behave_like "a resource with a singular GET endpoint"
|
36
|
+
it_should_behave_like "a resource with a DELETE endpoint"
|
37
|
+
it_should_behave_like "a resource with a POST endpoint"
|
38
|
+
it_should_behave_like "a resource with a PUT endpoint"
|
39
|
+
it_should_behave_like "a resource with a PUT endpoint that rejects invalid fields"
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Field do
|
4
|
+
|
5
|
+
with_each_client do |site_url, client|
|
6
|
+
let(:client) { client }
|
7
|
+
let(:site_url) { site_url }
|
8
|
+
|
9
|
+
|
10
|
+
let(:key) { "1" }
|
11
|
+
|
12
|
+
let(:expected_attributes) do
|
13
|
+
{
|
14
|
+
"id"=>key,
|
15
|
+
"name"=>"Description",
|
16
|
+
"custom"=>false,
|
17
|
+
"orderable"=>true,
|
18
|
+
"navigable"=>true,
|
19
|
+
"searchable"=>true,
|
20
|
+
"clauseNames"=>["description"],
|
21
|
+
"schema"=> {
|
22
|
+
"type"=>"string",
|
23
|
+
"system"=>"description"
|
24
|
+
}
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:expected_collection_length) { 2 }
|
29
|
+
|
30
|
+
it_should_behave_like "a resource"
|
31
|
+
it_should_behave_like "a resource with a collection GET endpoint"
|
32
|
+
it_should_behave_like "a resource with a singular GET endpoint"
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Issue do
|
4
|
+
|
5
|
+
with_each_client do |site_url, client|
|
6
|
+
let(:client) { client }
|
7
|
+
let(:site_url) { site_url }
|
8
|
+
|
9
|
+
|
10
|
+
let(:key) { "10002" }
|
11
|
+
|
12
|
+
let(:expected_attributes) do
|
13
|
+
{
|
14
|
+
'self' => "http://localhost:2990/jira/rest/api/2/issue/10002",
|
15
|
+
'key' => "SAMPLEPROJECT-1",
|
16
|
+
'expand' => "renderedFields,names,schema,transitions,editmeta,changelog"
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:attributes_for_post) {
|
21
|
+
{ 'foo' => 'bar' }
|
22
|
+
}
|
23
|
+
let(:expected_attributes_from_post) {
|
24
|
+
{ "id" => "10005", "key" => "SAMPLEPROJECT-4" }
|
25
|
+
}
|
26
|
+
|
27
|
+
let(:attributes_for_put) {
|
28
|
+
{ 'foo' => 'bar' }
|
29
|
+
}
|
30
|
+
let(:expected_attributes_from_put) {
|
31
|
+
{ 'foo' => 'bar' }
|
32
|
+
}
|
33
|
+
let(:expected_collection_length) { 11 }
|
34
|
+
|
35
|
+
it_should_behave_like "a resource"
|
36
|
+
it_should_behave_like "a resource with a singular GET endpoint"
|
37
|
+
describe "GET all issues" do # JIRA::Resource::Issue.all uses the search endpoint
|
38
|
+
let(:client) { client }
|
39
|
+
let(:site_url) { site_url }
|
40
|
+
|
41
|
+
let(:expected_attributes) {
|
42
|
+
{
|
43
|
+
"id"=>"10014",
|
44
|
+
"self"=>"http://localhost:2990/jira/rest/api/2/issue/10014",
|
45
|
+
"key"=>"SAMPLEPROJECT-13"
|
46
|
+
}
|
47
|
+
}
|
48
|
+
before(:each) do
|
49
|
+
stub_request(:get, site_url + "/jira/rest/api/2/search").
|
50
|
+
to_return(:status => 200, :body => get_mock_response('issue.json'))
|
51
|
+
end
|
52
|
+
it_should_behave_like "a resource with a collection GET endpoint"
|
53
|
+
end
|
54
|
+
it_should_behave_like "a resource with a DELETE endpoint"
|
55
|
+
it_should_behave_like "a resource with a POST endpoint"
|
56
|
+
it_should_behave_like "a resource with a PUT endpoint"
|
57
|
+
it_should_behave_like "a resource with a PUT endpoint that rejects invalid fields"
|
58
|
+
|
59
|
+
describe "errors" do
|
60
|
+
before(:each) do
|
61
|
+
stub_request(:get,
|
62
|
+
site_url + "/jira/rest/api/2/issue/10002").
|
63
|
+
to_return(:status => 200, :body => get_mock_response('issue/10002.json'))
|
64
|
+
stub_request(:put, site_url + "/jira/rest/api/2/issue/10002").
|
65
|
+
with(:body => '{"missing":"fields and update"}').
|
66
|
+
to_return(:status => 400, :body => get_mock_response('issue/10002.put.missing_field_update.json'))
|
67
|
+
end
|
68
|
+
|
69
|
+
it "fails to save when fields and update are missing" do
|
70
|
+
subject = client.Issue.build('id' => '10002')
|
71
|
+
subject.fetch
|
72
|
+
subject.save('missing' => 'fields and update').should be_false
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "GET jql issues" do # JIRA::Resource::Issue.jql uses the search endpoint
|
78
|
+
jql_query_string = "PROJECT = 'SAMPLEPROJECT'"
|
79
|
+
let(:client) { client }
|
80
|
+
let(:site_url) { site_url }
|
81
|
+
let(:jql_query_string) { jql_query_string }
|
82
|
+
|
83
|
+
let(:expected_attributes) {
|
84
|
+
{
|
85
|
+
"id"=>"10014",
|
86
|
+
"self"=>"http://localhost:2990/jira/rest/api/2/issue/10014",
|
87
|
+
"key"=>"SAMPLEPROJECT-13"
|
88
|
+
}
|
89
|
+
}
|
90
|
+
it_should_behave_like "a resource with JQL inputs and a collection GET endpoint"
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Issuetype do
|
4
|
+
|
5
|
+
with_each_client do |site_url, client|
|
6
|
+
let(:client) { client }
|
7
|
+
let(:site_url) { site_url }
|
8
|
+
|
9
|
+
let(:key) { "5" }
|
10
|
+
|
11
|
+
let(:expected_attributes) do
|
12
|
+
{
|
13
|
+
'self' => "http://localhost:2990/jira/rest/api/2/issuetype/5",
|
14
|
+
'id' => key,
|
15
|
+
'name' => 'Sub-task'
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:expected_collection_length) { 5 }
|
20
|
+
|
21
|
+
it_should_behave_like "a resource"
|
22
|
+
it_should_behave_like "a resource with a collection GET endpoint"
|
23
|
+
it_should_behave_like "a resource with a singular GET endpoint"
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Priority do
|
4
|
+
|
5
|
+
with_each_client do |site_url, client|
|
6
|
+
let(:client) { client }
|
7
|
+
let(:site_url) { site_url }
|
8
|
+
|
9
|
+
|
10
|
+
let(:key) { "1" }
|
11
|
+
|
12
|
+
let(:expected_attributes) do
|
13
|
+
{
|
14
|
+
'self' => "http://localhost:2990/jira/rest/api/2/priority/1",
|
15
|
+
'id' => key,
|
16
|
+
'name' => 'Blocker'
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:expected_collection_length) { 5 }
|
21
|
+
|
22
|
+
it_should_behave_like "a resource"
|
23
|
+
it_should_behave_like "a resource with a collection GET endpoint"
|
24
|
+
it_should_behave_like "a resource with a singular GET endpoint"
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Project do
|
4
|
+
|
5
|
+
with_each_client do |site_url, client|
|
6
|
+
let(:client) { client }
|
7
|
+
let(:site_url) { site_url }
|
8
|
+
|
9
|
+
|
10
|
+
let(:key) { "SAMPLEPROJECT" }
|
11
|
+
|
12
|
+
let(:expected_attributes) do
|
13
|
+
{
|
14
|
+
'self' => "http://localhost:2990/jira/rest/api/2/project/SAMPLEPROJECT",
|
15
|
+
'key' => key,
|
16
|
+
'name' => "Sample Project for Developing RoR RESTful API"
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:expected_collection_length) { 1 }
|
21
|
+
|
22
|
+
it_should_behave_like "a resource"
|
23
|
+
it_should_behave_like "a resource with a collection GET endpoint"
|
24
|
+
it_should_behave_like "a resource with a singular GET endpoint"
|
25
|
+
|
26
|
+
describe "issues" do
|
27
|
+
|
28
|
+
it "returns all the issues" do
|
29
|
+
stub_request(:get, site_url + "/jira/rest/api/2/search?jql=project=\"SAMPLEPROJECT\"").
|
30
|
+
to_return(:status => 200, :body => get_mock_response('project/SAMPLEPROJECT.issues.json'))
|
31
|
+
subject = client.Project.build('key' => key)
|
32
|
+
issues = subject.issues
|
33
|
+
issues.length.should == 11
|
34
|
+
issues.each do |issue|
|
35
|
+
issue.class.should == JIRA::Resource::Issue
|
36
|
+
issue.expanded?.should be_false
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns a collection of components" do
|
44
|
+
|
45
|
+
stub_request(:get, site_url + described_class.singular_path(client, key)).
|
46
|
+
to_return(:status => 200, :body => get_mock_response('project/SAMPLEPROJECT.json'))
|
47
|
+
|
48
|
+
subject = client.Project.find(key)
|
49
|
+
subject.components.length.should == 2
|
50
|
+
subject.components.each do |component|
|
51
|
+
component.class.should == JIRA::Resource::Component
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Status do
|
4
|
+
|
5
|
+
with_each_client do |site_url, client|
|
6
|
+
let(:client) { client }
|
7
|
+
let(:site_url) { site_url }
|
8
|
+
|
9
|
+
|
10
|
+
let(:key) { "1" }
|
11
|
+
|
12
|
+
let(:expected_attributes) do
|
13
|
+
{
|
14
|
+
'self' => "http://localhost:2990/jira/rest/api/2/status/1",
|
15
|
+
'id' => key,
|
16
|
+
'name' => 'Open'
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:expected_collection_length) { 5 }
|
21
|
+
|
22
|
+
it_should_behave_like "a resource"
|
23
|
+
it_should_behave_like "a resource with a collection GET endpoint"
|
24
|
+
it_should_behave_like "a resource with a singular GET endpoint"
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Transition do
|
4
|
+
|
5
|
+
with_each_client do |site_url, client|
|
6
|
+
let(:client) { client }
|
7
|
+
let(:site_url) { site_url }
|
8
|
+
|
9
|
+
let(:key) { '10000' }
|
10
|
+
|
11
|
+
let(:target) { JIRA::Resource::Transition.new(client, :attrs => {'id' => '99999'}, :issue_id => '10014') }
|
12
|
+
|
13
|
+
let(:belongs_to) {
|
14
|
+
JIRA::Resource::Issue.new(client, :attrs => {
|
15
|
+
'id' => '10002',
|
16
|
+
'self' => "#{site_url}/jira/rest/api/2/issue/10002",
|
17
|
+
'fields' => {
|
18
|
+
'comment' => {'comments' => []}
|
19
|
+
}
|
20
|
+
})
|
21
|
+
}
|
22
|
+
|
23
|
+
let(:expected_attributes) do
|
24
|
+
{
|
25
|
+
'self' => "#{site_url}/jira/rest/api/2/issue/10002/transition/10000",
|
26
|
+
'id' => key
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
let(:attributes_for_post) {
|
31
|
+
{
|
32
|
+
'transition' => {
|
33
|
+
'id' => '42'
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
it_should_behave_like "a resource"
|
39
|
+
|
40
|
+
describe "POST endpoint" do
|
41
|
+
it "saves a new resource" do
|
42
|
+
stub_request(:post, /#{described_class.collection_path(client, prefix)}$/)
|
43
|
+
.with(:body => attributes_for_post.to_json)
|
44
|
+
.to_return(:status => 200, :body => get_mock_from_path(:post))
|
45
|
+
subject = build_receiver.build
|
46
|
+
subject.save(attributes_for_post).should be_true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::User do
|
4
|
+
|
5
|
+
|
6
|
+
with_each_client do |site_url, client|
|
7
|
+
let(:client) { client }
|
8
|
+
let(:site_url) { site_url }
|
9
|
+
|
10
|
+
|
11
|
+
let(:key) { "admin" }
|
12
|
+
|
13
|
+
let(:expected_attributes) do
|
14
|
+
{
|
15
|
+
'self' => "http://localhost:2990/jira/rest/api/2/user?username=admin",
|
16
|
+
'name' => key,
|
17
|
+
'emailAddress' => 'admin@example.com'
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
it_should_behave_like "a resource"
|
22
|
+
it_should_behave_like "a resource with a singular GET endpoint"
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Version do
|
4
|
+
|
5
|
+
|
6
|
+
with_each_client do |site_url, client|
|
7
|
+
let(:client) { client }
|
8
|
+
let(:site_url) { site_url }
|
9
|
+
|
10
|
+
|
11
|
+
let(:key) { "10000" }
|
12
|
+
|
13
|
+
let(:expected_attributes) do
|
14
|
+
{
|
15
|
+
'self' => "http://localhost:2990/jira/rest/api/2/version/10000",
|
16
|
+
'id' => key,
|
17
|
+
'description' => "Initial version"
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:attributes_for_post) {
|
22
|
+
{"name" => "2.0", "project" => "SAMPLEPROJECT" }
|
23
|
+
}
|
24
|
+
let(:expected_attributes_from_post) {
|
25
|
+
{ "id" => "10001", "name" => "2.0" }
|
26
|
+
}
|
27
|
+
|
28
|
+
let(:attributes_for_put) {
|
29
|
+
{"name" => "2.0.0" }
|
30
|
+
}
|
31
|
+
let(:expected_attributes_from_put) {
|
32
|
+
{ "id" => "10000", "name" => "2.0.0" }
|
33
|
+
}
|
34
|
+
|
35
|
+
it_should_behave_like "a resource"
|
36
|
+
it_should_behave_like "a resource with a singular GET endpoint"
|
37
|
+
it_should_behave_like "a resource with a DELETE endpoint"
|
38
|
+
it_should_behave_like "a resource with a POST endpoint"
|
39
|
+
it_should_behave_like "a resource with a PUT endpoint"
|
40
|
+
it_should_behave_like "a resource with a PUT endpoint that rejects invalid fields"
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Worklog do
|
4
|
+
|
5
|
+
|
6
|
+
with_each_client do |site_url, client|
|
7
|
+
let(:client) { client }
|
8
|
+
let(:site_url) { site_url }
|
9
|
+
|
10
|
+
|
11
|
+
let(:key) { "10000" }
|
12
|
+
|
13
|
+
let(:target) { JIRA::Resource::Worklog.new(client, :attrs => {'id' => '99999'}, :issue_id => '54321') }
|
14
|
+
|
15
|
+
let(:expected_collection_length) { 3 }
|
16
|
+
|
17
|
+
let(:belongs_to) {
|
18
|
+
JIRA::Resource::Issue.new(client, :attrs => {
|
19
|
+
'id' => '10002', 'fields' => {
|
20
|
+
'comment' => {'comments' => []}
|
21
|
+
}
|
22
|
+
})
|
23
|
+
}
|
24
|
+
|
25
|
+
let(:expected_attributes) do
|
26
|
+
{
|
27
|
+
'self' => "http://localhost:2990/jira/rest/api/2/issue/10002/worklog/10000",
|
28
|
+
'id' => key,
|
29
|
+
'comment' => "Some epic work."
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:attributes_for_post) {
|
34
|
+
{"timeSpent" => "2d"}
|
35
|
+
}
|
36
|
+
let(:expected_attributes_from_post) {
|
37
|
+
{ "id" => "10001", "timeSpent" => "2d"}
|
38
|
+
}
|
39
|
+
|
40
|
+
let(:attributes_for_put) {
|
41
|
+
{"timeSpent" => "2d"}
|
42
|
+
}
|
43
|
+
let(:expected_attributes_from_put) {
|
44
|
+
{ "id" => "10001", "timeSpent" => "4d"}
|
45
|
+
}
|
46
|
+
|
47
|
+
it_should_behave_like "a resource"
|
48
|
+
it_should_behave_like "a resource with a collection GET endpoint"
|
49
|
+
it_should_behave_like "a resource with a singular GET endpoint"
|
50
|
+
it_should_behave_like "a resource with a DELETE endpoint"
|
51
|
+
it_should_behave_like "a resource with a POST endpoint"
|
52
|
+
it_should_behave_like "a resource with a PUT endpoint"
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::BaseFactory do
|
4
|
+
|
5
|
+
class JIRA::Resource::FooFactory < JIRA::BaseFactory ; end
|
6
|
+
class JIRA::Resource::Foo ; end
|
7
|
+
|
8
|
+
let(:client) { double() }
|
9
|
+
subject { JIRA::Resource::FooFactory.new(client) }
|
10
|
+
|
11
|
+
it "initializes correctly" do
|
12
|
+
subject.class.should == JIRA::Resource::FooFactory
|
13
|
+
subject.client.should == client
|
14
|
+
subject.target_class.should == JIRA::Resource::Foo
|
15
|
+
end
|
16
|
+
|
17
|
+
it "proxies all to the target class" do
|
18
|
+
JIRA::Resource::Foo.should_receive(:all).with(client)
|
19
|
+
subject.all
|
20
|
+
end
|
21
|
+
|
22
|
+
it "proxies find to the target class" do
|
23
|
+
JIRA::Resource::Foo.should_receive(:find).with(client, 'FOO')
|
24
|
+
subject.find('FOO')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns the target class" do
|
28
|
+
subject.target_class.should == JIRA::Resource::Foo
|
29
|
+
end
|
30
|
+
|
31
|
+
it "proxies build to the target class" do
|
32
|
+
attrs = double()
|
33
|
+
JIRA::Resource::Foo.should_receive(:build).with(client, attrs)
|
34
|
+
subject.build(attrs)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "proxies collection path to the target class" do
|
38
|
+
JIRA::Resource::Foo.should_receive(:collection_path).with(client)
|
39
|
+
subject.collection_path
|
40
|
+
end
|
41
|
+
|
42
|
+
it "proxies singular path to the target class" do
|
43
|
+
JIRA::Resource::Foo.should_receive(:singular_path).with(client, 'FOO')
|
44
|
+
subject.singular_path('FOO')
|
45
|
+
end
|
46
|
+
end
|