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
41d1669b
Commit
41d1669b
authored
Jan 24, 2020
by
Nicolò Maria Mezzopera
Committed by
Peter Leitzen
Jan 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show settings only if container registry enabled
- create helper - use helper instead of direct feature flag call
parent
4fc452a9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
5 deletions
+51
-5
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+6
-0
app/views/projects/settings/ci_cd/show.html.haml
app/views/projects/settings/ci_cd/show.html.haml
+1
-1
spec/features/projects/settings/registry_settings_spec.rb
spec/features/projects/settings/registry_settings_spec.rb
+44
-4
No files found.
app/helpers/projects_helper.rb
View file @
41d1669b
...
...
@@ -709,4 +709,10 @@ module ProjectsHelper
def
show_visibility_confirm_modal?
(
project
)
project
.
unlink_forks_upon_visibility_decrease_enabled?
&&
project
.
visibility_level
>
Gitlab
::
VisibilityLevel
::
PRIVATE
&&
project
.
forks_count
>
0
end
def
settings_container_registry_expiration_policy_available?
(
project
)
Feature
.
enabled?
(
:registry_retention_policies_settings
,
project
)
&&
Gitlab
.
config
.
registry
.
enabled
&&
can?
(
current_user
,
:read_container_image
,
project
)
end
end
app/views/projects/settings/ci_cd/show.html.haml
View file @
41d1669b
...
...
@@ -62,7 +62,7 @@
.settings-content
=
render
'projects/triggers/index'
-
if
Feature
.
enabled?
(
:registry_retention_policies_settings
,
@project
)
-
if
settings_container_registry_expiration_policy_available?
(
@project
)
%section
.settings.no-animate
#js-registry-policies
{
class:
(
'expanded'
if
expanded
)
}
.settings-header
%h4
...
...
spec/features/projects/settings/registry_settings_spec.rb
View file @
41d1669b
...
...
@@ -4,20 +4,26 @@ require 'spec_helper'
describe
'Project > Settings > CI/CD > Container registry tag expiration policy'
,
:js
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
,
container_registry_enabled:
container_registry_enabled
)
}
let
(
:container_registry_enabled
)
{
true
}
before
do
sign_in
(
user
)
stub_container_registry_config
(
enabled:
true
)
stub_feature_flags
(
registry_retention_policies_settings:
true
)
end
context
'as owner'
do
before
do
sign_in
(
user
)
visit
project_settings_ci_cd_path
(
project
)
end
it
's
ection is available
'
do
it
's
hows available section
'
do
settings_block
=
find
(
'#js-registry-policies'
)
expect
(
settings_block
).
to
have_text
'Container Registry tag expiration policy'
end
it
'
Save
expiration policy submit the form'
do
it
'
saves
expiration policy submit the form'
do
within
'#js-registry-policies'
do
within
'.card-body'
do
find
(
'#expiration-policy-toggle button:not(.is-disabled)'
).
click
...
...
@@ -34,4 +40,38 @@ describe 'Project > Settings > CI/CD > Container registry tag expiration policy'
expect
(
toast
).
to
have_content
(
'Expiration policy successfully saved.'
)
end
end
context
'when registry is disabled'
do
before
do
stub_container_registry_config
(
enabled:
false
)
visit
project_settings_ci_cd_path
(
project
)
end
it
'does not exists'
do
expect
(
page
).
not_to
have_selector
(
'#js-registry-policies'
)
end
end
context
'when container registry is disabled on project'
do
let
(
:container_registry_enabled
)
{
false
}
before
do
visit
project_settings_ci_cd_path
(
project
)
end
it
'does not exists'
do
expect
(
page
).
not_to
have_selector
(
'#js-registry-policies'
)
end
end
context
'when feature flag is disabled'
do
before
do
stub_feature_flags
(
registry_retention_policies_settings:
false
)
visit
project_settings_ci_cd_path
(
project
)
end
it
'does not exists'
do
expect
(
page
).
not_to
have_selector
(
'#js-registry-policies'
)
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