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
d67d43d1
Commit
d67d43d1
authored
Apr 04, 2017
by
Jarka Kadlecova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split status and confidentiality action
parent
b57ed57f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
17 deletions
+36
-17
app/models/system_note_metadata.rb
app/models/system_note_metadata.rb
+2
-2
app/services/system_note_service.rb
app/services/system_note_service.rb
+11
-3
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+23
-12
No files found.
app/models/system_note_metadata.rb
View file @
d67d43d1
class
SystemNoteMetadata
<
ActiveRecord
::
Base
class
SystemNoteMetadata
<
ActiveRecord
::
Base
ICON_TYPES
=
%w[
ICON_TYPES
=
%w[
commit merge confidential
ity status
label assignee cross_reference
commit merge confidential
visible
label assignee cross_reference
title time_tracking branch milestone discussion task moved
title time_tracking branch milestone discussion task moved
opened closed merged
]
.
freeze
]
.
freeze
validates
:note
,
presence:
true
validates
:note
,
presence:
true
...
...
app/services/system_note_service.rb
View file @
d67d43d1
...
@@ -183,7 +183,9 @@ module SystemNoteService
...
@@ -183,7 +183,9 @@ module SystemNoteService
body
=
status
.
dup
body
=
status
.
dup
body
<<
" via
#{
source
.
gfm_reference
(
project
)
}
"
if
source
body
<<
" via
#{
source
.
gfm_reference
(
project
)
}
"
if
source
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'status'
))
action
=
status
==
'reopened'
?
'opened'
:
status
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
action
))
end
end
# Called when 'merge when pipeline succeeds' is executed
# Called when 'merge when pipeline succeeds' is executed
...
@@ -273,9 +275,15 @@ module SystemNoteService
...
@@ -273,9 +275,15 @@ module SystemNoteService
#
#
# Returns the created Note object
# Returns the created Note object
def
change_issue_confidentiality
(
issue
,
project
,
author
)
def
change_issue_confidentiality
(
issue
,
project
,
author
)
body
=
issue
.
confidential
?
'made the issue confidential'
:
'made the issue visible to everyone'
if
issue
.
confidential
body
=
'made the issue confidential'
action
=
'confidential'
else
body
=
'made the issue visible to everyone'
action
=
'visible'
end
create_note
(
NoteSummary
.
new
(
issue
,
project
,
author
,
body
,
action:
'confidentiality'
))
create_note
(
NoteSummary
.
new
(
issue
,
project
,
author
,
body
,
action:
action
))
end
end
# Called when a branch in Noteable is changed
# Called when a branch in Noteable is changed
...
...
spec/services/system_note_service_spec.rb
View file @
d67d43d1
...
@@ -221,26 +221,23 @@ describe SystemNoteService, services: true do
...
@@ -221,26 +221,23 @@ describe SystemNoteService, services: true do
describe
'.change_status'
do
describe
'.change_status'
do
subject
{
described_class
.
change_status
(
noteable
,
project
,
author
,
status
,
source
)
}
subject
{
described_class
.
change_status
(
noteable
,
project
,
author
,
status
,
source
)
}
let
(
:status
)
{
'new_status'
}
context
'with status reopened'
do
let
(
:source
)
{
nil
}
let
(
:status
)
{
'reopened'
}
let
(
:source
)
{
nil
}
it_behaves_like
'a system note'
do
it_behaves_like
'a system note'
do
let
(
:action
)
{
'status'
}
let
(
:action
)
{
'opened'
}
end
end
end
context
'with a source'
do
context
'with a source'
do
let
(
:status
)
{
'opened'
}
let
(
:source
)
{
double
(
'commit'
,
gfm_reference:
'commit 123456'
)
}
let
(
:source
)
{
double
(
'commit'
,
gfm_reference:
'commit 123456'
)
}
it
'sets the note text'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"
#{
status
}
via commit 123456"
expect
(
subject
.
note
).
to
eq
"
#{
status
}
via commit 123456"
end
end
end
end
context
'without a source'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
status
end
end
end
end
describe
'.merge_when_pipeline_succeeds'
do
describe
'.merge_when_pipeline_succeeds'
do
...
@@ -298,9 +295,23 @@ describe SystemNoteService, services: true do
...
@@ -298,9 +295,23 @@ describe SystemNoteService, services: true do
describe
'.change_issue_confidentiality'
do
describe
'.change_issue_confidentiality'
do
subject
{
described_class
.
change_issue_confidentiality
(
noteable
,
project
,
author
)
}
subject
{
described_class
.
change_issue_confidentiality
(
noteable
,
project
,
author
)
}
context
'when noteable responds to `confidential`'
do
context
'issue has been made confidential'
do
before
do
noteable
.
update_attribute
(
:confidential
,
true
)
end
it_behaves_like
'a system note'
do
let
(
:action
)
{
'confidential'
}
end
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
'made the issue confidential'
end
end
context
'issue has been made visible'
do
it_behaves_like
'a system note'
do
it_behaves_like
'a system note'
do
let
(
:action
)
{
'
confidentiality
'
}
let
(
:action
)
{
'
visible
'
}
end
end
it
'sets the note text'
do
it
'sets the note text'
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