BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
df65334e
Commit
df65334e
authored
Jul 23, 2017
by
Hiroyuki Sato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor: use keyword arguments for optional parameters
parent
7ff9008f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
4 deletions
+4
-4
wiki_page.rb
app/models/wiki_page.rb
+1
-1
update_service.rb
app/services/wiki_pages/update_service.rb
+1
-1
wiki_page_spec.rb
spec/models/wiki_page_spec.rb
+2
-2
No files found.
app/models/wiki_page.rb
View file @
df65334e
...
...
@@ -192,7 +192,7 @@ class WikiPage
#
# Returns the String SHA1 of the newly created page
# or False if the save was unsuccessful.
def
update
(
new_content
=
""
,
format
=
:markdown
,
message
=
nil
,
last_commit_sha
=
nil
)
def
update
(
new_content
,
format: :markdown
,
message:
nil
,
last_commit_sha:
nil
)
@attributes
[
:content
]
=
new_content
@attributes
[
:format
]
=
format
...
...
app/services/wiki_pages/update_service.rb
View file @
df65334e
module
WikiPages
class
UpdateService
<
WikiPages
::
BaseService
def
execute
(
page
)
if
page
.
update
(
@params
[
:content
],
@params
[
:format
],
@params
[
:message
],
@params
[
:last_commit_sha
])
if
page
.
update
(
@params
[
:content
],
format:
@params
[
:format
],
message:
@params
[
:message
],
last_commit_sha:
@params
[
:last_commit_sha
])
execute_hooks
(
page
,
'update'
)
end
...
...
spec/models/wiki_page_spec.rb
View file @
df65334e
...
...
@@ -212,14 +212,14 @@ describe WikiPage, models: true do
context
'with same last commit sha'
do
it
'returns true'
do
last_commit_sha
=
@page
.
commit
.
sha
expect
(
@page
.
update
(
'more content'
,
:markdown
,
nil
,
last_commit_sha
)).
to
be_truthy
expect
(
@page
.
update
(
'more content'
,
last_commit_sha:
last_commit_sha
)).
to
be_truthy
end
end
context
'with different last commit sha'
do
it
'raises exception'
do
last_commit_sha
=
'xxx'
expect
{
@page
.
update
(
'more content'
,
:markdown
,
nil
,
last_commit_sha
)
}.
to
raise_error
(
WikiPage
::
PageChangedError
)
expect
{
@page
.
update
(
'more content'
,
last_commit_sha:
last_commit_sha
)
}.
to
raise_error
(
WikiPage
::
PageChangedError
)
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