Skip to content

Commit

Permalink
Implements JIRA::Resource::Attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Signal committed Jan 10, 2012
1 parent 6156f19 commit 7a29fbe
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/jira.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
require 'jira/resource/http_error'

require 'jira/resource/user'
require 'jira/resource/attachment'
require 'jira/resource/component'
require 'jira/resource/issuetype'
require 'jira/resource/project'
Expand Down
4 changes: 4 additions & 0 deletions lib/jira/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def Comment
JIRA::Resource::CommentFactory.new(self)
end

def Attachment
JIRA::Resource::AttachmentFactory.new(self)
end

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

class AttachmentFactory < BaseFactory ; end

class Attachment < Base ; end

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

describe JIRA::Resource::Attachment do


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

let(:key) { "10000" }

let(:expected_attributes) do
{
'self' => "http://localhost:2990/jira/rest/api/2/attachment/10000",
'size' => 15360,
'filename' => "ballmer.png"
}
end

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

end
20 changes: 20 additions & 0 deletions spec/mock_responses/attachment/10000.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"self": "http://localhost:2990/jira/rest/api/2/attachment/10000",
"filename": "ballmer.png",
"author": {
"self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
"name": "admin",
"avatarUrls": {
"16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
"48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
},
"displayName": "admin",
"active": true
},
"created": "2012-01-11T10:54:50.875+1300",
"size": 15360,
"mimeType": "image/png",
"properties": {},
"content": "http://localhost:2990/jira/secure/attachment/10000/ballmer.png",
"thumbnail": "http://localhost:2990/jira/secure/thumbnail/10000/_thumb_10000.png"
}

0 comments on commit 7a29fbe

Please sign in to comment.