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
7b369727
Commit
7b369727
authored
Sep 30, 2020
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update blocking issues count on reopening
Refresh blocking issues count cache when reopening issue
parent
7dc38e15
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
0 deletions
+66
-0
app/services/issues/reopen_service.rb
app/services/issues/reopen_service.rb
+8
-0
ee/app/services/ee/issues/reopen_service.rb
ee/app/services/ee/issues/reopen_service.rb
+19
-0
ee/spec/services/ee/issues/reopen_service_spec.rb
ee/spec/services/ee/issues/reopen_service_spec.rb
+39
-0
No files found.
app/services/issues/reopen_service.rb
View file @
7b369727
...
...
@@ -5,6 +5,8 @@ module Issues
def
execute
(
issue
)
return
issue
unless
can?
(
current_user
,
:reopen_issue
,
issue
)
before_reopen
(
issue
)
if
issue
.
reopen
event_service
.
reopen_issue
(
issue
,
current_user
)
create_note
(
issue
,
'reopened'
)
...
...
@@ -21,8 +23,14 @@ module Issues
private
def
before_reopen
(
issue
)
# Overriden in EE
end
def
create_note
(
issue
,
state
=
issue
.
state
)
SystemNoteService
.
change_status
(
issue
,
issue
.
project
,
current_user
,
state
,
nil
)
end
end
end
Issues
::
ReopenService
.
prepend_if_ee
(
'EE::Issues::ReopenService'
)
ee/app/services/ee/issues/reopen_service.rb
0 → 100644
View file @
7b369727
# frozen_string_literal: true
module
EE
module
Issues
module
ReopenService
extend
::
Gitlab
::
Utils
::
Override
override
:before_reopen
def
before_reopen
(
issue
)
# Assign blocking_issues_count to issue object instead of performing an update,
# this way we can keep issue#previous_changes attributes consistent.
# Some services may use them to perform callbacks like StatusPage::TriggerPublishService
issue
.
blocking_issues_count
=
::
IssueLink
.
blocking_issues_count_for
(
issue
)
super
end
end
end
end
ee/spec/services/ee/issues/reopen_service_spec.rb
0 → 100644
View file @
7b369727
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Issues
::
ReopenService
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:issue
)
{
create
(
:issue
,
:closed
,
project:
project
)
}
let_it_be
(
:blocked_issue
)
{
create
(
:issue
,
project:
project
)
}
subject
{
described_class
.
new
(
project
,
user
).
execute
(
issue
)
}
before
do
create
(
:issue_link
,
source:
issue
,
target:
blocked_issue
,
link_type:
::
IssueLink
::
TYPE_BLOCKS
)
issue
.
update!
(
blocking_issues_count:
0
)
end
describe
'#execute'
do
context
'when user is not authorized to reopen issue'
do
before
do
project
.
add_guest
(
user
)
end
it
'does not update blocking issues count'
do
expect
{
subject
}.
not_to
change
{
issue
.
blocking_issues_count
}.
from
(
0
)
end
end
context
'when user is authorized to reopen issue'
do
before
do
project
.
add_maintainer
(
user
)
end
it
'updates blocking issues count'
do
expect
{
subject
}.
to
change
{
issue
.
blocking_issues_count
}.
from
(
0
).
to
(
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