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
baf65910
Commit
baf65910
authored
Aug 11, 2020
by
Philip Cunningham
Committed by
Patrick Bajao
Aug 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up DastSite on DastSiteProfile destroy
parent
313d4d0f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
ee/app/models/dast_site_profile.rb
ee/app/models/dast_site_profile.rb
+6
-0
ee/spec/models/dast_site_profile_spec.rb
ee/spec/models/dast_site_profile_spec.rb
+20
-0
No files found.
ee/app/models/dast_site_profile.rb
View file @
baf65910
...
@@ -10,8 +10,14 @@ class DastSiteProfile < ApplicationRecord
...
@@ -10,8 +10,14 @@ class DastSiteProfile < ApplicationRecord
scope
:with_dast_site
,
->
{
includes
(
:dast_site
)
}
scope
:with_dast_site
,
->
{
includes
(
:dast_site
)
}
after_destroy
:cleanup_dast_site
private
private
def
cleanup_dast_site
dast_site
.
destroy
if
dast_site
.
dast_site_profiles
.
empty?
end
def
dast_site_project_id_fk
def
dast_site_project_id_fk
unless
project_id
==
dast_site
&
.
project_id
unless
project_id
==
dast_site
&
.
project_id
errors
.
add
(
:project_id
,
'does not match dast_site.project'
)
errors
.
add
(
:project_id
,
'does not match dast_site.project'
)
...
...
ee/spec/models/dast_site_profile_spec.rb
View file @
baf65910
...
@@ -43,4 +43,24 @@ RSpec.describe DastSiteProfile, type: :model do
...
@@ -43,4 +43,24 @@ RSpec.describe DastSiteProfile, type: :model do
end
end
end
end
end
end
describe
'#destroy!'
do
context
'when the associated dast_site has no dast_site_profiles'
do
it
'is also destroyed'
do
subject
.
destroy!
expect
{
subject
.
dast_site
.
reload
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
end
context
'when the associated dast_site has dast_site_profiles'
do
it
'is not destroyed'
do
create
(
:dast_site_profile
,
dast_site:
subject
.
dast_site
,
project:
subject
.
project
)
subject
.
destroy!
expect
{
subject
.
dast_site
.
reload
}.
not_to
raise_error
end
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