Commit ce9cbde6 authored by Francisco Javier López's avatar Francisco Javier López Committed by Markus Koller

Fix bug with wiki async loading and relative url

parent ef8d8c27
...@@ -136,7 +136,7 @@ module WikiHelper ...@@ -136,7 +136,7 @@ module WikiHelper
end end
def wiki_page_render_api_endpoint(page) def wiki_page_render_api_endpoint(page)
api_v4_projects_wikis_path(wiki_page_render_api_endpoint_params(page)) expose_path(api_v4_projects_wikis_path(wiki_page_render_api_endpoint_params(page)))
end end
def wiki_markup_hash_by_name_id def wiki_markup_hash_by_name_id
......
...@@ -18,7 +18,7 @@ module EE ...@@ -18,7 +18,7 @@ module EE
def wiki_page_render_api_endpoint(page) def wiki_page_render_api_endpoint(page)
return super if page.wiki.is_a?(ProjectWiki) return super if page.wiki.is_a?(ProjectWiki)
api_v4_groups_wikis_path(wiki_page_render_api_endpoint_params(page)) expose_path(api_v4_groups_wikis_path(wiki_page_render_api_endpoint_params(page)))
end end
end end
end end
...@@ -10,4 +10,8 @@ RSpec.describe WikiHelper do ...@@ -10,4 +10,8 @@ RSpec.describe WikiHelper do
expect(helper.wiki_attachment_upload_url).to end_with("/api/v4/groups/#{@wiki.group.id}/wikis/attachments") expect(helper.wiki_attachment_upload_url).to end_with("/api/v4/groups/#{@wiki.group.id}/wikis/attachments")
end end
end end
it_behaves_like 'wiki endpoint helpers' do
let_it_be(:page) { create(:wiki_page, wiki: create(:group_wiki)) }
end
end end
...@@ -145,4 +145,8 @@ RSpec.describe WikiHelper do ...@@ -145,4 +145,8 @@ RSpec.describe WikiHelper do
expect(subject).to include('wiki-directory-nest-level' => 0) expect(subject).to include('wiki-directory-nest-level' => 0)
end end
end end
it_behaves_like 'wiki endpoint helpers' do
let_it_be(:page) { create(:wiki_page) }
end
end end
# frozen_string_literal: true
RSpec.shared_examples 'wiki endpoint helpers' do
let(:resource_path) { page.wiki.container.class.to_s.pluralize.downcase }
let(:url) { "/api/v4/#{resource_path}/#{page.wiki.container.id}/wikis/#{page.slug}?version=#{page.version.id}"}
it 'returns the full endpoint url' do
expect(helper.wiki_page_render_api_endpoint(page)).to end_with(url)
end
context 'when relative url is set' do
let(:relative_url) { "/gitlab#{url}" }
it 'returns the full endpoint url with the relative path' do
stub_config_setting(relative_url_root: '/gitlab')
expect(helper.wiki_page_render_api_endpoint(page)).to end_with(relative_url)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment