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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
0698113c
Commit
0698113c
authored
May 18, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move #create_confidentiality_note to Issues::UpdateService
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
483c034b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
32 deletions
+19
-32
app/services/issuable_base_service.rb
app/services/issuable_base_service.rb
+0
-6
app/services/issues/update_service.rb
app/services/issues/update_service.rb
+7
-1
app/services/system_note_service.rb
app/services/system_note_service.rb
+7
-12
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+2
-2
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+3
-11
No files found.
app/services/issuable_base_service.rb
View file @
0698113c
...
@@ -36,12 +36,6 @@ class IssuableBaseService < BaseService
...
@@ -36,12 +36,6 @@ 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 @
0698113c
...
@@ -41,5 +41,11 @@ module Issues
...
@@ -41,5 +41,11 @@ module Issues
def
close_service
def
close_service
Issues
::
CloseService
Issues
::
CloseService
end
end
private
def
create_confidentiality_note
(
issue
)
SystemNoteService
.
change_issue_confidentiality
(
issue
,
issue
.
project
,
current_user
)
end
end
end
end
end
app/services/system_note_service.rb
View file @
0698113c
...
@@ -169,29 +169,24 @@ class SystemNoteService
...
@@ -169,29 +169,24 @@ class SystemNoteService
#
#
# Returns the created Note object
# Returns the created Note object
def
self
.
change_title
(
noteable
,
project
,
author
,
old_title
)
def
self
.
change_title
(
noteable
,
project
,
author
,
old_title
)
return
unless
noteable
.
respond_to?
(
:title
)
body
=
"Title changed from **
#{
old_title
}
** to **
#{
noteable
.
title
}
**"
body
=
"Title changed from **
#{
old_title
}
** to **
#{
noteable
.
title
}
**"
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
# Called when the confidentiality changes
#
#
#
noteable - Noteable object that responds to 'confidential'
#
issue - Issue object
# project
- Project owning noteabl
e
# project
- Project owning the issu
e
# author - User performing the change
# author - User performing the change
#
#
# Example Note text:
# Example Note text:
#
#
# "Ma
rked as
confidential"
# "Ma
de the issue
confidential"
#
#
# Returns the created Note object
# Returns the created Note object
def
self
.
change_confidentiality
(
noteable
,
project
,
author
)
def
self
.
change_issue_confidentiality
(
issue
,
project
,
author
)
return
unless
noteable
.
respond_to?
(
:confidential
)
body
=
issue
.
confidential
?
'Made the issue confidential'
:
'Made the issue visible'
create_note
(
noteable:
issue
,
project:
project
,
author:
author
,
note:
body
)
confidentiality_status
=
noteable
.
confidential
?
"confidential"
:
"not confidential"
body
=
"Marked as
#{
confidentiality_status
}
"
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
end
# Called when a branch in Noteable is changed
# Called when a branch in Noteable is changed
...
...
spec/services/issues/update_service_spec.rb
View file @
0698113c
...
@@ -82,10 +82,10 @@ describe Issues::UpdateService, services: true do
...
@@ -82,10 +82,10 @@ describe Issues::UpdateService, services: true do
end
end
it
'creates system note about confidentiality change'
do
it
'creates system note about confidentiality change'
do
note
=
find_note
(
'Ma
rked as
confidential'
)
note
=
find_note
(
'Ma
de the issue
confidential'
)
expect
(
note
).
not_to
be_nil
expect
(
note
).
not_to
be_nil
expect
(
note
.
note
).
to
eq
'Ma
rked as
confidential'
expect
(
note
.
note
).
to
eq
'Ma
de the issue
confidential'
end
end
end
end
...
...
spec/services/system_note_service_spec.rb
View file @
0698113c
...
@@ -244,24 +244,16 @@ describe SystemNoteService, services: true do
...
@@ -244,24 +244,16 @@ describe SystemNoteService, services: true do
to
eq
"Title changed from **Old title** to **
#{
noteable
.
title
}
**"
to
eq
"Title changed from **Old title** to **
#{
noteable
.
title
}
**"
end
end
end
end
context
'when noteable does not respond to `title'
do
let
(
:noteable
)
{
double
(
'noteable'
)
}
it
'returns nil'
do
expect
(
subject
).
to
be_nil
end
end
end
end
describe
'.change_confidentiality'
do
describe
'.change_
issue_
confidentiality'
do
subject
{
described_class
.
change_confidentiality
(
noteable
,
project
,
author
)
}
subject
{
described_class
.
change_
issue_
confidentiality
(
noteable
,
project
,
author
)
}
context
'when noteable responds to `confidential`'
do
context
'when noteable responds to `confidential`'
do
it_behaves_like
'a system note'
it_behaves_like
'a system note'
it
'sets the note text'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"Marked as not confidential"
expect
(
subject
.
note
).
to
eq
'Made the issue visible'
end
end
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