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
5eb48e2e
Commit
5eb48e2e
authored
Apr 13, 2021
by
John Hope
Committed by
Tiger Watson
Apr 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix notification when new Service Desk Issue is created
parent
ca02d83c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
122 additions
and
0 deletions
+122
-0
app/models/user.rb
app/models/user.rb
+1
-0
changelogs/unreleased/confirm_support_bot.yml
changelogs/unreleased/confirm_support_bot.yml
+5
-0
db/post_migrate/20210407150240_confirm_support_bot_user.rb
db/post_migrate/20210407150240_confirm_support_bot_user.rb
+23
-0
db/schema_migrations/20210407150240
db/schema_migrations/20210407150240
+1
-0
spec/migrations/confirm_support_bot_user_spec.rb
spec/migrations/confirm_support_bot_user_spec.rb
+86
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+6
-0
No files found.
app/models/user.rb
View file @
5eb48e2e
...
@@ -764,6 +764,7 @@ class User < ApplicationRecord
...
@@ -764,6 +764,7 @@ class User < ApplicationRecord
u
.
bio
=
'The GitLab support bot used for Service Desk'
u
.
bio
=
'The GitLab support bot used for Service Desk'
u
.
name
=
'GitLab Support Bot'
u
.
name
=
'GitLab Support Bot'
u
.
avatar
=
bot_avatar
(
image:
'support-bot.png'
)
u
.
avatar
=
bot_avatar
(
image:
'support-bot.png'
)
u
.
confirmed_at
=
Time
.
zone
.
now
end
end
end
end
...
...
changelogs/unreleased/confirm_support_bot.yml
0 → 100644
View file @
5eb48e2e
---
title
:
Fix notification when new Service Desk Issue is created
merge_request
:
58803
author
:
type
:
fixed
db/post_migrate/20210407150240_confirm_support_bot_user.rb
0 → 100644
View file @
5eb48e2e
# frozen_string_literal: true
class
ConfirmSupportBotUser
<
ActiveRecord
::
Migration
[
6.0
]
SUPPORT_BOT_TYPE
=
1
def
up
users
=
Arel
::
Table
.
new
(
:users
)
um
=
Arel
::
UpdateManager
.
new
um
.
table
(
users
)
.
where
(
users
[
:user_type
].
eq
(
SUPPORT_BOT_TYPE
))
.
where
(
users
[
:confirmed_at
].
eq
(
nil
))
.
set
([[
users
[
:confirmed_at
],
Arel
::
Nodes
::
NamedFunction
.
new
(
'COALESCE'
,
[
users
[
:created_at
],
Arel
::
Nodes
::
SqlLiteral
.
new
(
'NOW()'
)])]])
connection
.
execute
(
um
.
to_sql
)
end
def
down
# no op
# The up migration allows for the possibility that the support user might
# have already been manually confirmed. It's not reversible as this data is
# subsequently lost.
end
end
db/schema_migrations/20210407150240
0 → 100644
View file @
5eb48e2e
b5f83e3870dc7c70fbde6071725aa2acb3e99f7c2ed050633c34ed35e696ba1e
\ No newline at end of file
spec/migrations/confirm_support_bot_user_spec.rb
0 → 100644
View file @
5eb48e2e
# frozen_string_literal: true
require
'spec_helper'
require_migration!
RSpec
.
describe
ConfirmSupportBotUser
,
:migration
do
let
(
:users
)
{
table
(
:users
)
}
context
'when support bot user is currently unconfirmed'
do
let!
(
:support_bot
)
do
create_user!
(
created_at:
2
.
days
.
ago
,
user_type:
User
::
USER_TYPES
[
'support_bot'
]
)
end
it
'updates the `confirmed_at` attribute'
do
expect
{
migrate!
}.
to
change
{
support_bot
.
reload
.
confirmed_at
}
end
it
'sets `confirmed_at` to be the same as their `created_at` attribute'
do
migrate!
expect
(
support_bot
.
reload
.
confirmed_at
).
to
eq
(
support_bot
.
created_at
)
end
end
context
'when support bot user is already confirmed'
do
let!
(
:confirmed_support_bot
)
do
create_user!
(
user_type:
User
::
USER_TYPES
[
'support_bot'
],
confirmed_at:
1
.
day
.
ago
)
end
it
'does not change their `confirmed_at` attribute'
do
expect
{
migrate!
}.
not_to
change
{
confirmed_support_bot
.
reload
.
confirmed_at
}
end
end
context
'when support bot user created_at is null'
do
let!
(
:support_bot
)
do
create_user!
(
user_type:
User
::
USER_TYPES
[
'support_bot'
],
confirmed_at:
nil
,
record_timestamps:
false
)
end
it
'updates the `confirmed_at` attribute'
do
expect
{
migrate!
}.
to
change
{
support_bot
.
reload
.
confirmed_at
}.
from
(
nil
)
end
it
'does not change the `created_at` attribute'
do
expect
{
migrate!
}.
not_to
change
{
support_bot
.
reload
.
created_at
}.
from
(
nil
)
end
end
context
'with human users that are currently unconfirmed'
do
let!
(
:unconfirmed_human
)
do
create_user!
(
name:
'human'
,
email:
'human@example.com'
,
user_type:
nil
)
end
it
'does not update their `confirmed_at` attribute'
do
expect
{
migrate!
}.
not_to
change
{
unconfirmed_human
.
reload
.
confirmed_at
}
end
end
private
def
create_user!
(
name:
'GitLab Support Bot'
,
email:
'support@example.com'
,
user_type
:,
created_at:
Time
.
now
,
confirmed_at:
nil
,
record_timestamps:
true
)
users
.
create!
(
name:
name
,
email:
email
,
username:
name
,
projects_limit:
0
,
user_type:
user_type
,
confirmed_at:
confirmed_at
,
record_timestamps:
record_timestamps
)
end
end
spec/models/user_spec.rb
View file @
5eb48e2e
...
@@ -5508,6 +5508,12 @@ RSpec.describe User do
...
@@ -5508,6 +5508,12 @@ RSpec.describe User do
it_behaves_like
'bot user avatars'
,
:alert_bot
,
'alert-bot.png'
it_behaves_like
'bot user avatars'
,
:alert_bot
,
'alert-bot.png'
it_behaves_like
'bot user avatars'
,
:support_bot
,
'support-bot.png'
it_behaves_like
'bot user avatars'
,
:support_bot
,
'support-bot.png'
it_behaves_like
'bot user avatars'
,
:security_bot
,
'security-bot.png'
it_behaves_like
'bot user avatars'
,
:security_bot
,
'security-bot.png'
context
'when bot is the support_bot'
do
subject
{
described_class
.
support_bot
}
it
{
is_expected
.
to
be_confirmed
}
end
end
end
describe
'#confirmation_required_on_sign_in?'
do
describe
'#confirmation_required_on_sign_in?'
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