debian-mirror-gitlab/spec/features/admin/admin_mode/logout_spec.rb

75 lines
1.8 KiB
Ruby
Raw Normal View History

2020-04-08 14:13:33 +05:30
# frozen_string_literal: true
require 'spec_helper'
2021-02-22 17:27:13 +05:30
RSpec.describe 'Admin Mode Logout', :js do
2020-04-08 14:13:33 +05:30
include TermsHelper
include UserLoginHelper
let(:user) { create(:admin) }
2021-06-08 01:23:25 +05:30
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
2021-04-29 21:17:54 +05:30
2021-06-08 01:23:25 +05:30
it 'disable removes admin mode and redirects to root page' do
pending_on_combined_menu_flag
2020-04-08 14:13:33 +05:30
2021-06-08 01:23:25 +05:30
gitlab_disable_admin_mode
2020-04-08 14:13:33 +05:30
2021-06-08 01:23:25 +05:30
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
2020-04-08 14:13:33 +05:30
2021-06-08 01:23:25 +05:30
context 'on a read-only instance' do
before do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
end
2020-04-08 14:13:33 +05:30
2021-06-08 01:23:25 +05:30
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
2020-04-08 14:13:33 +05:30
end
2021-06-08 01:23:25 +05:30
context 'with combined_menu: feature flag on' do
let(:needs_rewrite_for_combined_menu_flag_on) { true }
2020-04-08 14:13:33 +05:30
before do
2021-06-08 01:23:25 +05:30
stub_feature_flags(combined_menu: true)
2020-04-08 14:13:33 +05:30
end
2021-06-08 01:23:25 +05:30
it_behaves_like 'combined_menu: feature flag examples'
end
2020-04-08 14:13:33 +05:30
2021-06-08 01:23:25 +05:30
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)
2020-04-08 14:13:33 +05:30
end
2021-06-08 01:23:25 +05:30
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
2020-04-08 14:13:33 +05:30
end
end