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
96482cac
Commit
96482cac
authored
Sep 29, 2021
by
Philip Cunningham
Committed by
Robert Speicher
Sep 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up DAST site tokens when site deleted
parent
fe8576d0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
ee/app/models/dast_site.rb
ee/app/models/dast_site.rb
+6
-0
ee/spec/models/dast_site_spec.rb
ee/spec/models/dast_site_spec.rb
+12
-0
No files found.
ee/app/models/dast_site.rb
View file @
96482cac
...
...
@@ -11,8 +11,14 @@ class DastSite < ApplicationRecord
validates
:project_id
,
presence:
true
validate
:dast_site_validation_project_id_fk
after_destroy
:cleanup_dast_site_token
private
def
cleanup_dast_site_token
DastSiteToken
.
where
(
project_id:
project
.
id
,
url:
url
).
delete_all
end
def
dast_site_validation_project_id_fk
return
unless
dast_site_validation_id
...
...
ee/spec/models/dast_site_spec.rb
View file @
96482cac
...
...
@@ -44,4 +44,16 @@ RSpec.describe DastSite, type: :model do
end
end
end
describe
'callbacks'
do
context
'when there is a related site token'
do
let_it_be
(
:dast_site
)
{
create
(
:dast_site
,
project:
project
)
}
let_it_be
(
:dast_site_token
)
{
create
(
:dast_site_token
,
project:
dast_site
.
project
,
url:
dast_site
.
url
)
}
let_it_be
(
:dast_site_validations
)
{
create_list
(
:dast_site_validation
,
5
,
dast_site_token:
dast_site_token
)
}
it
'ensures it and associated site validations cleaned up on destroy'
do
expect
{
dast_site
.
destroy!
}.
to
change
{
DastSiteToken
.
count
}.
from
(
1
).
to
(
0
).
and
change
{
DastSiteValidation
.
count
}.
from
(
5
).
to
(
0
)
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