Skip to content

Commit

Permalink
Add Project.has_many :components
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Signal committed Jan 10, 2012
1 parent 87c35de commit c99a752
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/jira.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
require 'jira/resource/http_error'

require 'jira/resource/issue'
require 'jira/resource/project'
require 'jira/resource/component'
require 'jira/resource/project'
require 'jira/resource/user'

require 'jira/client'
2 changes: 2 additions & 0 deletions lib/jira/resource/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class ProjectFactory < BaseFactory ; end

class Project < Base

has_many :components

def self.key_attribute
:key
end
Expand Down
13 changes: 13 additions & 0 deletions spec/integration/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,17 @@
end

end

it "returns a collection of components" do

stub_request(:get, 'http://localhost:2990' + described_class.singular_path(client, key)).
to_return(:status => 200, :body => get_mock_response('project/SAMPLEPROJECT.json'))

subject = client.Project.find(key)
subject.components.length.should == 2
subject.components.each do |component|
component.class.should == JIRA::Resource::Component
end

end
end
16 changes: 15 additions & 1 deletion spec/mock_responses/project/SAMPLEPROJECT.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@
"displayName": "admin",
"active": true
},
"components": [],
"components": [
{
"self": "http://localhost:2990/jira/rest/api/2/component/10001",
"id": "10001",
"name": "Jamflam",
"isAssigneeTypeValid": false
},
{
"self": "http://localhost:2990/jira/rest/api/2/component/10000",
"id": "10000",
"name": "Jammy",
"description": "Description!",
"isAssigneeTypeValid": false
}
],
"issueTypes": [
{
"self": "http://localhost:2990/jira/rest/api/2/issuetype/1",
Expand Down

0 comments on commit c99a752

Please sign in to comment.