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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-03 21:10:03 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-03 21:10:03 +0300
commitb6847c621ff246e6abceb90545d5a608318762d6 (patch)
tree460da2a6c2be2e4f5164c2bba1851b66260f850d /spec/models
parentc08d9c22569d1c9e7c7737e183969593394133d9 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/user_spec.rb69
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