summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Sidorenko <artem@posteo.de>2016-05-03 17:33:43 +0200
committerArtem Sidorenko <artem@posteo.de>2016-05-09 11:50:23 +0200
commit14b36f91d9d803850f59fe49961d6d6a9d540aab (patch)
treee2071f037b19010438c8d758f87ac355096d4fe7
parent0a103e983cccc9bb9a7a28fb4eacff8d624010f8 (diff)
downloadgitlab-ce-14b36f91d9d803850f59fe49961d6d6a9d540aab.tar.gz
Use the proper GitLab URL for links in Wiki
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/project_wiki.rb2
-rw-r--r--lib/gitlab/url_builder.rb2
-rw-r--r--spec/lib/gitlab/url_builder_spec.rb2
-rw-r--r--spec/models/project_wiki_spec.rb4
5 files changed, 7 insertions, 4 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 822fa4be565..b07b7da3300 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -36,6 +36,7 @@ v 8.8.0 (unreleased)
v 8.7.4
- Fix always showing build notification message when switching between merge requests
+ - Fix links on wiki pages for relative url setups. !4026 (Artem Sidorenko)
v 8.7.3
- Emails, Gitlab::Email::Message, Gitlab::Diff, and Premailer::Adapter::Nokogiri are now instrumented
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb
index 7c1a61bb0bf..c91cb70ae25 100644
--- a/app/models/project_wiki.rb
+++ b/app/models/project_wiki.rb
@@ -40,7 +40,7 @@ class ProjectWiki
end
def wiki_base_path
- ["/", @project.path_with_namespace, "/wikis"].join('')
+ [Gitlab.config.gitlab.url, "/", @project.path_with_namespace, "/wikis"].join('')
end
# Returns the Gollum::Wiki object.
diff --git a/lib/gitlab/url_builder.rb b/lib/gitlab/url_builder.rb
index 2bbbd3074e8..67a09d5abf5 100644
--- a/lib/gitlab/url_builder.rb
+++ b/lib/gitlab/url_builder.rb
@@ -62,7 +62,7 @@ module Gitlab
end
def wiki_page_url
- "#{Gitlab.config.gitlab.url}#{object.wiki.wiki_base_path}/#{object.slug}"
+ "#{object.wiki.wiki_base_path}/#{object.slug}"
end
end
end
diff --git a/spec/lib/gitlab/url_builder_spec.rb b/spec/lib/gitlab/url_builder_spec.rb
index bf11472407a..c8d3bc01395 100644
--- a/spec/lib/gitlab/url_builder_spec.rb
+++ b/spec/lib/gitlab/url_builder_spec.rb
@@ -112,7 +112,7 @@ describe Gitlab::UrlBuilder, lib: true do
wiki_page = build(:wiki_page)
url = described_class.build(wiki_page)
- expect(url).to eq "#{Gitlab.config.gitlab.url}#{wiki_page.wiki.wiki_base_path}/#{wiki_page.slug}"
+ expect(url).to eq "#{Gitlab.config.gitlab.url}/#{wiki_page.wiki.project.path_with_namespace}/wikis/#{wiki_page.slug}"
end
end
end
diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb
index 532e3f013fd..ea659f417f2 100644
--- a/spec/models/project_wiki_spec.rb
+++ b/spec/models/project_wiki_spec.rb
@@ -38,7 +38,9 @@ describe ProjectWiki, models: true do
describe "#wiki_base_path" do
it "returns the wiki base path" do
- wiki_base_path = "/#{project.path_with_namespace}/wikis"
+ gitlab_url = Gitlab.config.gitlab.url
+ wiki_base_path = "#{gitlab_url}/#{project.path_with_namespace}/wikis"
+
expect(subject.wiki_base_path).to eq(wiki_base_path)
end
end