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
6574f767
Commit
6574f767
authored
Apr 16, 2020
by
Sean Arnold
Committed by
Peter Leitzen
Apr 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make status page setting object exist always
- refactor specs
parent
7b5ad03d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
51 deletions
+52
-51
ee/app/controllers/ee/projects/settings/operations_controller.rb
...controllers/ee/projects/settings/operations_controller.rb
+5
-1
ee/app/helpers/operations_helper.rb
ee/app/helpers/operations_helper.rb
+7
-7
ee/app/models/status_page_setting.rb
ee/app/models/status_page_setting.rb
+2
-0
ee/app/views/projects/settings/operations/_status_page.html.haml
...views/projects/settings/operations/_status_page.html.haml
+1
-8
ee/spec/helpers/ee/operations_helper_spec.rb
ee/spec/helpers/ee/operations_helper_spec.rb
+23
-35
ee/spec/models/status_page_setting_spec.rb
ee/spec/models/status_page_setting_spec.rb
+14
-0
No files found.
ee/app/controllers/ee/projects/settings/operations_controller.rb
View file @
6574f767
...
@@ -8,7 +8,7 @@ module EE
...
@@ -8,7 +8,7 @@ module EE
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
prepended
do
prepended
do
helper_method
:tracing_setting
helper_method
:tracing_setting
,
:status_page_setting
private
private
...
@@ -16,6 +16,10 @@ module EE
...
@@ -16,6 +16,10 @@ module EE
@tracing_setting
||=
project
.
tracing_setting
||
project
.
build_tracing_setting
@tracing_setting
||=
project
.
tracing_setting
||
project
.
build_tracing_setting
end
end
def
status_page_setting
@status_page_setting
||=
project
.
status_page_setting
||
project
.
build_status_page_setting
end
def
has_tracing_license?
def
has_tracing_license?
project
.
feature_available?
(
:tracing
,
current_user
)
project
.
feature_available?
(
:tracing
,
current_user
)
end
end
...
...
ee/app/helpers/operations_helper.rb
View file @
6574f767
...
@@ -20,14 +20,14 @@ module OperationsHelper
...
@@ -20,14 +20,14 @@ module OperationsHelper
}
}
end
end
def
status_page_settings_data
(
status_page_setting
)
def
status_page_settings_data
{
{
'
user-can-enable-status-page'
=>
can?
(
current_user
,
:admin_operations
,
@project
).
to_s
,
'
operations-settings-endpoint'
=>
project_settings_operations_path
(
@project
)
,
'
setting-enabled'
=>
status_page_setting
&
.
enabled?
&
.
to_s
,
'
enabled'
=>
status_page_setting
.
enabled?
.
to_s
,
'
setting-aws-access-key'
=>
status_page_setting
&
.
aws_access_key
,
'
bucket-name'
=>
status_page_setting
.
aws_s3_bucket_name
,
'
setting-masked-aws-secret-key'
=>
status_page_setting
&
.
masked_aws_secret_key
,
'
region'
=>
status_page_setting
.
aws_region
,
'
setting-aws-region'
=>
status_page_setting
&
.
aws_region
,
'
aws-access-key'
=>
status_page_setting
.
aws_access_key
,
'
setting-aws-s3-bucket-name'
=>
status_page_setting
&
.
aws_s3_bucket_name
'
aws-secret-key'
=>
status_page_setting
.
masked_aws_secret_key
}
}
end
end
end
end
ee/app/models/status_page_setting.rb
View file @
6574f767
...
@@ -32,6 +32,8 @@ class StatusPageSetting < ApplicationRecord
...
@@ -32,6 +32,8 @@ class StatusPageSetting < ApplicationRecord
scope
:enabled
,
->
{
where
(
enabled:
true
)
}
scope
:enabled
,
->
{
where
(
enabled:
true
)
}
def
masked_aws_secret_key
def
masked_aws_secret_key
return
if
aws_secret_key
.
blank?
'*'
*
40
'*'
*
40
end
end
...
...
ee/app/views/projects/settings/operations/_status_page.html.haml
View file @
6574f767
-
return
unless
@project
.
feature_available?
(
:status_page
,
current_user
)
&&
@project
.
beta_feature_available?
(
:status_page
)
-
return
unless
@project
.
feature_available?
(
:status_page
,
current_user
)
&&
@project
.
beta_feature_available?
(
:status_page
)
-
setting
=
status_page_settings_data
(
@project
.
status_page_setting
)
.js-status-page-settings
{
data:
status_page_settings_data
}
.js-status-page-settings
{
data:
{
operations_settings_endpoint:
project_settings_operations_path
(
@project
),
enabled:
setting
[
'setting-enabled'
],
bucket_name:
setting
[
'setting-aws-s3-bucket-name'
],
region:
setting
[
'setting-aws-region'
],
aws_access_key:
setting
[
'setting-aws-access-key'
],
aws_secret_key:
setting
[
'setting-masked-aws-secret-key'
]
}
}
ee/spec/helpers/ee/operations_helper_spec.rb
View file @
6574f767
...
@@ -6,39 +6,27 @@ describe OperationsHelper do
...
@@ -6,39 +6,27 @@ describe OperationsHelper do
describe
'#status_page_settings_data'
do
describe
'#status_page_settings_data'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:private
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:private
)
}
let_it_be
(
:status_page_setting
)
{
project
.
build_status_page_setting
}
subject
{
helper
.
status_page_settings_data
(
status_page_setting
)
}
subject
{
helper
.
status_page_settings_data
}
before
do
before
do
helper
.
instance_variable_set
(
:@project
,
project
)
helper
.
instance_variable_set
(
:@project
,
project
)
allow
(
helper
).
to
receive
(
:status_page_setting
)
{
status_page_setting
}
allow
(
helper
).
to
receive
(
:current_user
)
{
user
}
allow
(
helper
).
to
receive
(
:current_user
)
{
user
}
allow
(
helper
)
allow
(
helper
)
.
to
receive
(
:can?
).
with
(
user
,
:admin_operations
,
project
)
{
true
}
.
to
receive
(
:can?
).
with
(
user
,
:admin_operations
,
project
)
{
true
}
end
end
context
'setting does not exist'
do
context
'setting does not exist'
do
let
(
:status_page_setting
)
{
nil
}
it
'returns the correct values'
do
expect
(
subject
.
keys
)
.
to
contain_exactly
(
'user-can-enable-status-page'
,
'setting-enabled'
,
'setting-aws-access-key'
,
'setting-masked-aws-secret-key'
,
'setting-aws-region'
,
'setting-aws-s3-bucket-name'
)
end
it
'returns the correct values'
do
it
'returns the correct values'
do
expect
(
subject
).
to
eq
(
expect
(
subject
).
to
eq
(
'
user-can-enable-status-page'
=>
'true'
,
'
operations-settings-endpoint'
=>
project_settings_operations_path
(
project
)
,
'
setting-enabled'
=>
nil
,
'
enabled'
=>
'false'
,
'
setting-
aws-access-key'
=>
nil
,
'aws-access-key'
=>
nil
,
'
setting-masked-
aws-secret-key'
=>
nil
,
'aws-secret-key'
=>
nil
,
'
setting-aws-
region'
=>
nil
,
'region'
=>
nil
,
'
setting-aws-s3-
bucket-name'
=>
nil
'bucket-name'
=>
nil
)
)
end
end
...
@@ -50,12 +38,12 @@ describe OperationsHelper do
...
@@ -50,12 +38,12 @@ describe OperationsHelper do
it
'returns the correct values'
do
it
'returns the correct values'
do
expect
(
subject
).
to
eq
(
expect
(
subject
).
to
eq
(
'
user-can-enable-status-page'
=>
'false'
,
'
operations-settings-endpoint'
=>
project_settings_operations_path
(
project
)
,
'
setting-enabled'
=>
nil
,
'
enabled'
=>
'false'
,
'
setting-
aws-access-key'
=>
nil
,
'aws-access-key'
=>
nil
,
'
setting-masked-
aws-secret-key'
=>
nil
,
'aws-secret-key'
=>
nil
,
'
setting-aws-
region'
=>
nil
,
'region'
=>
nil
,
'
setting-aws-s3-
bucket-name'
=>
nil
'bucket-name'
=>
nil
)
)
end
end
end
end
...
@@ -65,14 +53,14 @@ describe OperationsHelper do
...
@@ -65,14 +53,14 @@ describe OperationsHelper do
let
(
:status_page_setting
)
{
create
(
:status_page_setting
)
}
let
(
:status_page_setting
)
{
create
(
:status_page_setting
)
}
it
'returns the correct values'
do
it
'returns the correct values'
do
aggregate_failures
do
expect
(
subject
).
to
eq
(
expect
(
subject
[
'user-can-enable-status-page'
]).
to
eq
(
'true'
)
'operations-settings-endpoint'
=>
project_settings_operations_path
(
project
),
expect
(
subject
[
'setting-enabled'
]).
to
eq
(
status_page_setting
.
enabled
.
to_s
)
'enabled'
=>
status_page_setting
.
enabled
.
to_s
,
expect
(
subject
[
'setting-aws-access-key'
]).
to
eq
(
status_page_setting
.
aws_access_key
)
'aws-access-key'
=>
status_page_setting
.
aws_access_key
,
expect
(
subject
[
'setting-masked-aws-secret-key'
]).
to
eq
(
status_page_setting
.
masked_aws_secret_key
)
'aws-secret-key'
=>
status_page_setting
.
masked_aws_secret_key
,
expect
(
subject
[
'setting-aws-region'
]).
to
eq
(
status_page_setting
.
aws_region
)
'region'
=>
status_page_setting
.
aws_region
,
expect
(
subject
[
'setting-aws-s3-bucket-name'
]).
to
eq
(
status_page_setting
.
aws_s3_bucket_name
)
'bucket-name'
=>
status_page_setting
.
aws_s3_bucket_name
end
)
end
end
end
end
end
end
...
...
ee/spec/models/status_page_setting_spec.rb
View file @
6574f767
...
@@ -74,6 +74,20 @@ describe StatusPageSetting do
...
@@ -74,6 +74,20 @@ describe StatusPageSetting do
end
end
end
end
describe
'#masked_aws_secret_key'
do
let
(
:status_page_setting
)
{
build
(
:status_page_setting
)
}
subject
{
status_page_setting
.
masked_aws_secret_key
}
it
{
is_expected
.
to
eq
(
'*'
*
40
)
}
context
'when no secret saved'
do
let
(
:status_page_setting
)
{
build
(
:status_page_setting
,
aws_secret_key:
nil
)
}
it
{
is_expected
.
to
eq
(
nil
)
}
end
end
describe
'#enabled?'
do
describe
'#enabled?'
do
let
(
:status_page_setting
)
{
build
(
:status_page_setting
,
:enabled
)
}
let
(
:status_page_setting
)
{
build
(
:status_page_setting
,
:enabled
)
}
...
...
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