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

password_menu_spec.rb « menus « user_settings « sidebars « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 168019fea5d797dfcad566ed35b6930609315265 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Sidebars::UserSettings::Menus::PasswordMenu, feature_category: :navigation do
  it_behaves_like 'User settings menu',
    link: '/-/profile/password',
    title: _('Password'),
    icon: 'lock',
    active_routes: { controller: :passwords }

  describe '#render?' do
    subject { described_class.new(context) }

    let_it_be(:user) { build(:user) }
    let(:context) { Sidebars::Context.new(current_user: user, container: nil) }

    context 'when password authentication is enabled' do
      before do
        allow(user).to receive(:allow_password_authentication?).and_return(true)
      end

      it 'renders' do
        expect(subject.render?).to be true
      end
    end

    context 'when password authentication is disabled' do
      before do
        allow(user).to receive(:allow_password_authentication?).and_return(false)
      end

      it 'renders' do
        expect(subject.render?).to be false
      end
    end
  end
end