]> source.dussan.org Git - redmine.git/commitdiff
Fix WikiContentVersion API returns 500 if author is nil (#36494).
authorMarius Balteanu <marius.balteanu@zitec.com>
Fri, 18 Feb 2022 08:08:10 +0000 (08:08 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Fri, 18 Feb 2022 08:08:10 +0000 (08:08 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@21414 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/views/wiki/show.api.rsb
test/integration/api_test/wiki_pages_test.rb

index 8e082e123bcf93bb609df70b2fb9ea3738708a52..6165a94cc989599f414c07de1a223ee08b39f3b9 100644 (file)
@@ -5,7 +5,7 @@ api.wiki_page do
   end
   api.text @content.text
   api.version @content.version
-  api.author(:id => @content.author_id, :name => @content.author.name)
+  api.author(:id => @content.author_id, :name => @content.author.name) unless @content.author_id.nil?
   api.comments @content.comments
   api.created_on @page.created_on
   api.updated_on @content.updated_on
index 0b81c4341003fc3340728a0c62a9b4280117e55b..8caa75f7e5fdde2cb97fa92fd96087888aca18ed 100644 (file)
@@ -126,6 +126,17 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base
     assert_equal 'jsmith', page.content.author.login
   end
 
+  test "GET /projects/:project_id/wiki/:title/:version.xml should not includ author if not exists" do
+    WikiContentVersion.find_by_id(2).update(author_id: nil)
+
+    get '/projects/ecookbook/wiki/CookBook_documentation/2.xml'
+    assert_response 200
+    assert_equal 'application/xml', response.media_type
+    assert_select 'wiki_page' do
+      assert_select 'author', 0
+    end
+  end
+
   test "PUT /projects/:project_id/wiki/:title.xml with current versino should update wiki page" do
     assert_no_difference 'WikiPage.count' do
       assert_difference 'WikiContentVersion.count' do