Skip to content

Commit

Permalink
Implement JIRA::Resource::Issuetype
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Signal committed Jan 10, 2012
1 parent 503d2a1 commit 02de744
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 0 deletions.
10 changes: 10 additions & 0 deletions example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,13 @@
# # -----------
# user = client.User.find('admin')
# pp user
#
# # Get all issue types
# # -------------------
# issuetypes = client.Issuetype.all
# pp issuetypes
#
# # Get a single issue type
# # -----------------------
# issuetype = client.Issuetype.find('5')
# pp issuetype
1 change: 1 addition & 0 deletions lib/jira.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'jira/resource/user'
require 'jira/resource/component'
require 'jira/resource/project'
require 'jira/resource/issuetype'
require 'jira/resource/issue'

require 'jira/client'
4 changes: 4 additions & 0 deletions lib/jira/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def User
JIRA::Resource::UserFactory.new(self)
end

def Issuetype
JIRA::Resource::IssuetypeFactory.new(self)
end

def request_token
@request_token ||= get_request_token
end
Expand Down
9 changes: 9 additions & 0 deletions lib/jira/resource/issuetype.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module JIRA
module Resource

class IssuetypeFactory < BaseFactory ; end

class Issuetype < Base ; end

end
end
27 changes: 27 additions & 0 deletions spec/integration/issuetype_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'spec_helper'

describe JIRA::Resource::Issuetype do

let(:client) do
client = JIRA::Client.new('foo', 'bar')
client.set_access_token('abc', '123')
client
end

let(:key) { "5" }

let(:expected_attributes) do
{
'self' => "http://localhost:2990/jira/rest/api/2/issuetype/5",
'id' => key,
'name' => 'Sub-task'
}
end

let(:expected_collection_length) { 5 }

it_should_behave_like "a resource"
it_should_behave_like "a resource with a collection GET endpoint"
it_should_behave_like "a resource with a singular GET endpoint"

end
42 changes: 42 additions & 0 deletions spec/mock_responses/issuetype.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"self": "http://localhost:2990/jira/rest/api/2/issuetype/5",
"id": "5",
"description": "The sub-task of the issue",
"iconUrl": "http://localhost:2990/jira/images/icons/issue_subtask.gif",
"name": "Sub-task",
"subtask": true
},
{
"self": "http://localhost:2990/jira/rest/api/2/issuetype/4",
"id": "4",
"description": "An improvement or enhancement to an existing feature or task.",
"iconUrl": "http://localhost:2990/jira/images/icons/improvement.gif",
"name": "Improvement",
"subtask": false
},
{
"self": "http://localhost:2990/jira/rest/api/2/issuetype/3",
"id": "3",
"description": "A task that needs to be done.",
"iconUrl": "http://localhost:2990/jira/images/icons/task.gif",
"name": "Task",
"subtask": false
},
{
"self": "http://localhost:2990/jira/rest/api/2/issuetype/1",
"id": "1",
"description": "A problem which impairs or prevents the functions of the product.",
"iconUrl": "http://localhost:2990/jira/images/icons/bug.gif",
"name": "Bug",
"subtask": false
},
{
"self": "http://localhost:2990/jira/rest/api/2/issuetype/2",
"id": "2",
"description": "A new feature of the product, which has yet to be developed.",
"iconUrl": "http://localhost:2990/jira/images/icons/newfeature.gif",
"name": "New Feature",
"subtask": false
}
]
8 changes: 8 additions & 0 deletions spec/mock_responses/issuetype/5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"self": "http://localhost:2990/jira/rest/api/2/issuetype/5",
"id": "5",
"description": "The sub-task of the issue",
"iconUrl": "http://localhost:2990/jira/images/icons/issue_subtask.gif",
"name": "Sub-task",
"subtask": true
}

0 comments on commit 02de744

Please sign in to comment.