2018-10-01 09:59:44 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 03:56:52 -04:00
|
|
|
require 'spec_helper'
|
2015-09-23 16:20:58 -04:00
|
|
|
|
2020-06-24 11:08:50 -04:00
|
|
|
RSpec.describe 'help/index' do
|
2018-10-01 09:59:44 -04:00
|
|
|
include StubVersion
|
|
|
|
|
2015-09-23 16:20:58 -04:00
|
|
|
describe 'version information' do
|
2018-10-01 09:59:44 -04:00
|
|
|
before do
|
|
|
|
stub_helpers
|
|
|
|
end
|
|
|
|
|
2015-09-23 16:20:58 -04:00
|
|
|
it 'is hidden from guests' do
|
2015-09-23 17:18:15 -04:00
|
|
|
stub_user(nil)
|
2015-09-23 16:20:58 -04:00
|
|
|
stub_version('8.0.2', 'abcdefg')
|
|
|
|
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).not_to match '8.0.2'
|
|
|
|
expect(rendered).not_to match 'abcdefg'
|
|
|
|
end
|
|
|
|
|
2018-10-01 09:59:44 -04:00
|
|
|
context 'when logged in' do
|
2021-05-17 14:10:42 -04:00
|
|
|
def version_link_regexp(path)
|
|
|
|
base_url = "#{view.source_host_url}/#{view.source_code_group}"
|
|
|
|
%r{#{Regexp.escape(base_url)}/(gitlab|gitlab\-foss)/#{Regexp.escape(path)}}
|
|
|
|
end
|
|
|
|
|
2018-10-01 09:59:44 -04:00
|
|
|
before do
|
|
|
|
stub_user
|
|
|
|
end
|
2015-09-23 16:20:58 -04:00
|
|
|
|
2018-10-01 09:59:44 -04:00
|
|
|
it 'shows a link to the tag to users' do
|
|
|
|
stub_version('8.0.2', 'abcdefg')
|
|
|
|
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to match '8.0.2'
|
2021-05-17 14:10:42 -04:00
|
|
|
expect(rendered).to have_link('8.0.2', href: version_link_regexp('-/tags/v8.0.2'))
|
2018-10-01 09:59:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows a link to the commit for pre-releases' do
|
|
|
|
stub_version('8.0.2-pre', 'abcdefg')
|
2015-09-23 16:20:58 -04:00
|
|
|
|
2018-10-01 09:59:44 -04:00
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to match '8.0.2'
|
2021-05-17 14:10:42 -04:00
|
|
|
expect(rendered).to have_link('abcdefg', href: version_link_regexp('-/commits/abcdefg'))
|
2018-10-01 09:59:44 -04:00
|
|
|
end
|
2015-09-23 16:20:58 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-24 10:34:36 -04:00
|
|
|
describe 'instance configuration link' do
|
|
|
|
it 'is visible to guests' do
|
|
|
|
render
|
|
|
|
|
2018-09-14 16:36:40 -04:00
|
|
|
expect(rendered).to have_link(nil, href: help_instance_configuration_url)
|
2017-08-24 10:34:36 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-30 05:09:39 -04:00
|
|
|
describe 'Markdown rendering' do
|
|
|
|
before do
|
|
|
|
assign(:help_index, 'Welcome to [GitLab](https://about.gitlab.com/) Documentation.')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders Markdown' do
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to have_link('GitLab', href: 'https://about.gitlab.com/')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-23 17:18:15 -04:00
|
|
|
def stub_user(user = double)
|
|
|
|
allow(view).to receive(:user_signed_in?).and_return(user)
|
2015-09-23 16:20:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def stub_helpers
|
|
|
|
allow(view).to receive(:markdown).and_return('')
|
2015-09-23 16:26:15 -04:00
|
|
|
allow(view).to receive(:version_status_badge).and_return('')
|
2017-08-31 05:47:03 -04:00
|
|
|
allow(view).to receive(:current_application_settings).and_return(Gitlab::CurrentSettings.current_application_settings)
|
2015-09-23 16:20:58 -04:00
|
|
|
end
|
|
|
|
end
|