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
d4ec5c8c
Commit
d4ec5c8c
authored
Jun 23, 2020
by
Sean Arnold
Committed by
Peter Leitzen
Jun 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor to name as user_actions
- Add back mark for publication - Add back error message
parent
038953d2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
11 deletions
+42
-11
ee/app/services/status_page/trigger_publish_service.rb
ee/app/services/status_page/trigger_publish_service.rb
+21
-3
ee/lib/ee/gitlab/quick_actions/issue_actions.rb
ee/lib/ee/gitlab/quick_actions/issue_actions.rb
+1
-4
ee/lib/status_page.rb
ee/lib/status_page.rb
+2
-2
ee/spec/lib/status_page_spec.rb
ee/spec/lib/status_page_spec.rb
+1
-1
ee/spec/services/status_page/trigger_publish_service_spec.rb
ee/spec/services/status_page/trigger_publish_service_spec.rb
+17
-1
No files found.
ee/app/services/status_page/trigger_publish_service.rb
View file @
d4ec5c8c
...
...
@@ -17,10 +17,13 @@ module StatusPage
PUBLISH_WHEN_ISSUE_CHANGED
=
%w[title description confidential state_id closed_by_id]
.
freeze
def
initialize
(
project
,
user
,
triggered_by
)
VALID_ACTIONS
=
%i[init update]
.
freeze
def
initialize
(
project
,
user
,
triggered_by
,
action
:)
@project
=
project
@user
=
user
@triggered_by
=
triggered_by
@action
=
set_action
(
action
)
end
def
execute
...
...
@@ -33,7 +36,21 @@ module StatusPage
private
attr_reader
:user
,
:project
,
:triggered_by
attr_reader
:user
,
:project
,
:triggered_by
,
:action
def
set_action
(
action
)
raise
ArgumentError
,
'Invalid action'
unless
VALID_ACTIONS
.
include?
(
action
)
action
end
def
update?
action
==
:update
end
def
init?
action
==
:init
end
def
can_publish?
user
&
.
can?
(
:publish_status_page
,
project
)
...
...
@@ -59,13 +76,14 @@ module StatusPage
# Trigger publish for public (non-confidential) issues
# - which were changed
# - which were not changed, and the action is not update (i.e init action)
# - just become confidential to unpublish
def
eligable_issue_id_from_issue
issue
=
triggered_by
changes
=
issue
.
previous_changes
.
keys
&
PUBLISH_WHEN_ISSUE_CHANGED
return
if
changes
.
none?
return
if
update?
&&
changes
.
none?
return
if
issue
.
confidential?
&&
changes
.
exclude?
(
'confidential'
)
return
unless
issue
.
status_page_published_incident
...
...
ee/lib/ee/gitlab/quick_actions/issue_actions.rb
View file @
d4ec5c8c
...
...
@@ -143,10 +143,7 @@ module EE
end
command
:publish
do
if
StatusPage
.
mark_for_publication
(
project
,
current_user
,
quick_action_target
).
success?
# Ideally, we want to use `StatusPage.trigger_publish` instead of dispatching a worker.
# See https://gitlab.com/gitlab-org/gitlab/-/issues/219266
StatusPage
::
PublishWorker
.
perform_async
(
current_user
.
id
,
project
.
id
,
quick_action_target
.
id
)
StatusPage
.
trigger_publish
(
project
,
current_user
,
quick_action_target
,
action: :init
)
@execution_message
[
:publish
]
=
_
(
'Issue published on status page.'
)
else
@execution_message
[
:publish
]
=
_
(
'Failed to publish issue on status page.'
)
...
...
ee/lib/status_page.rb
View file @
d4ec5c8c
...
...
@@ -7,8 +7,8 @@ module StatusPage
AWARD_EMOJI
=
'microphone'
# Convenient method to trigger a status page update.
def
self
.
trigger_publish
(
project
,
user
,
triggered_by
)
TriggerPublishService
.
new
(
project
,
user
,
triggered_by
).
execute
def
self
.
trigger_publish
(
project
,
user
,
triggered_by
,
action: :update
)
TriggerPublishService
.
new
(
project
,
user
,
triggered_by
,
action:
action
).
execute
end
# Method to mark an issue as published and trigger update
...
...
ee/spec/lib/status_page_spec.rb
View file @
d4ec5c8c
...
...
@@ -12,7 +12,7 @@ RSpec.describe StatusPage do
it
'delegates to TriggerPublishService'
do
expect_next_instance_of
(
StatusPage
::
TriggerPublishService
,
project
,
user
,
triggered_by
)
do
|
service
|
project
,
user
,
triggered_by
,
action: :update
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
)
end
...
...
ee/spec/services/status_page/trigger_publish_service_spec.rb
View file @
d4ec5c8c
...
...
@@ -6,7 +6,7 @@ RSpec.describe StatusPage::TriggerPublishService do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project
,
refind:
true
)
{
create
(
:project
,
:repository
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
triggered_by
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
triggered_by
,
action: :update
)
}
describe
'#execute'
do
# Variables used by shared examples
...
...
@@ -18,6 +18,16 @@ RSpec.describe StatusPage::TriggerPublishService do
subject
{
service
.
execute
}
describe
'invalid action'
do
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
double
(
:issue
),
action: :something_invalid
)
}
it
'raises an argument error and does not process'
do
expect
(
StatusPage
::
PublishWorker
).
not_to
receive
(
:perform_async
)
expect
{
subject
}.
to
raise_error
(
ArgumentError
)
end
end
describe
'triggered by issue'
do
let_it_be
(
:triggered_by
,
reload:
true
)
{
create
(
:issue
,
:published
,
project:
project
)
}
let
(
:issue_id
)
{
triggered_by
.
id
}
...
...
@@ -41,6 +51,12 @@ RSpec.describe StatusPage::TriggerPublishService do
context
'without changes'
do
include_examples
'no trigger status page publish'
context
'with init action'
do
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
triggered_by
,
action: :init
)
}
include_examples
'trigger status page publish'
end
end
context
'when a confidential issue changes'
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