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
Léo-Paul Géneau
gitlab-ce
Commits
3811eb0b
Commit
3811eb0b
authored
Apr 26, 2016
by
Rémy Coutable
Committed by
Stan Hu
Apr 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error when trying to create a wiki page
Closes #15527. Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
bfc6a0e3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
139 additions
and
4 deletions
+139
-4
CHANGELOG
CHANGELOG
+2
-1
app/controllers/projects/wikis_controller.rb
app/controllers/projects/wikis_controller.rb
+2
-2
app/services/wiki_pages/create_service.rb
app/services/wiki_pages/create_service.rb
+2
-1
spec/features/projects/wiki/user_creates_wiki_page_spec.rb
spec/features/projects/wiki/user_creates_wiki_page_spec.rb
+87
-0
spec/features/projects/wiki/user_updates_wiki_page_spec.rb
spec/features/projects/wiki/user_updates_wiki_page_spec.rb
+46
-0
No files found.
CHANGELOG
View file @
3811eb0b
...
@@ -15,8 +15,9 @@ v 8.8.0 (unreleased)
...
@@ -15,8 +15,9 @@ v 8.8.0 (unreleased)
- Files over 5MB can only be viewed in their raw form, files over 1MB without highlighting !3718
- Files over 5MB can only be viewed in their raw form, files over 1MB without highlighting !3718
- Add support for supressing text diffs using .gitattributes on the default branch (Matt Oakes)
- Add support for supressing text diffs using .gitattributes on the default branch (Matt Oakes)
v 8.7.2
v 8.7.2
(unreleased)
- The "New Branch" button is now loaded asynchronously
- The "New Branch" button is now loaded asynchronously
- Fix error 500 when trying to create a wiki page
v 8.7.1
v 8.7.1
- Throttle the update of `project.last_activity_at` to 1 minute. !3848
- Throttle the update of `project.last_activity_at` to 1 minute. !3848
...
...
app/controllers/projects/wikis_controller.rb
View file @
3811eb0b
...
@@ -40,10 +40,10 @@ class Projects::WikisController < Projects::ApplicationController
...
@@ -40,10 +40,10 @@ class Projects::WikisController < Projects::ApplicationController
end
end
def
update
def
update
@page
=
@project_wiki
.
find_page
(
params
[
:id
])
return
render
(
'empty'
)
unless
can?
(
current_user
,
:create_wiki
,
@project
)
return
render
(
'empty'
)
unless
can?
(
current_user
,
:create_wiki
,
@project
)
@page
=
@project_wiki
.
find_page
(
params
[
:id
])
if
@page
=
WikiPages
::
UpdateService
.
new
(
@project
,
current_user
,
wiki_params
).
execute
(
@page
)
if
@page
=
WikiPages
::
UpdateService
.
new
(
@project
,
current_user
,
wiki_params
).
execute
(
@page
)
redirect_to
(
redirect_to
(
namespace_project_wiki_path
(
@project
.
namespace
,
@project
,
@page
),
namespace_project_wiki_path
(
@project
.
namespace
,
@project
,
@page
),
...
...
app/services/wiki_pages/create_service.rb
View file @
3811eb0b
module
WikiPages
module
WikiPages
class
CreateService
<
WikiPages
::
BaseService
class
CreateService
<
WikiPages
::
BaseService
def
execute
def
execute
page
=
WikiPage
.
new
(
@project
.
wiki
)
project_wiki
=
ProjectWiki
.
new
(
@project
,
current_user
)
page
=
WikiPage
.
new
(
project_wiki
)
if
page
.
create
(
@params
)
if
page
.
create
(
@params
)
execute_hooks
(
page
,
'create'
)
execute_hooks
(
page
,
'create'
)
...
...
spec/features/projects/wiki/user_creates_wiki_page_spec.rb
0 → 100644
View file @
3811eb0b
require
'spec_helper'
feature
'Projects > Wiki > User creates wiki page'
,
feature:
true
do
let
(
:user
)
{
create
(
:user
)
}
background
do
project
.
team
<<
[
user
,
:master
]
login_as
(
user
)
visit
namespace_project_path
(
project
.
namespace
,
project
)
click_link
'Wiki'
end
context
'wiki project is in the user namespace'
do
let
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
context
'when wiki is empty'
do
scenario
'user can create a new wiki page from the wiki home page'
do
expect
(
page
).
to
have_content
(
'Home · Edit Page'
)
fill_in
:wiki_content
,
with:
'My awesome wiki!'
click_button
'Create page'
expect
(
page
).
to
have_content
(
"Home · last edited by
#{
user
.
name
}
"
)
expect
(
page
).
to
have_content
(
'My awesome wiki!'
)
end
end
context
'when wiki is not empty'
do
before
do
WikiPages
::
CreateService
.
new
(
project
,
user
,
title:
'home'
,
content:
'Home page'
).
execute
end
scenario
'user can create a new wiki page'
,
js:
true
do
click_link
'New Page'
fill_in
:new_wiki_path
,
with:
'foo'
click_button
'Create Page'
expect
(
page
).
to
have_content
(
'Foo · Edit Page'
)
fill_in
:wiki_content
,
with:
'My awesome wiki!'
click_button
'Create page'
expect
(
page
).
to
have_content
(
"Foo · last edited by
#{
user
.
name
}
"
)
expect
(
page
).
to
have_content
(
'My awesome wiki!'
)
end
end
end
context
'wiki project is in the user namespace'
do
let
(
:project
)
{
create
(
:project
,
namespace:
create
(
:group
,
:public
))
}
context
'when wiki is empty'
do
scenario
'user can create a new wiki page from the wiki home page'
do
expect
(
page
).
to
have_content
(
'Home · Edit Page'
)
fill_in
:wiki_content
,
with:
'My awesome wiki!'
click_button
'Create page'
expect
(
page
).
to
have_content
(
"Home · last edited by
#{
user
.
name
}
"
)
expect
(
page
).
to
have_content
(
'My awesome wiki!'
)
end
end
context
'when wiki is not empty'
do
before
do
WikiPages
::
CreateService
.
new
(
project
,
user
,
title:
'home'
,
content:
'Home page'
).
execute
end
scenario
'user can create a new wiki page'
,
js:
true
do
click_link
'New Page'
fill_in
:new_wiki_path
,
with:
'foo'
click_button
'Create Page'
expect
(
page
).
to
have_content
(
'Foo · Edit Page'
)
fill_in
:wiki_content
,
with:
'My awesome wiki!'
click_button
'Create page'
expect
(
page
).
to
have_content
(
"Foo · last edited by
#{
user
.
name
}
"
)
expect
(
page
).
to
have_content
(
'My awesome wiki!'
)
end
end
end
end
spec/features/projects/wiki/user_updates_wiki_page_spec.rb
0 → 100644
View file @
3811eb0b
require
'spec_helper'
feature
'Projects > Wiki > User updates wiki page'
,
feature:
true
do
let
(
:user
)
{
create
(
:user
)
}
background
do
project
.
team
<<
[
user
,
:master
]
login_as
(
user
)
visit
namespace_project_path
(
project
.
namespace
,
project
)
WikiPages
::
CreateService
.
new
(
project
,
user
,
title:
'home'
,
content:
'Home page'
).
execute
click_link
'Wiki'
end
context
'wiki project is in the user namespace'
do
let
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
scenario
'user can update the wiki home page'
do
click_link
'Edit'
expect
(
page
).
to
have_content
(
'Home · Edit Page'
)
fill_in
:wiki_content
,
with:
'My awesome wiki!'
click_button
'Save changes'
expect
(
page
).
to
have_content
(
"Home · last edited by
#{
user
.
name
}
"
)
expect
(
page
).
to
have_content
(
'My awesome wiki!'
)
end
end
context
'wiki project is in the user namespace'
do
let
(
:project
)
{
create
(
:project
,
namespace:
create
(
:group
,
:public
))
}
scenario
'user can update the wiki home page'
do
click_link
'Edit'
expect
(
page
).
to
have_content
(
'Home · Edit Page'
)
fill_in
:wiki_content
,
with:
'My awesome wiki!'
click_button
'Save changes'
expect
(
page
).
to
have_content
(
"Home · last edited by
#{
user
.
name
}
"
)
expect
(
page
).
to
have_content
(
'My awesome wiki!'
)
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