BigW Consortium Gitlab

index.html.haml_spec.rb 908 Bytes
Newer Older
1 2 3 4 5
require 'rails_helper'

describe 'help/index' do
  describe 'version information' do
    it 'is hidden from guests' do
6
      stub_user(nil)
7 8 9 10 11 12 13 14 15
      stub_version('8.0.2', 'abcdefg')
      stub_helpers

      render

      expect(rendered).not_to match '8.0.2'
      expect(rendered).not_to match 'abcdefg'
    end

16 17
    it 'is shown to users' do
      stub_user
18 19 20 21 22 23 24 25 26 27
      stub_version('8.0.2', 'abcdefg')
      stub_helpers

      render

      expect(rendered).to match '8.0.2'
      expect(rendered).to match 'abcdefg'
    end
  end

28 29
  def stub_user(user = double)
    allow(view).to receive(:user_signed_in?).and_return(user)
30 31 32 33 34 35 36 37 38
  end

  def stub_version(version, revision)
    stub_const('Gitlab::VERSION', version)
    stub_const('Gitlab::REVISION', revision)
  end

  def stub_helpers
    allow(view).to receive(:markdown).and_return('')
39
    allow(view).to receive(:version_status_badge).and_return('')
40 41
  end
end