File: themed_layout_examples.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (35 lines) | stat: -rw-r--r-- 1,058 bytes parent folder | download
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("html.#{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("html.#{default_theme_class}")
          end

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