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
3e190323
Commit
3e190323
authored
Aug 05, 2021
by
Tetiana Chupryna
Committed by
Doug Stull
Aug 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Security bot confirmed
parent
0842aff3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
0 deletions
+57
-0
db/migrate/20210729123101_confirm_security_bot.rb
db/migrate/20210729123101_confirm_security_bot.rb
+18
-0
db/schema_migrations/20210729123101
db/schema_migrations/20210729123101
+1
-0
spec/migrations/confirm_security_bot_spec.rb
spec/migrations/confirm_security_bot_spec.rb
+38
-0
No files found.
db/migrate/20210729123101_confirm_security_bot.rb
0 → 100644
View file @
3e190323
# frozen_string_literal: true
class
ConfirmSecurityBot
<
ActiveRecord
::
Migration
[
6.0
]
class
User
<
ActiveRecord
::
Base
self
.
table_name
=
'users'
SECURITY_BOT_TYPE
=
8
end
def
up
User
.
where
(
user_type:
User
::
SECURITY_BOT_TYPE
,
confirmed_at:
nil
)
.
update_all
(
confirmed_at:
Time
.
current
)
end
# no-op
# Security Bot should be always confirmed
def
down
end
end
db/schema_migrations/20210729123101
0 → 100644
View file @
3e190323
8522eaf951d87de04aea82fe8e1a9577e6665c8d08245282239476e49b02bc7d
\ No newline at end of file
spec/migrations/confirm_security_bot_spec.rb
0 → 100644
View file @
3e190323
# frozen_string_literal: true
require
'spec_helper'
require_migration!
RSpec
.
describe
ConfirmSecurityBot
,
:migration
do
let
(
:users
)
{
table
(
:users
)
}
let
(
:user_type
)
{
8
}
context
'when bot is not created'
do
it
'skips migration'
do
migrate!
bot
=
users
.
find_by
(
user_type:
user_type
)
expect
(
bot
).
to
be_nil
end
end
context
'when bot is confirmed'
do
let
(
:bot
)
{
table
(
:users
).
create!
(
user_type:
user_type
,
confirmed_at:
Time
.
current
,
projects_limit:
1
)
}
it
'skips migration'
do
expect
{
migrate!
}.
not_to
change
{
bot
.
reload
.
confirmed_at
}
end
end
context
'when bot is not confirmed'
do
let
(
:bot
)
{
table
(
:users
).
create!
(
user_type:
user_type
,
projects_limit:
1
)
}
it
'update confirmed_at'
do
freeze_time
do
expect
{
migrate!
}.
to
change
{
bot
.
reload
.
confirmed_at
}.
from
(
nil
).
to
(
Time
.
current
)
end
end
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