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
483c034b
Commit
483c034b
authored
Apr 20, 2016
by
Alex Moore-Niemi
Committed by
Rémy Coutable
May 18, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changing the confidentiality of an issue now creates a new system note
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
da8ac163
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
7 deletions
+57
-7
CHANGELOG
CHANGELOG
+1
-0
app/services/issuable_base_service.rb
app/services/issuable_base_service.rb
+6
-0
app/services/issues/update_service.rb
app/services/issues/update_service.rb
+5
-1
app/services/system_note_service.rb
app/services/system_note_service.rb
+19
-0
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+14
-6
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+12
-0
No files found.
CHANGELOG
View file @
483c034b
...
@@ -10,6 +10,7 @@ v 8.8.0 (unreleased)
...
@@ -10,6 +10,7 @@ v 8.8.0 (unreleased)
- Escape HTML in commit titles in system note messages
- Escape HTML in commit titles in system note messages
- Improve multiple branch push performance by memoizing permission checking
- Improve multiple branch push performance by memoizing permission checking
- Log to application.log when an admin starts and stops impersonating a user
- Log to application.log when an admin starts and stops impersonating a user
- Changing the confidentiality of an issue now creates a new system note (Alex Moore-Niemi)
- Updated gitlab_git to 10.1.0
- Updated gitlab_git to 10.1.0
- GitAccess#protected_tag? no longer loads all tags just to check if a single one exists
- GitAccess#protected_tag? no longer loads all tags just to check if a single one exists
- Reduce delay in destroying a project from 1-minute to immediately
- Reduce delay in destroying a project from 1-minute to immediately
...
...
app/services/issuable_base_service.rb
View file @
483c034b
...
@@ -36,6 +36,12 @@ class IssuableBaseService < BaseService
...
@@ -36,6 +36,12 @@ class IssuableBaseService < BaseService
end
end
end
end
def
create_confidentiality_note
(
issuable
)
SystemNoteService
.
change_confidentiality
(
issuable
,
issuable
.
project
,
current_user
)
end
def
filter_params
(
issuable_ability_name
=
:issue
)
def
filter_params
(
issuable_ability_name
=
:issue
)
filter_assignee
filter_assignee
filter_milestone
filter_milestone
...
...
app/services/issues/update_service.rb
View file @
483c034b
...
@@ -24,6 +24,10 @@ module Issues
...
@@ -24,6 +24,10 @@ module Issues
todo_service
.
reassigned_issue
(
issue
,
current_user
)
todo_service
.
reassigned_issue
(
issue
,
current_user
)
end
end
if
issue
.
previous_changes
.
include?
(
'confidential'
)
create_confidentiality_note
(
issue
)
end
added_labels
=
issue
.
labels
-
old_labels
added_labels
=
issue
.
labels
-
old_labels
if
added_labels
.
present?
if
added_labels
.
present?
notification_service
.
relabeled_issue
(
issue
,
added_labels
,
current_user
)
notification_service
.
relabeled_issue
(
issue
,
added_labels
,
current_user
)
...
...
app/services/system_note_service.rb
View file @
483c034b
...
@@ -175,6 +175,25 @@ class SystemNoteService
...
@@ -175,6 +175,25 @@ class SystemNoteService
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
end
# Called when the confidentiality changes
#
# noteable - Noteable object that responds to 'confidential'
# project - Project owning noteable
# author - User performing the change
#
# Example Note text:
#
# "Marked as confidential"
#
# Returns the created Note object
def
self
.
change_confidentiality
(
noteable
,
project
,
author
)
return
unless
noteable
.
respond_to?
(
:confidential
)
confidentiality_status
=
noteable
.
confidential
?
"confidential"
:
"not confidential"
body
=
"Marked as
#{
confidentiality_status
}
"
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
# Called when a branch in Noteable is changed
# Called when a branch in Noteable is changed
#
#
# noteable - Noteable object
# noteable - Noteable object
...
...
spec/services/issues/update_service_spec.rb
View file @
483c034b
...
@@ -27,11 +27,6 @@ describe Issues::UpdateService, services: true do
...
@@ -27,11 +27,6 @@ describe Issues::UpdateService, services: true do
end
end
end
end
def
update_issue
(
opts
)
@issue
=
Issues
::
UpdateService
.
new
(
project
,
user
,
opts
).
execute
(
issue
)
@issue
.
reload
end
context
"valid params"
do
context
"valid params"
do
before
do
before
do
opts
=
{
opts
=
{
...
@@ -39,7 +34,8 @@ describe Issues::UpdateService, services: true do
...
@@ -39,7 +34,8 @@ describe Issues::UpdateService, services: true do
description:
'Also please fix'
,
description:
'Also please fix'
,
assignee_id:
user2
.
id
,
assignee_id:
user2
.
id
,
state_event:
'close'
,
state_event:
'close'
,
label_ids:
[
label
.
id
]
label_ids:
[
label
.
id
],
confidential:
true
}
}
perform_enqueued_jobs
do
perform_enqueued_jobs
do
...
@@ -84,6 +80,18 @@ describe Issues::UpdateService, services: true do
...
@@ -84,6 +80,18 @@ describe Issues::UpdateService, services: true do
expect
(
note
).
not_to
be_nil
expect
(
note
).
not_to
be_nil
expect
(
note
.
note
).
to
eq
'Title changed from **Old title** to **New title**'
expect
(
note
.
note
).
to
eq
'Title changed from **Old title** to **New title**'
end
end
it
'creates system note about confidentiality change'
do
note
=
find_note
(
'Marked as confidential'
)
expect
(
note
).
not_to
be_nil
expect
(
note
.
note
).
to
eq
'Marked as confidential'
end
end
def
update_issue
(
opts
)
@issue
=
Issues
::
UpdateService
.
new
(
project
,
user
,
opts
).
execute
(
issue
)
@issue
.
reload
end
end
context
'todos'
do
context
'todos'
do
...
...
spec/services/system_note_service_spec.rb
View file @
483c034b
...
@@ -254,6 +254,18 @@ describe SystemNoteService, services: true do
...
@@ -254,6 +254,18 @@ describe SystemNoteService, services: true do
end
end
end
end
describe
'.change_confidentiality'
do
subject
{
described_class
.
change_confidentiality
(
noteable
,
project
,
author
)
}
context
'when noteable responds to `confidential`'
do
it_behaves_like
'a system note'
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"Marked as not confidential"
end
end
end
describe
'.change_branch'
do
describe
'.change_branch'
do
subject
{
described_class
.
change_branch
(
noteable
,
project
,
author
,
'target'
,
old_branch
,
new_branch
)
}
subject
{
described_class
.
change_branch
(
noteable
,
project
,
author
,
'target'
,
old_branch
,
new_branch
)
}
let
(
:old_branch
)
{
'old_branch'
}
let
(
:old_branch
)
{
'old_branch'
}
...
...
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