summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-11-14 10:45:56 +0000
committerRémy Coutable <remy@rymai.me>2016-11-14 10:45:56 +0000
commit0f48abf24b0ba34aebfc1d0d52e9e22648b7da1a (patch)
tree1bd322f214a49853f1d41c68a404b1477f5f28d1 /spec
parent4e9b02c3e8174118c933e55aec3ddfd763c5984d (diff)
parentb99282804d682251928f932812068513f4061abb (diff)
downloadgitlab-ce-0f48abf24b0ba34aebfc1d0d52e9e22648b7da1a.tar.gz
Merge branch 'fix-help-page-links' into 'master'
Fix error links in help index page when access it with url `http://gitlab.example.com/help/` which have an extra slash Fixes #24349 See merge request !7396
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/help_controller_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb
index 33c75e7584f..6fc6ea95e13 100644
--- a/spec/controllers/help_controller_spec.rb
+++ b/spec/controllers/help_controller_spec.rb
@@ -7,6 +7,40 @@ describe HelpController do
sign_in(user)
end
+ describe 'GET #index' do
+ context 'when url prefixed without /help/' do
+ it 'has correct url prefix' do
+ stub_readme("[API](api/README.md)")
+ get :index
+ expect(assigns[:help_index]).to eq '[API](/help/api/README.md)'
+ end
+ end
+
+ context 'when url prefixed with help/' do
+ it 'will be an absolute path' do
+ stub_readme("[API](help/api/README.md)")
+ get :index
+ expect(assigns[:help_index]).to eq '[API](/help/api/README.md)'
+ end
+ end
+
+ context 'when url prefixed with help' do
+ it 'will be an absolute path' do
+ stub_readme("[API](helpful_hints/README.md)")
+ get :index
+ expect(assigns[:help_index]).to eq '[API](/help/helpful_hints/README.md)'
+ end
+ end
+
+ context 'when url prefixed with /help/' do
+ it 'will not be changed' do
+ stub_readme("[API](/help/api/README.md)")
+ get :index
+ expect(assigns[:help_index]).to eq '[API](/help/api/README.md)'
+ end
+ end
+ end
+
describe 'GET #show' do
context 'for Markdown formats' do
context 'when requested file exists' do
@@ -72,4 +106,8 @@ describe HelpController do
end
end
end
+
+ def stub_readme(content)
+ allow(File).to receive(:read).and_return(content)
+ end
end