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
a07efbdf
Commit
a07efbdf
authored
Aug 21, 2019
by
manojmj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CE: Audit event for archiving and unarchiving projects
parent
da573ae2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
4 deletions
+99
-4
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-4
doc/administration/audit_events.md
doc/administration/audit_events.md
+2
-0
spec/controllers/projects_controller_spec.rb
spec/controllers/projects_controller_spec.rb
+96
-0
No files found.
app/controllers/projects_controller.rb
View file @
a07efbdf
...
...
@@ -29,6 +29,7 @@ class ProjectsController < Projects::ApplicationController
# Authorize
before_action
:authorize_admin_project!
,
only:
[
:edit
,
:update
,
:housekeeping
,
:download_export
,
:export
,
:remove_export
,
:generate_new_export
]
before_action
:authorize_archive_project!
,
only:
[
:archive
,
:unarchive
]
before_action
:event_filter
,
only:
[
:show
,
:activity
]
layout
:determine_layout
...
...
@@ -164,8 +165,6 @@ class ProjectsController < Projects::ApplicationController
end
def
archive
return
access_denied!
unless
can?
(
current_user
,
:archive_project
,
@project
)
::
Projects
::
UpdateService
.
new
(
@project
,
current_user
,
archived:
true
).
execute
respond_to
do
|
format
|
...
...
@@ -174,8 +173,6 @@ class ProjectsController < Projects::ApplicationController
end
def
unarchive
return
access_denied!
unless
can?
(
current_user
,
:archive_project
,
@project
)
::
Projects
::
UpdateService
.
new
(
@project
,
current_user
,
archived:
false
).
execute
respond_to
do
|
format
|
...
...
doc/administration/audit_events.md
View file @
a07efbdf
...
...
@@ -75,6 +75,8 @@ From there, you can see the following actions:
-
User was removed from project
-
Project export was downloaded
-
Project repository was downloaded
-
Project was archived
-
Project was unarchived
### Instance events **(PREMIUM ONLY)**
...
...
spec/controllers/projects_controller_spec.rb
View file @
a07efbdf
...
...
@@ -318,6 +318,102 @@ describe ProjectsController do
end
end
describe
'POST #archive'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
before
do
sign_in
(
user
)
end
context
'for a user with the ability to archive a project'
do
before
do
group
.
add_owner
(
user
)
post
:archive
,
params:
{
namespace_id:
project
.
namespace
.
path
,
id:
project
.
path
}
end
it
'archives the project'
do
expect
(
project
.
reload
.
archived?
).
to
be_truthy
end
it
'redirects to projects path'
do
expect
(
response
).
to
have_gitlab_http_status
(
302
)
expect
(
response
).
to
redirect_to
(
project_path
(
project
))
end
end
context
'for a user that does not have the ability to archive a project'
do
before
do
project
.
add_maintainer
(
user
)
post
:archive
,
params:
{
namespace_id:
project
.
namespace
.
path
,
id:
project
.
path
}
end
it
'does not archive the project'
do
expect
(
project
.
reload
.
archived?
).
to
be_falsey
end
it
'returns 404'
do
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
end
describe
'POST #unarchive'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
:archived
,
group:
group
)
}
before
do
sign_in
(
user
)
end
context
'for a user with the ability to unarchive a project'
do
before
do
group
.
add_owner
(
user
)
post
:unarchive
,
params:
{
namespace_id:
project
.
namespace
.
path
,
id:
project
.
path
}
end
it
'unarchives the project'
do
expect
(
project
.
reload
.
archived?
).
to
be_falsey
end
it
'redirects to projects path'
do
expect
(
response
).
to
have_gitlab_http_status
(
302
)
expect
(
response
).
to
redirect_to
(
project_path
(
project
))
end
end
context
'for a user that does not have the ability to unarchive a project'
do
before
do
project
.
add_maintainer
(
user
)
post
:unarchive
,
params:
{
namespace_id:
project
.
namespace
.
path
,
id:
project
.
path
}
end
it
'does not unarchive the project'
do
expect
(
project
.
reload
.
archived?
).
to
be_truthy
end
it
'returns 404'
do
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
end
describe
'#housekeeping'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
...
...
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