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
1c180843
Commit
1c180843
authored
Jun 17, 2021
by
charlie ablett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sync destruction between requirements and issues
Changelog: added EE: true
parent
3b143c7a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
ee/app/models/requirements_management/requirement.rb
ee/app/models/requirements_management/requirement.rb
+5
-1
ee/spec/models/requirements_management/requirement_spec.rb
ee/spec/models/requirements_management/requirement_spec.rb
+17
-0
No files found.
ee/app/models/requirements_management/requirement.rb
View file @
1c180843
...
...
@@ -20,7 +20,11 @@ module RequirementsManagement
belongs_to
:author
,
inverse_of: :requirements
,
class_name:
'User'
belongs_to
:project
,
inverse_of: :requirements
belongs_to
:requirement_issue
,
class_name:
'Issue'
,
foreign_key: :issue_id
# deleting an issue would result in deleting requirement record due to cascade delete via foreign key
# but to sync the other way around, we require a temporary `dependent: :destroy`
# See https://gitlab.com/gitlab-org/gitlab/-/issues/323779 for details.
# This will be removed in https://gitlab.com/gitlab-org/gitlab/-/issues/329432
belongs_to
:requirement_issue
,
class_name:
'Issue'
,
foreign_key: :issue_id
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
validates
:issue_id
,
uniqueness:
true
,
allow_nil:
true
...
...
ee/spec/models/requirements_management/requirement_spec.rb
View file @
1c180843
...
...
@@ -184,4 +184,21 @@ RSpec.describe RequirementsManagement::Requirement do
end
end
end
describe
'sync with requirement issues'
do
let_it_be_with_reload
(
:requirement
)
{
create
(
:requirement
)
}
let_it_be_with_reload
(
:requirement_issue
)
{
create
(
:requirement_issue
,
requirement:
requirement
)
}
context
'when destroying a requirement'
do
it
'also destroys the associated requirement issue'
do
expect
{
requirement
.
destroy!
}.
to
change
{
Issue
.
where
(
issue_type:
'requirement'
).
count
}.
by
(
-
1
)
end
end
context
'when destroying a requirement issue'
do
it
'also destroys the associated requirement'
do
expect
{
requirement_issue
.
destroy!
}.
to
change
{
RequirementsManagement
::
Requirement
.
count
}.
by
(
-
1
)
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