about summary refs log tree commit diff
path: root/spec/views/about/_links.html.haml_spec.rb
blob: 2d7f7467a04df567f5e02d6a1834d0f8331e14c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true

require 'rails_helper'

describe 'about/_links.html.haml' do
  context 'when signed in' do
    before do
      allow(view).to receive(:user_signed_in?).and_return(true)
    end

    it 'does not show sign in link' do
      render 'about/links', instance: InstancePresenter.new

      expect(rendered).to have_content(I18n.t('about.get_started'))
      expect(rendered).not_to have_content(I18n.t('auth.login'))
    end
  end

  context 'when signed out' do
    before do
      allow(view).to receive(:user_signed_in?).and_return(false)
    end

    it 'shows get started link when registrations are allowed' do
      render 'about/links', instance: double(open_registrations: true)

      expect(rendered).to have_content(I18n.t('about.get_started'))
      expect(rendered).to have_content(I18n.t('auth.login'))
    end

    it 'hides get started link when registrations are closed' do
      render 'about/links', instance: double(open_registrations: false)

      expect(rendered).not_to have_content(I18n.t('about.get_started'))
      expect(rendered).to have_content(I18n.t('auth.login'))
    end
  end
end