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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
9b93f8ad
Commit
9b93f8ad
authored
Mar 23, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Destroy related todos when an issue is deleted
parent
07e1ec5d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
1 deletion
+20
-1
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+1
-0
db/migrate/20160324020319_remove_todos_for_deleted_issues.rb
db/migrate/20160324020319_remove_todos_for_deleted_issues.rb
+17
-0
db/schema.rb
db/schema.rb
+1
-1
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+1
-0
No files found.
app/models/concerns/issuable.rb
View file @
9b93f8ad
...
...
@@ -19,6 +19,7 @@ module Issuable
has_many
:notes
,
as: :noteable
,
dependent: :destroy
has_many
:label_links
,
as: :target
,
dependent: :destroy
has_many
:labels
,
through: :label_links
has_many
:todos
,
as: :target
,
dependent: :destroy
validates
:author
,
presence:
true
validates
:title
,
presence:
true
,
length:
{
within:
0
..
255
}
...
...
db/migrate/20160324020319_remove_todos_for_deleted_issues.rb
0 → 100644
View file @
9b93f8ad
class
RemoveTodosForDeletedIssues
<
ActiveRecord
::
Migration
def
up
execute
<<-
SQL
DELETE FROM todos
WHERE todos.target_type = 'Issue'
AND NOT EXISTS (
SELECT *
FROM issues
WHERE issues.id = todos.target_id
AND issues.deleted_at IS NULL
)
SQL
end
def
down
end
end
db/schema.rb
View file @
9b93f8ad
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2016032
0204112
)
do
ActiveRecord
::
Schema
.
define
(
version:
2016032
4020319
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
spec/models/concerns/issuable_spec.rb
View file @
9b93f8ad
...
...
@@ -9,6 +9,7 @@ describe Issue, "Issuable" do
it
{
is_expected
.
to
belong_to
(
:author
)
}
it
{
is_expected
.
to
belong_to
(
:assignee
)
}
it
{
is_expected
.
to
have_many
(
:notes
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:todos
).
dependent
(
:destroy
)
}
end
describe
"Validation"
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