2015-01-15 20:06:32 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-01-18 11:21:18 -05:00
|
|
|
describe 'Help Pages', feature: true do
|
2016-11-25 12:26:24 -05:00
|
|
|
describe 'Get the main help page' do
|
2016-12-01 06:07:52 -05:00
|
|
|
shared_examples_for 'help page' do |prefix: ''|
|
2016-11-25 12:26:24 -05:00
|
|
|
it 'prefixes links correctly' do
|
2016-12-01 06:07:52 -05:00
|
|
|
expect(page).to have_selector(%(div.documentation-index > ul a[href="#{prefix}/help/api/README.md"]))
|
2016-11-25 12:26:24 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'without a trailing slash' do
|
|
|
|
before do
|
|
|
|
visit help_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'help page'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a trailing slash' do
|
|
|
|
before do
|
|
|
|
visit help_path + '/'
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'help page'
|
|
|
|
end
|
2016-12-01 06:07:52 -05:00
|
|
|
|
|
|
|
context 'with a relative installation' do
|
|
|
|
before do
|
|
|
|
stub_config_setting(relative_url_root: '/gitlab')
|
|
|
|
visit help_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'help page', prefix: '/gitlab'
|
|
|
|
end
|
2016-11-25 12:26:24 -05:00
|
|
|
end
|
2017-01-12 09:00:06 -05:00
|
|
|
|
2017-06-08 05:55:07 -04:00
|
|
|
context 'in a production environment with version check enabled', :js do
|
2017-01-12 09:00:06 -05:00
|
|
|
before do
|
|
|
|
allow(Rails.env).to receive(:production?) { true }
|
2017-06-13 12:46:02 -04:00
|
|
|
allow_any_instance_of(ApplicationSetting).to receive(:version_check_enabled) { true }
|
2017-01-12 09:00:06 -05:00
|
|
|
allow_any_instance_of(VersionCheck).to receive(:url) { '/version-check-url' }
|
|
|
|
|
2017-06-05 14:44:29 -04:00
|
|
|
gitlab_sign_in :user
|
2017-01-12 09:00:06 -05:00
|
|
|
visit help_path
|
|
|
|
end
|
|
|
|
|
2017-06-08 05:55:07 -04:00
|
|
|
it 'has a version check image' do
|
|
|
|
expect(find('.js-version-status-badge', visible: false)['src']).to end_with('/version-check-url')
|
2017-01-12 09:00:06 -05:00
|
|
|
end
|
|
|
|
|
2017-06-08 05:55:07 -04:00
|
|
|
it 'hides the version check image if the image request fails' do
|
|
|
|
# We use '--load-images=yes' with poltergeist so the image fails to load
|
2017-01-12 09:00:06 -05:00
|
|
|
expect(find('.js-version-status-badge', visible: false)).not_to be_visible
|
|
|
|
end
|
|
|
|
end
|
2017-06-13 12:46:02 -04:00
|
|
|
|
|
|
|
describe 'when help page is customized' do
|
|
|
|
before do
|
|
|
|
allow_any_instance_of(ApplicationSetting).to receive(:help_page_hide_commercial_content?) { true }
|
|
|
|
allow_any_instance_of(ApplicationSetting).to receive(:help_page_text) { "My Custom Text" }
|
|
|
|
allow_any_instance_of(ApplicationSetting).to receive(:help_page_support_url) { "http://example.com/help" }
|
|
|
|
|
2017-06-05 14:44:29 -04:00
|
|
|
gitlab_sign_in(:user)
|
2017-06-13 12:46:02 -04:00
|
|
|
visit help_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should display custom help page text' do
|
|
|
|
expect(page).to have_text "My Custom Text"
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should hide marketing content when enabled' do
|
|
|
|
expect(page).not_to have_link "Get a support subscription"
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should use a custom support url' do
|
|
|
|
expect(page).to have_link "See our website for getting help", href: "http://example.com/help"
|
|
|
|
end
|
|
|
|
end
|
2015-01-15 20:06:32 -05:00
|
|
|
end
|