Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
26fded71
Commit
26fded71
authored
Apr 15, 2020
by
Pavel Shutsin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused User.internal scope
It looks like it's not used anymore
parent
c58e66d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
38 deletions
+25
-38
app/models/user.rb
app/models/user.rb
+6
-19
spec/models/user_spec.rb
spec/models/user_spec.rb
+19
-19
No files found.
app/models/user.rb
View file @
26fded71
...
...
@@ -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
...
...
spec/models/user_spec.rb
View file @
26fded71
...
...
@@ -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
)
e
nd
expect
(
alert_bot
).
to
be_bot
e
xpect
(
project_bot
).
to
be_bot
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment