summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/views/themed_layout_examples.rb
blob: 599fd141dd78842bef7ce6e7ae85f95907ce1183 (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
# frozen_string_literal: true

RSpec.shared_examples "a layout which reflects the application theme setting" do
  context 'as a themed layout' do
    let(:default_theme_class) { ::Gitlab::Themes.default.css_class }

    context 'when no theme is explicitly selected' do
      it 'renders with the default theme' do
        render

        expect(rendered).to have_selector("body.#{default_theme_class}")
      end
    end

    context 'when user is authenticated & has selected a specific theme' do
      before do
        allow(view).to receive(:user_application_theme).and_return(chosen_theme.css_class)
      end

      where(chosen_theme: ::Gitlab::Themes.available_themes)

      with_them do
        it "renders with the #{params[:chosen_theme].name} theme" do
          render

          if chosen_theme.css_class != default_theme_class
            expect(rendered).not_to have_selector("body.#{default_theme_class}")
          end

          expect(rendered).to have_selector("body.#{chosen_theme.css_class}")
        end
      end
    end
  end
end