Skip to content

Allow Wiki REST endpoint to retrieve page versions

What does this MR do and why?

This is additional work needed for #336792 (closed).

In #336792 (closed), we want to load pages async. Nevertheless, we can not only render the last version of the page, but also older ones.

The current REST endpoint only allows us to render the last version, so we need to add that functionality.

How to set up and validate locally

  1. We need an existing wiki with pages. Let's say that it is stored in wiki which belong to a project with id 6, and the page name is home
  2. Execute the following to get that pages version: page = wiki.find_page('home'); old_version = page.last_version.id
  3. Now, update the page: wiki.update_page(page.page, content: 'New content', message: 'updated page')
  4. Check that when we ask the API without any other info we get the last version: http://127.0.0.1:3000/api/v4/projects/6/wikis/home
  5. The content in the response debería ser New content
  6. Now retrieve the old version of the page using last_version: http://127.0.0.1:3000/api/v4/projects/6/wikis/home?version=<last_version here>
  7. Check that we get in content the old data in the page

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #336792 (closed)

Merge request reports