Browse Source

Add attachment information to issues.xml in REST API (#12181).

git-svn-id: http://svn.redmine.org/redmine/trunk@16360 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/3.4.0
Jean-Philippe Lang 7 years ago
parent
commit
331c1f674d
2 changed files with 22 additions and 0 deletions
  1. 6
    0
      app/views/issues/index.api.rsb
  2. 16
    0
      test/integration/api_test/issues_test.rb

+ 6
- 0
app/views/issues/index.api.rsb View File

@@ -26,6 +26,12 @@ api.array :issues, api_meta(:total_count => @issue_count, :offset => @offset, :l
api.updated_on issue.updated_on
api.closed_on issue.closed_on

api.array :attachments do
issue.attachments.each do |attachment|
render_api_attachment(attachment, api)
end
end if include_in_api_response?('attachments')

api.array :relations do
issue.relations.each do |relation|
api.relation(:id => relation.id, :issue_id => relation.issue_from_id, :issue_to_id => relation.issue_to_id, :relation_type => relation.relation_type, :delay => relation.delay)

+ 16
- 0
test/integration/api_test/issues_test.rb View File

@@ -82,6 +82,22 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
end
end

test "GET /issues.xml with attachments" do
get '/issues.xml?include=attachments'

assert_response :success
assert_equal 'application/xml', @response.content_type

assert_select 'issue id', :text => '3' do
assert_select '~ attachments attachment', 4
end

assert_select 'issue id', :text => '1' do
assert_select '~ attachments'
assert_select '~ attachments attachment', 0
end
end

test "GET /issues.xml with invalid query params" do
get '/issues.xml', {:f => ['start_date'], :op => {:start_date => '='}}


Loading…
Cancel
Save