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
744ae80c
Commit
744ae80c
authored
May 17, 2021
by
Athar Hameed
Committed by
Robert Speicher
May 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Changes will be lost if multiple people edit a wiki page"
parent
b5be8cd0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
15 deletions
+27
-15
app/controllers/concerns/wiki_actions.rb
app/controllers/concerns/wiki_actions.rb
+0
-3
app/services/wiki_pages/update_service.rb
app/services/wiki_pages/update_service.rb
+10
-4
changelogs/unreleased/200002-changes-will-be-lost-if-multiple-people-edit-a-wiki-page.yml
...nges-will-be-lost-if-multiple-people-edit-a-wiki-page.yml
+5
-0
spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb
...s/features/wiki/user_updates_wiki_page_shared_examples.rb
+12
-8
No files found.
app/controllers/concerns/wiki_actions.rb
View file @
744ae80c
...
@@ -115,9 +115,6 @@ module WikiActions
...
@@ -115,9 +115,6 @@ module WikiActions
@error
=
response
.
message
@error
=
response
.
message
render
'shared/wikis/edit'
render
'shared/wikis/edit'
end
end
rescue
WikiPage
::
PageChangedError
,
WikiPage
::
PageRenameError
=>
e
@error
=
e
.
message
render
'shared/wikis/edit'
end
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
# rubocop:enable Gitlab/ModuleWithInstanceVariables
...
...
app/services/wiki_pages/update_service.rb
View file @
744ae80c
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
module
WikiPages
module
WikiPages
class
UpdateService
<
WikiPages
::
BaseService
class
UpdateService
<
WikiPages
::
BaseService
UpdateError
=
Class
.
new
(
StandardError
)
def
execute
(
page
)
def
execute
(
page
)
# this class is not thread safe!
# this class is not thread safe!
@old_slug
=
page
.
slug
@old_slug
=
page
.
slug
...
@@ -10,11 +12,15 @@ module WikiPages
...
@@ -10,11 +12,15 @@ module WikiPages
execute_hooks
(
page
)
execute_hooks
(
page
)
ServiceResponse
.
success
(
payload:
{
page:
page
})
ServiceResponse
.
success
(
payload:
{
page:
page
})
else
else
ServiceResponse
.
error
(
raise
UpdateError
,
s_
(
'Could not update wiki page'
)
message:
_
(
'Could not update wiki page'
),
payload:
{
page:
page
}
)
end
end
rescue
UpdateError
,
WikiPage
::
PageChangedError
,
WikiPage
::
PageRenameError
=>
e
page
.
update_attributes
(
@params
)
# rubocop:disable Rails/ActiveRecordAliases
ServiceResponse
.
error
(
message:
e
.
message
,
payload:
{
page:
page
}
)
end
end
def
usage_counter_action
def
usage_counter_action
...
...
changelogs/unreleased/200002-changes-will-be-lost-if-multiple-people-edit-a-wiki-page.yml
0 → 100644
View file @
744ae80c
---
title
:
Preserve user changes in the wiki editor if multiple people edit the page
merge_request
:
61120
author
:
type
:
fixed
spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb
View file @
744ae80c
...
@@ -117,14 +117,6 @@ RSpec.shared_examples 'User updates wiki page' do
...
@@ -117,14 +117,6 @@ RSpec.shared_examples 'User updates wiki page' do
expect
(
page
).
to
have_selector
(
'.atwho-view'
)
expect
(
page
).
to
have_selector
(
'.atwho-view'
)
end
end
it
'shows the error message'
,
:js
do
wiki_page
.
update
(
content:
'Update'
)
# rubocop:disable Rails/SaveBang
click_button
(
'Save changes'
)
expect
(
page
).
to
have_content
(
'Someone edited the page the same time you did.'
)
end
it
'updates a page'
,
:js
do
it
'updates a page'
,
:js
do
fill_in
(
'Content'
,
with:
'Updated Wiki Content'
)
fill_in
(
'Content'
,
with:
'Updated Wiki Content'
)
click_on
(
'Save changes'
)
click_on
(
'Save changes'
)
...
@@ -145,6 +137,18 @@ RSpec.shared_examples 'User updates wiki page' do
...
@@ -145,6 +137,18 @@ RSpec.shared_examples 'User updates wiki page' do
end
end
it_behaves_like
'wiki file attachments'
it_behaves_like
'wiki file attachments'
context
'when multiple people edit the page at the same time'
do
it
'preserves user changes in the wiki editor'
,
:js
do
wiki_page
.
update
(
content:
'Some Other Updates'
)
# rubocop:disable Rails/SaveBang
fill_in
(
'Content'
,
with:
'Updated Wiki Content'
)
click_on
(
'Save changes'
)
expect
(
page
).
to
have_content
(
'Someone edited the page the same time you did.'
)
expect
(
find
(
'textarea#wiki_content'
).
value
).
to
eq
(
'Updated Wiki Content'
)
end
end
end
end
context
'when the page is in a subdir'
,
:js
do
context
'when the page is in a subdir'
,
:js
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