Adds ?include=attachments option when retrieving a wiki page with the REST API (#7082).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10718 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-10-25 20:44:37 +00:00
parent eff874b29a
commit 03062394fc
2 changed files with 21 additions and 0 deletions

View File

@ -8,4 +8,10 @@ api.wiki_page do
api.author(:id => @content.author_id, :name => @content.author.name)
api.created_on @page.created_on
api.updated_on @content.updated_on
api.array :attachments do
@page.attachments.each do |attachment|
render_api_attachment(attachment, api)
end
end if include_in_api_response?('attachments')
end

View File

@ -59,6 +59,21 @@ class ApiTest::WikiPagesTest < ActionController::IntegrationTest
end
end
test "GET /projects/:project_id/wiki/:title.xml?include=attachments should include attachments" do
get '/projects/ecookbook/wiki/Page_with_an_inline_image.xml?include=attachments'
assert_response 200
assert_equal 'application/xml', response.content_type
assert_select 'wiki_page' do
assert_select 'title', :text => 'Page_with_an_inline_image'
assert_select 'attachments[type=array]' do
assert_select 'attachment' do
assert_select 'id', :text => '3'
assert_select 'filename', :text => 'logo.gif'
end
end
end
end
test "GET /projects/:project_id/wiki/:title.xml with unknown title and edit permission should respond with 404" do
get '/projects/ecookbook/wiki/Invalid_Page.xml', {}, credentials('jsmith')
assert_response 404