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
2dd9b8a3
Commit
2dd9b8a3
authored
Mar 20, 2017
by
Dongqing Hu
Committed by
Rémy Coutable
Mar 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Project Wiki update
parent
915af2dc
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
13 deletions
+36
-13
app/controllers/projects/wikis_controller.rb
app/controllers/projects/wikis_controller.rb
+2
-1
app/helpers/nav_helper.rb
app/helpers/nav_helper.rb
+1
-0
app/models/wiki_page.rb
app/models/wiki_page.rb
+5
-3
changelogs/unreleased/29405-fix-project-wiki-update.yml
changelogs/unreleased/29405-fix-project-wiki-update.yml
+4
-0
spec/features/projects/wiki/user_updates_wiki_page_spec.rb
spec/features/projects/wiki/user_updates_wiki_page_spec.rb
+24
-9
No files found.
app/controllers/projects/wikis_controller.rb
View file @
2dd9b8a3
...
...
@@ -45,8 +45,9 @@ class Projects::WikisController < Projects::ApplicationController
return
render
(
'empty'
)
unless
can?
(
current_user
,
:create_wiki
,
@project
)
@page
=
@project_wiki
.
find_page
(
params
[
:id
])
@page
=
WikiPages
::
UpdateService
.
new
(
@project
,
current_user
,
wiki_params
).
execute
(
@page
)
if
@page
=
WikiPages
::
UpdateService
.
new
(
@project
,
current_user
,
wiki_params
).
execute
(
@page
)
if
@page
.
valid?
redirect_to
(
namespace_project_wiki_path
(
@project
.
namespace
,
@project
,
@page
),
notice:
'Wiki was successfully updated.'
...
...
app/helpers/nav_helper.rb
View file @
2dd9b8a3
...
...
@@ -16,6 +16,7 @@ module NavHelper
"page-gutter build-sidebar right-sidebar-expanded"
elsif
current_path?
(
'wikis#show'
)
||
current_path?
(
'wikis#edit'
)
||
current_path?
(
'wikis#update'
)
||
current_path?
(
'wikis#history'
)
||
current_path?
(
'wikis#git_access'
)
"page-gutter wiki-sidebar right-sidebar-expanded"
...
...
app/models/wiki_page.rb
View file @
2dd9b8a3
...
...
@@ -155,7 +155,7 @@ class WikiPage
end
# Returns boolean True or False if this instance
# has been fully
saved to
disk or not.
# has been fully
created on
disk or not.
def
persisted?
@persisted
==
true
end
...
...
@@ -226,6 +226,8 @@ class WikiPage
end
def
save
(
method
,
*
args
)
saved
=
false
project_wiki
=
wiki
if
valid?
&&
project_wiki
.
send
(
method
,
*
args
)
...
...
@@ -243,10 +245,10 @@ class WikiPage
set_attributes
@persisted
=
true
saved
=
true
else
errors
.
add
(
:base
,
project_wiki
.
error_message
)
if
project_wiki
.
error_message
@persisted
=
false
end
@persist
ed
sav
ed
end
end
changelogs/unreleased/29405-fix-project-wiki-update.yml
0 → 100644
View file @
2dd9b8a3
---
title
:
Fix Project Wiki update
merge_request
:
9990
author
:
Dongqing Hu
spec/features/projects/wiki/user_updates_wiki_page_spec.rb
View file @
2dd9b8a3
...
...
@@ -15,7 +15,8 @@ feature 'Projects > Wiki > User updates wiki page', feature: true do
context
'in the user namespace'
do
let
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
scenario
'the home page'
do
context
'the home page'
do
scenario
'success when the wiki content is not empty'
do
click_link
'Edit'
fill_in
:wiki_content
,
with:
'My awesome wiki!'
...
...
@@ -25,6 +26,20 @@ feature 'Projects > Wiki > User updates wiki page', feature: true do
expect
(
page
).
to
have_content
(
"Last edited by
#{
user
.
name
}
"
)
expect
(
page
).
to
have_content
(
'My awesome wiki!'
)
end
scenario
'failure when the wiki content is empty'
do
click_link
'Edit'
fill_in
:wiki_content
,
with:
''
click_button
'Save changes'
expect
(
page
).
to
have_selector
(
'.wiki-form'
)
expect
(
page
).
to
have_content
(
'Edit Page'
)
expect
(
page
).
to
have_content
(
'The form contains the following error:'
)
expect
(
page
).
to
have_content
(
'Content can\'t be blank'
)
expect
(
find
(
'textarea#wiki_content'
).
value
).
to
eq
''
end
end
end
context
'in a group namespace'
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