Commit 26fded71 authored by Pavel Shutsin's avatar Pavel Shutsin

Remove unused User.internal scope

It looks like it's not used anymore
parent c58e66d1
......@@ -324,6 +324,7 @@ class User < ApplicationRecord
scope :active, -> { with_state(:active).non_internal }
scope :active_without_ghosts, -> { with_state(:active).without_ghosts }
scope :without_ghosts, -> { humans.or(where.not(user_type: :ghost)) }
scope :non_internal, -> { without_ghosts.with_project_bots }
scope :deactivated, -> { with_state(:deactivated).non_internal }
scope :without_projects, -> { joins('LEFT JOIN project_authorizations ON users.id = project_authorizations.user_id').where(project_authorizations: { user_id: nil }) }
scope :order_recent_sign_in, -> { reorder(Gitlab::Database.nulls_last_order('current_sign_in_at', 'DESC')) }
......@@ -650,6 +651,10 @@ class User < ApplicationRecord
end
end
#
# Instance methods
#
def full_path
username
end
......@@ -663,25 +668,7 @@ class User < ApplicationRecord
def internal?
ghost? || (bot? && !project_bot?)
end
def self.internal
where(user_type: :ghost).or(bots)
end
# The explicit check for project_bot will be removed with Bot Categorization
# Ref: https://gitlab.com/gitlab-org/gitlab/-/issues/213945
def self.non_internal
without_ghosts.with_project_bots
end
def human?
user_type.nil?
end
#
# Instance methods
#
def to_param
username
end
......
......@@ -4354,31 +4354,31 @@ describe User, :do_not_mock_admin_mode do
end
end
describe 'internal methods' do
let_it_be(:user) { create(:user) }
let_it_be(:ghost) { described_class.ghost }
let_it_be(:alert_bot) { described_class.alert_bot }
let_it_be(:project_bot) { create(:user, :project_bot) }
let_it_be(:non_internal) { [user, project_bot] }
let_it_be(:internal) { [ghost, alert_bot] }
it 'returns internal users' do
expect(described_class.internal).to match_array(internal)
expect(internal.all?(&:internal?)).to eq(true)
end
describe '.non_internal' do
let!(:user) { create(:user) }
let!(:ghost) { described_class.ghost }
let!(:alert_bot) { described_class.alert_bot }
let!(:project_bot) { create(:user, :project_bot) }
let(:non_internal) { [user, project_bot] }
it 'returns non internal users' do
expect(described_class.non_internal).to match_array(non_internal)
expect(described_class.non_internal).to eq(non_internal)
expect(non_internal.all?(&:internal?)).to eq(false)
end
end
describe '#bot?' do
let!(:user) { create(:user) }
let!(:ghost) { described_class.ghost }
let!(:alert_bot) { described_class.alert_bot }
let!(:project_bot) { create(:user, :project_bot) }
describe '#bot?' do
it 'marks bot users' do
expect(user.bot?).to eq(false)
expect(ghost.bot?).to eq(false)
it 'marks bot users' do
expect(user).not_to be_bot
expect(ghost).not_to be_bot
expect(alert_bot.bot?).to eq(true)
end
expect(alert_bot).to be_bot
expect(project_bot).to be_bot
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment