summaryrefslogtreecommitdiff
path: root/spec/views/layouts/snippets.html.haml_spec.rb
blob: 5c182f715d6d607cb8a97333628e91cffd36da22 (plain)
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
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'layouts/snippets', feature_category: :source_code_management do
  before do
    allow(view).to receive(:current_user).and_return(user)
    allow(view).to receive(:current_user_mode).and_return(Gitlab::Auth::CurrentUserMode.new(user))
  end

  describe 'sidebar' do
    context 'when feature flag is on' do
      context 'when signed in' do
        let(:user) { build_stubbed(:user) }

        it 'renders the "Your work" sidebar' do
          render

          expect(rendered).to have_css('aside.nav-sidebar[aria-label="Your work"]')
        end
      end

      context 'when not signed in' do
        let(:user) { nil }

        it 'renders no sidebar' do
          render

          expect(rendered).not_to have_css('aside.nav-sidebar')
        end
      end
    end

    context 'when feature flag is off' do
      before do
        stub_feature_flags(your_work_sidebar: false)
      end

      let(:user) { build_stubbed(:user) }

      it 'renders no sidebar' do
        render

        expect(rendered).not_to have_css('aside.nav-sidebar')
      end
    end
  end
end