diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-03 18:10:03 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-03 18:10:03 +0000 |
commit | b6847c621ff246e6abceb90545d5a608318762d6 (patch) | |
tree | 460da2a6c2be2e4f5164c2bba1851b66260f850d /spec/models | |
parent | c08d9c22569d1c9e7c7737e183969593394133d9 (diff) | |
download | gitlab-ce-b6847c621ff246e6abceb90545d5a608318762d6.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/user_spec.rb | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 291c628bfde..12f83e6d8c6 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -4475,4 +4475,73 @@ describe User, :do_not_mock_admin_mode do end end end + + describe '#active_for_authentication?' do + subject { user.active_for_authentication? } + + let(:user) { create(:user) } + + context 'when user is blocked' do + before do + user.block + end + + it { is_expected.to be false } + end + + context 'when user is a ghost user' do + before do + user.update(ghost: true) + end + + it { is_expected.to be false } + end + + context 'based on user type' do + using RSpec::Parameterized::TableSyntax + + where(:user_type, :expected_result) do + 'human' | true + 'alert_bot' | false + end + + with_them do + before do + user.update(user_type: user_type) + end + + it { is_expected.to be expected_result } + end + end + end + + describe '#inactive_message' do + subject { user.inactive_message } + + let(:user) { create(:user) } + + context 'when user is blocked' do + before do + user.block + end + + it { is_expected.to eq User::BLOCKED_MESSAGE } + end + + context 'when user is an internal user' do + before do + user.update(ghost: true) + end + + it { is_expected.to be User::LOGIN_FORBIDDEN } + end + + context 'when user is locked' do + before do + user.lock_access! + end + + it { is_expected.to be :locked } + end + end end |