Welcome to mirror list, hosted at ThFree Co, Russian Federation.

logout_spec.rb « admin_mode « admin « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 664eb51e58f57875548681ad97799e86234d5876 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Admin Mode Logout', :js do
  include TermsHelper
  include UserLoginHelper

  let(:user) { create(:admin) }

  shared_examples 'combined_menu: feature flag examples' do
    before do
      gitlab_sign_in(user)
      gitlab_enable_admin_mode_sign_in(user)
      visit admin_root_path
    end

    it 'disable removes admin mode and redirects to root page' do
      pending_on_combined_menu_flag

      gitlab_disable_admin_mode

      expect(current_path).to eq root_path
      expect(page).to have_link(href: new_admin_session_path)
    end

    it 'disable shows flash notice' do
      pending_on_combined_menu_flag

      gitlab_disable_admin_mode

      expect(page).to have_selector('.flash-notice')
    end

    context 'on a read-only instance' do
      before do
        allow(Gitlab::Database).to receive(:read_only?).and_return(true)
      end

      it 'disable removes admin mode and redirects to root page' do
        pending_on_combined_menu_flag

        gitlab_disable_admin_mode

        expect(current_path).to eq root_path
        expect(page).to have_link(href: new_admin_session_path)
      end
    end
  end

  context 'with combined_menu: feature flag on' do
    let(:needs_rewrite_for_combined_menu_flag_on) { true }

    before do
      stub_feature_flags(combined_menu: true)
    end

    it_behaves_like 'combined_menu: feature flag examples'
  end

  context 'with combined_menu feature flag off' do
    let(:needs_rewrite_for_combined_menu_flag_on) { false }

    before do
      stub_feature_flags(combined_menu: false)
    end

    it_behaves_like 'combined_menu: feature flag examples'
  end

  def pending_on_combined_menu_flag
    pending 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56587' if needs_rewrite_for_combined_menu_flag_on
  end
end