@@ -189,6 +189,20 module IssuesHelper | |||||
189 | end |
|
189 | end | |
190 | end |
|
190 | end | |
191 |
|
191 | |||
|
192 | # Renders issue children recursively | |||
|
193 | def render_api_issue_children(issue, api) | |||
|
194 | return if issue.leaf? | |||
|
195 | api.array :children do | |||
|
196 | issue.children.each do |child| | |||
|
197 | api.issue(:id => child.id) do | |||
|
198 | api.tracker(:id => child.tracker_id, :name => child.tracker.name) unless child.tracker.nil? | |||
|
199 | api.subject child.subject | |||
|
200 | render_api_issue_children(child, api) | |||
|
201 | end | |||
|
202 | end | |||
|
203 | end | |||
|
204 | end | |||
|
205 | ||||
192 | def issues_to_csv(issues, project = nil) |
|
206 | def issues_to_csv(issues, project = nil) | |
193 | ic = Iconv.new(l(:general_csv_encoding), 'UTF-8') |
|
207 | ic = Iconv.new(l(:general_csv_encoding), 'UTF-8') | |
194 | decimal_separator = l(:general_csv_decimal_separator) |
|
208 | decimal_separator = l(:general_csv_decimal_separator) |
@@ -29,6 +29,8 api.issue do | |||||
29 | api.created_on @issue.created_on |
|
29 | api.created_on @issue.created_on | |
30 | api.updated_on @issue.updated_on |
|
30 | api.updated_on @issue.updated_on | |
31 |
|
31 | |||
|
32 | render_api_issue_children(@issue, api) | |||
|
33 | ||||
32 | api.array :relations do |
|
34 | api.array :relations do | |
33 | @issue.relations.select {|r| r.other_issue(@issue).visible? }.each do |relation| |
|
35 | @issue.relations.select {|r| r.other_issue(@issue).visible? }.each do |relation| | |
34 | api.relation(:id => relation.id, :issue_id => relation.other_issue(@issue).id, :relation_type => relation.relation_type_for(@issue), :delay => relation.delay) |
|
36 | api.relation(:id => relation.id, :issue_id => relation.other_issue(@issue).id, :relation_type => relation.relation_type_for(@issue), :delay => relation.delay) |
@@ -89,6 +89,60 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||||
89 | context "/issues/6.json" do |
|
89 | context "/issues/6.json" do | |
90 | should_allow_api_authentication(:get, "/issues/6.json") |
|
90 | should_allow_api_authentication(:get, "/issues/6.json") | |
91 | end |
|
91 | end | |
|
92 | ||||
|
93 | context "GET /issues/:id" do | |||
|
94 | context "with subtasks" do | |||
|
95 | setup do | |||
|
96 | @c1 = Issue.generate!(:status_id => 1, :subject => "child c1", :tracker_id => 1, :project_id => 1, :parent_issue_id => 1) | |||
|
97 | @c2 = Issue.generate!(:status_id => 1, :subject => "child c2", :tracker_id => 1, :project_id => 1, :parent_issue_id => 1) | |||
|
98 | @c3 = Issue.generate!(:status_id => 1, :subject => "child c3", :tracker_id => 1, :project_id => 1, :parent_issue_id => @c1.id) | |||
|
99 | end | |||
|
100 | ||||
|
101 | context ".xml" do | |||
|
102 | should "display children" do | |||
|
103 | get '/issues/1.xml' | |||
|
104 | ||||
|
105 | assert_tag :tag => 'issue', | |||
|
106 | :child => { | |||
|
107 | :tag => 'children', | |||
|
108 | :children => {:count => 2}, | |||
|
109 | :child => { | |||
|
110 | :tag => 'issue', | |||
|
111 | :attributes => {:id => @c1.id.to_s}, | |||
|
112 | :child => { | |||
|
113 | :tag => 'subject', | |||
|
114 | :content => 'child c1', | |||
|
115 | :sibling => { | |||
|
116 | :tag => 'children', | |||
|
117 | :children => {:count => 1}, | |||
|
118 | :child => { | |||
|
119 | :tag => 'issue', | |||
|
120 | :attributes => {:id => @c3.id.to_s} | |||
|
121 | } | |||
|
122 | } | |||
|
123 | } | |||
|
124 | } | |||
|
125 | } | |||
|
126 | end | |||
|
127 | ||||
|
128 | context ".json" do | |||
|
129 | should "display children" do | |||
|
130 | get '/issues/1.json' | |||
|
131 | ||||
|
132 | json = ActiveSupport::JSON.decode(response.body) | |||
|
133 | assert_equal([ | |||
|
134 | { | |||
|
135 | 'id' => @c1.id, 'subject' => 'child c1', 'tracker' => {'id' => 1, 'name' => 'Bug'}, | |||
|
136 | 'children' => [{ 'id' => @c3.id, 'subject' => 'child c3', 'tracker' => {'id' => 1, 'name' => 'Bug'} }] | |||
|
137 | }, | |||
|
138 | { 'id' => @c2.id, 'subject' => 'child c2', 'tracker' => {'id' => 1, 'name' => 'Bug'} } | |||
|
139 | ], | |||
|
140 | json['issue']['children']) | |||
|
141 | end | |||
|
142 | end | |||
|
143 | end | |||
|
144 | end | |||
|
145 | end | |||
92 |
|
146 | |||
93 | context "POST /issues.xml" do |
|
147 | context "POST /issues.xml" do | |
94 | should_allow_api_authentication(:post, |
|
148 | should_allow_api_authentication(:post, |
General Comments 0
You need to be logged in to leave comments.
Login now