@@ -866,6 +866,16 module ApplicationHelper | |||
|
866 | 866 | def favicon |
|
867 | 867 | "<link rel='shortcut icon' href='#{image_path('/favicon.ico')}' />" |
|
868 | 868 | end |
|
869 | ||
|
870 | # Returns true if arg is expected in the API response | |
|
871 | def include_in_api_response?(arg) | |
|
872 | unless @included_in_api_response | |
|
873 | param = params[:include] | |
|
874 | @included_in_api_response = param.is_a?(Array) ? param.collect(&:to_s) : param.to_s.split(',') | |
|
875 | @included_in_api_response.collect!(&:strip) | |
|
876 | end | |
|
877 | @included_in_api_response.include?(arg.to_s) | |
|
878 | end | |
|
869 | 879 | |
|
870 | 880 | private |
|
871 | 881 |
@@ -25,13 +25,13 api.issue do | |||
|
25 | 25 | api.created_on @issue.created_on |
|
26 | 26 | api.updated_on @issue.updated_on |
|
27 | 27 | |
|
28 | render_api_issue_children(@issue, api) | |
|
28 | render_api_issue_children(@issue, api) if include_in_api_response?('children') | |
|
29 | 29 | |
|
30 | 30 | api.array :relations do |
|
31 | 31 | @issue.relations.select {|r| r.other_issue(@issue).visible? }.each do |relation| |
|
32 | 32 | api.relation(:id => relation.id, :issue_id => relation.other_issue(@issue).id, :relation_type => relation.relation_type_for(@issue), :delay => relation.delay) |
|
33 | 33 | end |
|
34 | end | |
|
34 | end if include_in_api_response?('relations') | |
|
35 | 35 | |
|
36 | 36 | api.array :changesets do |
|
37 | 37 | @issue.changesets.each do |changeset| |
@@ -41,7 +41,7 api.issue do | |||
|
41 | 41 | api.committed_on changeset.committed_on |
|
42 | 42 | end |
|
43 | 43 | end |
|
44 |
end if User.current.allowed_to?(:view_changesets, @project) |
|
|
44 | end if include_in_api_response?('changesets') && User.current.allowed_to?(:view_changesets, @project) | |
|
45 | 45 | |
|
46 | 46 | api.array :journals do |
|
47 | 47 | @issue.journals.each do |journal| |
@@ -58,5 +58,5 api.issue do | |||
|
58 | 58 | end |
|
59 | 59 | end |
|
60 | 60 | end |
|
61 | end unless @issue.journals.empty? | |
|
61 | end if include_in_api_response?('journals') | |
|
62 | 62 | end |
@@ -14,5 +14,5 api.project do | |||
|
14 | 14 | @project.trackers.each do |tracker| |
|
15 | 15 | api.tracker(:id => tracker.id, :name => tracker.name) |
|
16 | 16 | end |
|
17 | end | |
|
17 | end if include_in_api_response?('trackers') | |
|
18 | 18 | end |
@@ -20,5 +20,5 api.user do | |||
|
20 | 20 | end |
|
21 | 21 | end if membership.project |
|
22 | 22 | end |
|
23 | end if @memberships.present? | |
|
23 | end if include_in_api_response?('memberships') && @memberships | |
|
24 | 24 | end |
@@ -94,7 +94,7 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
94 | 94 | context "with journals" do |
|
95 | 95 | context ".xml" do |
|
96 | 96 | should "display journals" do |
|
97 | get '/issues/1.xml' | |
|
97 | get '/issues/1.xml?include=journals' | |
|
98 | 98 | |
|
99 | 99 | assert_tag :tag => 'issue', |
|
100 | 100 | :child => { |
@@ -160,7 +160,7 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
160 | 160 | |
|
161 | 161 | context ".xml" do |
|
162 | 162 | should "display children" do |
|
163 | get '/issues/1.xml' | |
|
163 | get '/issues/1.xml?include=children' | |
|
164 | 164 | |
|
165 | 165 | assert_tag :tag => 'issue', |
|
166 | 166 | :child => { |
@@ -187,7 +187,7 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
187 | 187 | |
|
188 | 188 | context ".json" do |
|
189 | 189 | should "display children" do |
|
190 | get '/issues/1.json' | |
|
190 | get '/issues/1.json?include=children' | |
|
191 | 191 | |
|
192 | 192 | json = ActiveSupport::JSON.decode(response.body) |
|
193 | 193 | assert_equal([ |
General Comments 0
You need to be logged in to leave comments.
Login now