2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
require 'spec_helper'
|
2015-09-25 12:07:36 +05:30
|
|
|
|
|
|
|
describe 'help/index' do
|
2018-12-05 23:21:45 +05:30
|
|
|
include StubVersion
|
|
|
|
|
2015-09-25 12:07:36 +05:30
|
|
|
describe 'version information' do
|
2018-12-05 23:21:45 +05:30
|
|
|
before do
|
|
|
|
stub_helpers
|
|
|
|
end
|
|
|
|
|
2015-09-25 12:07:36 +05:30
|
|
|
it 'is hidden from guests' do
|
|
|
|
stub_user(nil)
|
|
|
|
stub_version('8.0.2', 'abcdefg')
|
|
|
|
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).not_to match '8.0.2'
|
|
|
|
expect(rendered).not_to match 'abcdefg'
|
|
|
|
end
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
context 'when logged in' do
|
|
|
|
before do
|
|
|
|
stub_user
|
|
|
|
end
|
2015-09-25 12:07:36 +05:30
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
it 'shows a link to the tag to users' do
|
|
|
|
stub_version('8.0.2', 'abcdefg')
|
|
|
|
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to match '8.0.2'
|
2019-12-04 20:38:33 +05:30
|
|
|
expect(rendered).to have_link('8.0.2', href: %r{https://gitlab.com/gitlab-org/(gitlab|gitlab-foss)/-/tags/v8.0.2})
|
2018-12-05 23:21:45 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows a link to the commit for pre-releases' do
|
|
|
|
stub_version('8.0.2-pre', 'abcdefg')
|
2015-09-25 12:07:36 +05:30
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to match '8.0.2'
|
2019-12-04 20:38:33 +05:30
|
|
|
expect(rendered).to have_link('abcdefg', href: %r{https://gitlab.com/gitlab-org/(gitlab|gitlab-foss)/commits/abcdefg})
|
2018-12-05 23:21:45 +05:30
|
|
|
end
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe 'instance configuration link' do
|
|
|
|
it 'is visible to guests' do
|
|
|
|
render
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
expect(rendered).to have_link(nil, href: help_instance_configuration_url)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-25 12:07:36 +05:30
|
|
|
def stub_user(user = double)
|
|
|
|
allow(view).to receive(:user_signed_in?).and_return(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
def stub_helpers
|
|
|
|
allow(view).to receive(:markdown).and_return('')
|
|
|
|
allow(view).to receive(:version_status_badge).and_return('')
|
2018-03-17 18:26:18 +05:30
|
|
|
allow(view).to receive(:current_application_settings).and_return(Gitlab::CurrentSettings.current_application_settings)
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
|
|
|
end
|