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
eda2229f
Commit
eda2229f
authored
Nov 20, 2019
by
Jan Beckmann
Committed by
Mayra Cabrera
Nov 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add relationship and link to new epic to promoted issues
Closes #9898
parent
610d9235
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
145 additions
and
1 deletion
+145
-1
app/helpers/issues_helper.rb
app/helpers/issues_helper.rb
+1
-1
db/migrate/20191026120008_add_promoted_to_epic_to_issues.rb
db/migrate/20191026120008_add_promoted_to_epic_to_issues.rb
+16
-0
db/migrate/20191026120112_add_promoted_to_epic_to_issues_index.rb
...te/20191026120112_add_promoted_to_epic_to_issues_index.rb
+22
-0
db/schema.rb
db/schema.rb
+3
-0
ee/app/helpers/ee/issues_helper.rb
ee/app/helpers/ee/issues_helper.rb
+11
-0
ee/app/models/ee/issue.rb
ee/app/models/ee/issue.rb
+5
-0
ee/app/services/epics/issue_promote_service.rb
ee/app/services/epics/issue_promote_service.rb
+10
-0
ee/changelogs/unreleased/9898-issue-epic-indication.yml
ee/changelogs/unreleased/9898-issue-epic-indication.yml
+5
-0
ee/spec/helpers/ee/issues_helper_spec.rb
ee/spec/helpers/ee/issues_helper_spec.rb
+45
-0
ee/spec/models/issue_spec.rb
ee/spec/models/issue_spec.rb
+17
-0
ee/spec/services/epics/issue_promote_service_spec.rb
ee/spec/services/epics/issue_promote_service_spec.rb
+5
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+1
-0
spec/lib/gitlab/import_export/safe_model_attributes.yml
spec/lib/gitlab/import_export/safe_model_attributes.yml
+1
-0
No files found.
app/helpers/issues_helper.rb
View file @
eda2229f
...
...
@@ -183,4 +183,4 @@ module IssuesHelper
module_function
:url_for_tracker_issue
end
IssuesHelper
.
include
_if_ee
(
'EE::IssuesHelper'
)
IssuesHelper
.
prepend
_if_ee
(
'EE::IssuesHelper'
)
db/migrate/20191026120008_add_promoted_to_epic_to_issues.rb
0 → 100644
View file @
eda2229f
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
AddPromotedToEpicToIssues
<
ActiveRecord
::
Migration
[
5.2
]
DOWNTIME
=
false
def
up
add_column
:issues
,
:promoted_to_epic_id
,
:integer
end
def
down
remove_column
:issues
,
:promoted_to_epic_id
end
end
db/migrate/20191026120112_add_promoted_to_epic_to_issues_index.rb
0 → 100644
View file @
eda2229f
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
AddPromotedToEpicToIssuesIndex
<
ActiveRecord
::
Migration
[
5.2
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_concurrent_foreign_key
:issues
,
:epics
,
column: :promoted_to_epic_id
,
on_delete: :nullify
add_concurrent_index
:issues
,
:promoted_to_epic_id
,
where:
'promoted_to_epic_id IS NOT NULL'
end
def
down
remove_concurrent_index
(
:issues
,
:promoted_to_epic_id
)
remove_foreign_key
:issues
,
column: :promoted_to_epic_id
end
end
db/schema.rb
View file @
eda2229f
...
...
@@ -2049,6 +2049,7 @@ ActiveRecord::Schema.define(version: 2019_11_18_182722) do
t
.
integer
"closed_by_id"
t
.
integer
"state_id"
,
limit:
2
,
default:
1
,
null:
false
t
.
integer
"duplicated_to_id"
t
.
integer
"promoted_to_epic_id"
t
.
index
[
"author_id"
],
name:
"index_issues_on_author_id"
t
.
index
[
"closed_by_id"
],
name:
"index_issues_on_closed_by_id"
t
.
index
[
"confidential"
],
name:
"index_issues_on_confidential"
...
...
@@ -2065,6 +2066,7 @@ ActiveRecord::Schema.define(version: 2019_11_18_182722) do
t
.
index
[
"project_id"
,
"relative_position"
,
"state_id"
,
"id"
],
name:
"idx_issues_on_project_id_and_rel_position_and_state_id_and_id"
,
order:
{
id: :desc
}
t
.
index
[
"project_id"
,
"updated_at"
,
"id"
,
"state"
],
name:
"index_issues_on_project_id_and_updated_at_and_id_and_state"
t
.
index
[
"project_id"
,
"updated_at"
,
"id"
,
"state_id"
],
name:
"idx_issues_on_project_id_and_updated_at_and_id_and_state_id"
t
.
index
[
"promoted_to_epic_id"
],
name:
"index_issues_on_promoted_to_epic_id"
,
where:
"(promoted_to_epic_id IS NOT NULL)"
t
.
index
[
"relative_position"
],
name:
"index_issues_on_relative_position"
t
.
index
[
"state"
],
name:
"index_issues_on_state"
t
.
index
[
"state_id"
],
name:
"idx_issues_on_state_id"
...
...
@@ -4428,6 +4430,7 @@ ActiveRecord::Schema.define(version: 2019_11_18_182722) do
add_foreign_key
"issue_tracker_data"
,
"services"
,
on_delete: :cascade
add_foreign_key
"issue_user_mentions"
,
"issues"
,
on_delete: :cascade
add_foreign_key
"issue_user_mentions"
,
"notes"
,
on_delete: :cascade
add_foreign_key
"issues"
,
"epics"
,
column:
"promoted_to_epic_id"
,
name:
"fk_df75a7c8b8"
,
on_delete: :nullify
add_foreign_key
"issues"
,
"issues"
,
column:
"duplicated_to_id"
,
name:
"fk_9c4516d665"
,
on_delete: :nullify
add_foreign_key
"issues"
,
"issues"
,
column:
"moved_to_id"
,
name:
"fk_a194299be1"
,
on_delete: :nullify
add_foreign_key
"issues"
,
"milestones"
,
name:
"fk_96b1dd429c"
,
on_delete: :nullify
...
...
ee/app/helpers/ee/issues_helper.rb
View file @
eda2229f
...
...
@@ -2,6 +2,8 @@
module
EE
module
IssuesHelper
extend
::
Gitlab
::
Utils
::
Override
def
weight_dropdown_tag
(
issuable
,
opts
=
{},
&
block
)
title
=
issuable
.
weight
||
'Weight'
additional_toggle_class
=
opts
.
delete
(
:toggle_class
)
...
...
@@ -28,5 +30,14 @@ module EE
h
(
weight
.
presence
||
'Weight'
)
end
end
override
:issue_closed_link
def
issue_closed_link
(
issue
,
current_user
,
css_class:
''
)
if
issue
.
promoted?
&&
can?
(
current_user
,
:read_epic
,
issue
.
promoted_to_epic
)
link_to
(
s_
(
'IssuableStatus|promoted'
),
issue
.
promoted_to_epic
,
class:
css_class
)
else
super
end
end
end
end
ee/app/models/ee/issue.rb
View file @
eda2229f
...
...
@@ -26,6 +26,7 @@ module EE
has_one
:epic_issue
has_one
:epic
,
through: :epic_issue
belongs_to
:promoted_to_epic
,
class_name:
'Epic'
has_many
:designs
,
class_name:
"DesignManagement::Design"
,
inverse_of: :issue
has_many
:design_versions
,
class_name:
"DesignManagement::Version"
,
inverse_of: :issue
do
def
most_recent
...
...
@@ -124,6 +125,10 @@ module EE
@design_collection
||=
::
DesignManagement
::
DesignCollection
.
new
(
self
)
end
def
promoted?
!!
promoted_to_epic_id
end
class_methods
do
# override
def
sort_by_attribute
(
method
,
excluded_labels:
[])
...
...
ee/app/services/epics/issue_promote_service.rb
View file @
eda2229f
...
...
@@ -33,6 +33,16 @@ module Epics
@new_entity
=
Epics
::
CreateService
.
new
(
@group
,
current_user
,
params
).
execute
end
def
update_old_entity
super
mark_as_promoted
end
def
mark_as_promoted
original_entity
.
update
(
promoted_to_epic:
new_entity
)
end
def
params
{
title:
original_entity
.
title
...
...
ee/changelogs/unreleased/9898-issue-epic-indication.yml
0 → 100644
View file @
eda2229f
---
title
:
Add link to new epic for promoted issues
merge_request
:
18839
author
:
Jan Beckmann
type
:
added
ee/spec/helpers/ee/issues_helper_spec.rb
0 → 100644
View file @
eda2229f
# frozen_string_literal: true
require
"spec_helper"
describe
IssuesHelper
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:issue
)
{
create
:issue
,
project:
project
}
describe
'#issue_closed_link'
do
let
(
:new_epic
)
{
create
(
:epic
)
}
let
(
:user
)
{
create
(
:user
)
}
context
'with linked issue'
do
context
'with promoted issue'
do
before
do
issue
.
update
(
promoted_to_epic:
new_epic
)
end
context
'when user has permission to see new epic'
do
before
do
expect
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:read_epic
,
new_epic
)
{
true
}
end
let
(
:css_class
)
{
'text-white text-underline'
}
it
'returns link'
do
link
=
"<a class=
\"
#{
css_class
}
\"
href=
\"
/groups/
#{
new_epic
.
group
.
full_path
}
/-/epics/
#{
new_epic
.
iid
}
\"
>(promoted)</a>"
expect
(
helper
.
issue_closed_link
(
issue
,
user
,
css_class:
css_class
)).
to
match
(
link
)
end
end
context
'when user has no permission to see new epic'
do
before
do
expect
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:read_epic
,
new_epic
)
{
false
}
end
it
'returns nil'
do
expect
(
helper
.
issue_closed_link
(
issue
,
user
)).
to
be_nil
end
end
end
end
end
end
ee/spec/models/issue_spec.rb
View file @
eda2229f
...
...
@@ -115,6 +115,7 @@ describe Issue do
it
{
is_expected
.
to
have_many
(
:prometheus_alerts
)
}
it
{
is_expected
.
to
have_many
(
:vulnerability_links
).
class_name
(
'Vulnerabilities::IssueLink'
).
inverse_of
(
:issue
)
}
it
{
is_expected
.
to
have_many
(
:related_vulnerabilities
).
through
(
:vulnerability_links
).
source
(
:vulnerability
)
}
it
{
is_expected
.
to
belong_to
(
:promoted_to_epic
).
class_name
(
'Epic'
)
}
describe
'versions.most_recent'
do
it
'returns the most recent version'
do
...
...
@@ -256,6 +257,22 @@ describe Issue do
end
end
describe
'#promoted?'
do
let
(
:issue
)
{
create
(
:issue
)
}
subject
{
issue
.
promoted?
}
context
'issue not promoted'
do
it
{
is_expected
.
to
be_falsey
}
end
context
'issue promoted'
do
let
(
:promoted_to_epic
)
{
create
(
:epic
)
}
let
(
:issue
)
{
create
(
:issue
,
promoted_to_epic:
promoted_to_epic
)
}
it
{
is_expected
.
to
be_truthy
}
end
end
describe
'relative positioning with group boards'
do
let
(
:group
)
{
create
(
:group
)
}
let!
(
:board
)
{
create
(
:board
,
group:
group
)
}
...
...
ee/spec/services/epics/issue_promote_service_spec.rb
View file @
eda2229f
...
...
@@ -83,6 +83,11 @@ describe Epics::IssuePromoteService do
it
'closes the original issue'
do
expect
(
issue
).
to
be_closed
end
it
'marks the old issue as promoted'
do
expect
(
issue
).
to
be_promoted
expect
(
issue
.
promoted_to_epic
).
to
eq
(
epic
)
end
end
context
'when promoted issue has notes'
do
...
...
locale/gitlab.pot
View file @
eda2229f
...
...
@@ -9565,6 +9565,9 @@ msgstr ""
msgid "IssuableStatus|moved"
msgstr ""
msgid "IssuableStatus|promoted"
msgstr ""
msgid "Issue"
msgstr ""
...
...
spec/lib/gitlab/import_export/all_models.yml
View file @
eda2229f
...
...
@@ -15,6 +15,7 @@ issues:
-
user_agent_detail
-
moved_to
-
duplicated_to
-
promoted_to_epic
-
events
-
merge_requests_closing_issues
-
metrics
...
...
spec/lib/gitlab/import_export/safe_model_attributes.yml
View file @
eda2229f
...
...
@@ -20,6 +20,7 @@ Issue:
-
due_date
-
moved_to_id
-
duplicated_to_id
-
promoted_to_epic_id
-
lock_version
-
milestone_id
-
weight
...
...
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