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
a0f7a0e9
Commit
a0f7a0e9
authored
Dec 11, 2019
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide mirror admin actions from developers
parent
8d416b7b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
1 deletion
+115
-1
changelogs/unreleased/35305-hide-unauthorized-mirroring-actions.yml
.../unreleased/35305-hide-unauthorized-mirroring-actions.yml
+5
-0
ee/app/views/shared/_mirror_update_button.html.haml
ee/app/views/shared/_mirror_update_button.html.haml
+5
-1
ee/spec/views/shared/_mirror_update_button.html.haml_spec.rb
ee/spec/views/shared/_mirror_update_button.html.haml_spec.rb
+105
-0
No files found.
changelogs/unreleased/35305-hide-unauthorized-mirroring-actions.yml
0 → 100644
View file @
a0f7a0e9
---
title
:
Hide mirror admin actions from developers
merge_request
:
21569
author
:
type
:
fixed
ee/app/views/shared/_mirror_update_button.html.haml
View file @
a0f7a0e9
...
...
@@ -8,10 +8,14 @@
%span
.btn.disabled
=
icon
(
"refresh spin"
)
Updating
…
-
els
e
-
els
if
can?
(
current_user
,
:admin_project
,
@project
)
=
link_to
update_now_project_mirror_path
(
@project
),
method: :post
,
class:
'btn'
do
=
icon
(
"refresh"
)
Update Now
-
else
%span
.btn.disabled
=
icon
(
"refresh"
)
Update Now
-
if
@project
.
mirror_last_update_succeeded?
%p
.inline.prepend-left-10
Successfully updated
#{
time_ago_with_tooltip
(
@project
.
import_state
.
last_successful_update_at
)
}
.
ee/spec/views/shared/_mirror_update_button.html.haml_spec.rb
0 → 100644
View file @
a0f7a0e9
# frozen_string_literal: true
require
'spec_helper'
describe
'shared/mirror_update_button'
do
let
(
:partial
)
{
'shared/mirror_update_button'
}
let_it_be
(
:project
)
{
create
(
:project
,
:mirror
)
}
let
(
:import_state
)
{
project
.
import_state
}
let
(
:owner
)
{
project
.
owner
}
let
(
:developer
)
{
create
(
:user
).
tap
{
|
user
|
project
.
team
.
add_developer
(
user
)
}
}
let
(
:reporter
)
{
create
(
:user
).
tap
{
|
user
|
project
.
team
.
add_reporter
(
user
)
}
}
let
(
:update_link
)
{
update_now_project_mirror_path
(
project
)
}
let
(
:have_update_button
)
{
have_link
(
'Update Now'
,
href:
update_link
)
}
before
do
@project
=
project
end
subject
{
rendered
}
context
'mirror update can be triggered'
do
context
'user is owner'
do
it
'renders a working update button'
do
render
partial
,
current_user:
owner
is_expected
.
to
have_update_button
end
end
context
'user is developer'
do
it
'renders a disabled update button'
do
render
partial
,
current_user:
developer
is_expected
.
to
have_text
(
'Update Now'
)
is_expected
.
not_to
have_update_button
end
end
context
'user is anonymous'
do
it
'renders nothing'
do
render
partial
,
current_user:
nil
is_expected
.
to
eq
(
''
)
end
end
end
context
'mirror update due'
do
it
'renders a disabled update button'
do
expect
(
import_state
).
to
receive
(
:mirror_update_due?
)
{
true
}
allow
(
import_state
).
to
receive
(
:last_successful_update_at
)
{
Time
.
now
}
render
partial
,
current_user:
owner
is_expected
.
to
have_text
(
'Scheduled…'
)
is_expected
.
not_to
have_update_button
end
end
context
'mirror is currently updating'
do
it
'renders a disabled update button'
do
expect
(
import_state
).
to
receive
(
:updating_mirror?
)
{
true
}
render
partial
,
current_user:
owner
is_expected
.
to
have_text
(
'Updating…'
)
is_expected
.
not_to
have_update_button
end
end
context
'project is not a mirror'
do
let
(
:project
)
{
create
(
:project
)
}
it
'renders nothing'
do
is_expected
.
to
eq
(
''
)
end
end
it
'renders a notification if the last update succeeded'
do
expect
(
project
).
to
receive
(
:mirror_last_update_succeeded?
)
{
true
}
expect
(
import_state
).
to
receive
(
:last_successful_update_at
)
{
Time
.
now
}
render
partial
,
current_user:
developer
is_expected
.
to
have_text
(
'Successfully updated'
)
end
it
'renders no notification if the last update did not succeed'
do
expect
(
project
).
to
receive
(
:mirror_last_update_succeeded?
)
{
false
}
render
partial
,
current_user:
developer
is_expected
.
not_to
have_text
(
'Successfully updated'
)
end
it
"renders nothing if the user can't push code"
do
render
partial
,
current_user:
reporter
is_expected
.
to
eq
(
''
)
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