BigW Consortium Gitlab

help_pages_spec.rb 1.73 KB
Newer Older
1 2
require 'spec_helper'

3
describe 'Help Pages', feature: true do
4
  describe 'Get the main help page' do
5
    shared_examples_for 'help page' do |prefix: ''|
6
      it 'prefixes links correctly' do
7
        expect(page).to have_selector(%(div.documentation-index > ul a[href="#{prefix}/help/api/README.md"]))
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
      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
26 27 28 29 30 31 32 33 34

    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
35
  end
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

  context 'in a production environment with version check enabled', js: true do
    before do
      allow(Rails.env).to receive(:production?) { true }
      allow(current_application_settings).to receive(:version_check_enabled) { true }
      allow_any_instance_of(VersionCheck).to receive(:url) { '/version-check-url' }

      login_as :user
      visit help_path
    end

    it 'should display a version check image' do
      expect(find('.js-version-status-badge')).to be_visible
    end

    it 'should have a src url' do
      expect(find('.js-version-status-badge')['src']).to match(/\/version-check-url/)
    end

    it 'should hide the version check image if the image request fails' do
      # We use '--load-images=no' with poltergeist so we must trigger manually
      execute_script("$('.js-version-status-badge').trigger('error');")

      expect(find('.js-version-status-badge', visible: false)).not_to be_visible
    end
  end
62
end