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
7de250fb
Commit
7de250fb
authored
Apr 05, 2018
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure internal users (ghost, support bot) get assigned a namespace
parent
eaed588b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
1 deletion
+10
-1
app/models/user.rb
app/models/user.rb
+3
-1
changelogs/unreleased/dm-internal-user-namespace.yml
changelogs/unreleased/dm-internal-user-namespace.yml
+5
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+2
-0
No files found.
app/models/user.rb
View file @
7de250fb
...
...
@@ -164,12 +164,15 @@ class User < ActiveRecord::Base
before_validation
:sanitize_attrs
before_validation
:set_notification_email
,
if: :email_changed?
before_save
:set_notification_email
,
if: :email_changed?
# in case validation is skipped
before_validation
:set_public_email
,
if: :public_email_changed?
before_save
:set_public_email
,
if: :public_email_changed?
# in case validation is skipped
before_save
:ensure_incoming_email_token
before_save
:ensure_user_rights_and_limits
,
if:
->
(
user
)
{
user
.
new_record?
||
user
.
external_changed?
}
before_save
:skip_reconfirmation!
,
if:
->
(
user
)
{
user
.
email_changed?
&&
user
.
read_only_attribute?
(
:email
)
}
before_save
:check_for_verified_email
,
if:
->
(
user
)
{
user
.
email_changed?
&&
!
user
.
new_record?
}
before_validation
:ensure_namespace_correct
before_save
:ensure_namespace_correct
# in case validation is skipped
after_validation
:set_username_errors
after_update
:username_changed_hook
,
if: :username_changed?
after_destroy
:post_destroy_hook
...
...
@@ -408,7 +411,6 @@ class User < ActiveRecord::Base
unique_internal
(
where
(
ghost:
true
),
'ghost'
,
email
)
do
|
u
|
u
.
bio
=
'This is a "Ghost User", created to hold all issues authored by users that have since been deleted. This user cannot be removed.'
u
.
name
=
'Ghost User'
u
.
notification_email
=
email
end
end
end
...
...
changelogs/unreleased/dm-internal-user-namespace.yml
0 → 100644
View file @
7de250fb
---
title
:
Ensure internal users (ghost, support bot) get assigned a namespace
merge_request
:
author
:
type
:
fixed
spec/models/user_spec.rb
View file @
7de250fb
...
...
@@ -2071,6 +2071,8 @@ describe User do
expect
(
ghost
).
to
be_ghost
expect
(
ghost
).
to
be_persisted
expect
(
ghost
.
namespace
).
not_to
be_nil
expect
(
ghost
.
namespace
).
to
be_persisted
end
it
"does not create a second ghost user if one is already present"
do
...
...
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