2015-09-23 16:20:58 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe 'help/index' do
|
|
|
|
describe 'version information' do
|
|
|
|
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')
|
|
|
|
stub_helpers
|
|
|
|
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).not_to match '8.0.2'
|
|
|
|
expect(rendered).not_to match 'abcdefg'
|
|
|
|
end
|
|
|
|
|
2015-09-23 17:18:15 -04:00
|
|
|
it 'is shown to users' do
|
|
|
|
stub_user
|
2015-09-23 16:20:58 -04:00
|
|
|
stub_version('8.0.2', 'abcdefg')
|
|
|
|
stub_helpers
|
|
|
|
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to match '8.0.2'
|
2017-06-08 09:43:06 -04:00
|
|
|
expect(rendered).to have_link('abcdefg', 'https://gitlab.com/gitlab-org/gitlab-ce/commits/abcdefg')
|
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
|
|
|
|
|
|
|
|
expect(rendered).to have_link(nil, help_instance_configuration_url)
|
|
|
|
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_version(version, revision)
|
|
|
|
stub_const('Gitlab::VERSION', version)
|
2018-05-24 03:57:54 -04:00
|
|
|
allow(Gitlab).to receive(:revision).and_return(revision)
|
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
|