Commit f659545e authored by Markus Koller's avatar Markus Koller

Merge branch '356406-fj-fix-bug-with-relative-url' into 'master'

Fix bug with wiki async loading and relative url

See merge request gitlab-org/gitlab!85075
parents 8edfaf0b ce9cbde6
......@@ -136,7 +136,7 @@ module WikiHelper
end
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
def wiki_markup_hash_by_name_id
......
......@@ -18,7 +18,7 @@ module EE
def wiki_page_render_api_endpoint(page)
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
......@@ -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")
end
end
it_behaves_like 'wiki endpoint helpers' do
let_it_be(:page) { create(:wiki_page, wiki: create(:group_wiki)) }
end
end
......@@ -145,4 +145,8 @@ RSpec.describe WikiHelper do
expect(subject).to include('wiki-directory-nest-level' => 0)
end
end
it_behaves_like 'wiki endpoint helpers' do
let_it_be(:page) { create(:wiki_page) }
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