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
7d0a27a2
Commit
7d0a27a2
authored
Oct 02, 2019
by
Patrick Derichs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use named arguments for SystemNotes::BaseService constructor
parent
be0877c6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
6 deletions
+21
-6
app/services/system_note_service.rb
app/services/system_note_service.rb
+2
-2
app/services/system_notes/base_service.rb
app/services/system_notes/base_service.rb
+1
-1
spec/services/system_notes/base_service_spec.rb
spec/services/system_notes/base_service_spec.rb
+16
-1
spec/services/system_notes/commit_service_spec.rb
spec/services/system_notes/commit_service_spec.rb
+2
-2
No files found.
app/services/system_note_service.rb
View file @
7d0a27a2
...
...
@@ -18,7 +18,7 @@ module SystemNoteService
#
# Returns the created Note object
def
add_commits
(
noteable
,
project
,
author
,
new_commits
,
existing_commits
=
[],
oldrev
=
nil
)
::
SystemNotes
::
CommitService
.
new
(
noteable
,
project
,
author
).
add_commits
(
new_commits
,
existing_commits
,
oldrev
)
::
SystemNotes
::
CommitService
.
new
(
noteable
:
noteable
,
project:
project
,
author:
author
).
add_commits
(
new_commits
,
existing_commits
,
oldrev
)
end
# Called when a commit was tagged
...
...
@@ -30,7 +30,7 @@ module SystemNoteService
#
# Returns the created Note object
def
tag_commit
(
noteable
,
project
,
author
,
tag_name
)
::
SystemNotes
::
CommitService
.
new
(
noteable
,
project
,
author
).
tag_commit
(
tag_name
)
::
SystemNotes
::
CommitService
.
new
(
noteable
:
noteable
,
project:
project
,
author:
author
).
tag_commit
(
tag_name
)
end
# Called when the assignee of a Noteable is changed or removed
...
...
app/services/system_notes/base_service.rb
View file @
7d0a27a2
...
...
@@ -4,7 +4,7 @@ module SystemNotes
class
BaseService
attr_reader
:noteable
,
:project
,
:author
def
initialize
(
noteable
,
project
,
author
)
def
initialize
(
noteable
:
nil
,
author:
nil
,
project:
nil
)
@noteable
=
noteable
@project
=
project
@author
=
author
...
...
spec/services/system_notes/base_service_spec.rb
View file @
7d0a27a2
...
...
@@ -7,23 +7,38 @@ describe SystemNotes::BaseService do
let
(
:project
)
{
double
}
let
(
:author
)
{
double
}
let
(
:base_service
)
{
described_class
.
new
(
noteable
,
project
,
author
)
}
let
(
:base_service
)
{
described_class
.
new
(
noteable
:
noteable
,
project:
project
,
author:
author
)
}
describe
'#noteable'
do
subject
{
base_service
.
noteable
}
it
{
is_expected
.
to
eq
(
noteable
)
}
it
'returns nil if no arguments are given'
do
instance
=
described_class
.
new
expect
(
instance
.
noteable
).
to
be_nil
end
end
describe
'#project'
do
subject
{
base_service
.
project
}
it
{
is_expected
.
to
eq
(
project
)
}
it
'returns nil if no arguments are given'
do
instance
=
described_class
.
new
expect
(
instance
.
project
).
to
be_nil
end
end
describe
'#author'
do
subject
{
base_service
.
author
}
it
{
is_expected
.
to
eq
(
author
)
}
it
'returns nil if no arguments are given'
do
instance
=
described_class
.
new
expect
(
instance
.
author
).
to
be_nil
end
end
end
spec/services/system_notes/commit_service_spec.rb
View file @
7d0a27a2
...
...
@@ -7,7 +7,7 @@ describe SystemNotes::CommitService do
set
(
:project
)
{
create
(
:project
,
:repository
,
group:
group
)
}
set
(
:author
)
{
create
(
:user
)
}
let
(
:commit_service
)
{
described_class
.
new
(
noteable
,
project
,
author
)
}
let
(
:commit_service
)
{
described_class
.
new
(
noteable
:
noteable
,
project:
project
,
author:
author
)
}
describe
'#add_commits'
do
subject
{
commit_service
.
add_commits
(
new_commits
,
old_commits
,
oldrev
)
}
...
...
@@ -111,7 +111,7 @@ describe SystemNotes::CommitService do
commit
=
double
(
title:
'<pre>This is a test</pre>'
,
short_id:
'12345678'
)
escaped
=
'<pre>This is a test</pre>'
expect
(
described_class
.
new
(
nil
,
nil
,
nil
)
.
new_commit_summary
([
commit
])).
to
all
(
match
(
/-
#{
escaped
}
/
))
expect
(
described_class
.
new
.
new_commit_summary
([
commit
])).
to
all
(
match
(
/-
#{
escaped
}
/
))
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