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
8babca59
Commit
8babca59
authored
Jul 05, 2021
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show 'Delete' button to developers in Wiki
Changelog: changed
parent
33b5009b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
14 deletions
+61
-14
app/controllers/concerns/wiki_actions.rb
app/controllers/concerns/wiki_actions.rb
+1
-2
app/views/shared/wikis/edit.html.haml
app/views/shared/wikis/edit.html.haml
+1
-1
spec/support/shared_examples/controllers/wiki_actions_shared_examples.rb
...ared_examples/controllers/wiki_actions_shared_examples.rb
+38
-6
spec/support/shared_examples/features/wiki/user_deletes_wiki_page_shared_examples.rb
...s/features/wiki/user_deletes_wiki_page_shared_examples.rb
+21
-5
No files found.
app/controllers/concerns/wiki_actions.rb
View file @
8babca59
...
...
@@ -14,8 +14,7 @@ module WikiActions
before_action
{
respond_to
:html
}
before_action
:authorize_read_wiki!
before_action
:authorize_create_wiki!
,
only:
[
:edit
,
:create
]
before_action
:authorize_admin_wiki!
,
only: :destroy
before_action
:authorize_create_wiki!
,
only:
[
:edit
,
:create
,
:destroy
]
before_action
:wiki
before_action
:page
,
only:
[
:show
,
:edit
,
:update
,
:history
,
:destroy
,
:diff
]
...
...
app/views/shared/wikis/edit.html.haml
View file @
8babca59
...
...
@@ -18,7 +18,7 @@
.nav-controls.pb-md-3.pb-lg-0
-
if
@page
.
persisted?
-
if
can?
(
current_user
,
:
admin
_wiki
,
@wiki
.
container
)
-
if
can?
(
current_user
,
:
create
_wiki
,
@wiki
.
container
)
#delete-wiki-modal-wrapper
{
data:
{
delete_wiki_url:
wiki_page_path
(
@wiki
,
@page
),
page_title:
@page
.
human_title
}
}
=
render
'shared/wikis/form'
,
uploads_path:
wiki_attachment_upload_url
...
...
spec/support/shared_examples/controllers/wiki_actions_shared_examples.rb
View file @
8babca59
# frozen_string_literal: true
RSpec
.
shared_examples
'wiki controller actions'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:other_user
)
{
create
(
:user
)
}
let
(
:container
)
{
raise
NotImplementedError
}
let
(
:routing_params
)
{
raise
NotImplementedError
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:wiki
)
{
Wiki
.
for_container
(
container
,
user
)
}
let
(
:wiki_title
)
{
'page title test'
}
...
...
@@ -458,6 +459,7 @@ RSpec.shared_examples 'wiki controller actions' do
describe
'DELETE #destroy'
do
let
(
:id_param
)
{
wiki_title
}
let
(
:delete_user
)
{
user
}
subject
(
:request
)
do
delete
(
:destroy
,
...
...
@@ -466,13 +468,21 @@ RSpec.shared_examples 'wiki controller actions' do
))
end
before
do
sign_in
(
delete_user
)
end
context
'when page exists'
do
it
'deletes the page'
do
expect
do
request
end
.
to
change
{
wiki
.
list_pages
.
size
}.
by
(
-
1
)
shared_examples
'deletes the page'
do
specify
do
expect
do
request
end
.
to
change
{
wiki
.
list_pages
.
size
}.
by
(
-
1
)
end
end
it_behaves_like
'deletes the page'
context
'but page cannot be deleted'
do
before
do
allow_next_instance_of
(
WikiPage
)
do
|
page
|
...
...
@@ -489,6 +499,28 @@ RSpec.shared_examples 'wiki controller actions' do
expect
(
assigns
(
:error
)).
to
eq
(
'Could not delete wiki page'
)
end
end
context
'when user is a developer'
do
let
(
:delete_user
)
{
other_user
}
before
do
container
.
add_developer
(
other_user
)
end
it_behaves_like
'deletes the page'
end
context
'when user is a reporter'
do
let
(
:delete_user
)
{
other_user
}
before
do
container
.
add_reporter
(
other_user
)
end
it
'returns 404'
do
is_expected
.
to
have_gitlab_http_status
(
:not_found
)
end
end
end
context
'when page does not exist'
do
...
...
spec/support/shared_examples/features/wiki/user_deletes_wiki_page_shared_examples.rb
View file @
8babca59
...
...
@@ -7,18 +7,34 @@
RSpec
.
shared_examples
'User deletes wiki page'
do
include
WikiHelpers
let_it_be
(
:developer
)
{
create
(
:user
)
}
let
(
:wiki_page
)
{
create
(
:wiki_page
,
wiki:
wiki
)
}
before
do
wiki
.
container
.
add_developer
(
developer
)
sign_in
(
user
)
visit
wiki_page_path
(
wiki
,
wiki_page
)
end
it
'deletes a page'
,
:js
do
click_on
(
'Edit'
)
click_on
(
'Delete'
)
find
(
'[data-testid="confirm_deletion_button"]'
).
click
shared_examples
'deletes a wiki page'
do
specify
'deletes a page'
,
:js
do
click_on
(
'Edit'
)
click_on
(
'Delete'
)
find
(
'[data-testid="confirm_deletion_button"]'
).
click
expect
(
page
).
to
have_content
(
'Wiki page was successfully deleted.'
)
end
end
context
'when user is the owner or maintainer'
do
it_behaves_like
'deletes a wiki page'
end
context
'when user is a developer'
do
let
(
:user
)
{
developer
}
expect
(
page
).
to
have_content
(
'Wiki page was successfully deleted.'
)
it_behaves_like
'deletes a wiki page'
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