diff options
Diffstat (limited to 'spec/controllers/help_controller_spec.rb')
-rw-r--r-- | spec/controllers/help_controller_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb index 33c75e7584f..d3489324a9c 100644 --- a/spec/controllers/help_controller_spec.rb +++ b/spec/controllers/help_controller_spec.rb @@ -7,6 +7,38 @@ describe HelpController do sign_in(user) end + describe 'GET #index' do + context 'with absolute url' do + it 'keeps the URL absolute' do + stub_readme("[API](/api/README.md)") + + get :index + + expect(assigns[:help_index]).to eq '[API](/api/README.md)' + end + end + + context 'with relative url' do + it 'prefixes it with /help/' 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 is an external link' do + it 'does not change it' do + stub_readme("[external](https://some.external.link)") + + get :index + + expect(assigns[:help_index]).to eq '[external](https://some.external.link)' + end + end + end + describe 'GET #show' do context 'for Markdown formats' do context 'when requested file exists' do @@ -72,4 +104,8 @@ describe HelpController do end end end + + def stub_readme(content) + allow(File).to receive(:read).and_return(content) + end end |