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
538a8ecc
Commit
538a8ecc
authored
Mar 05, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix helper and add more specs
parent
90e14fc5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
5 deletions
+23
-5
ee/app/helpers/operations_helper.rb
ee/app/helpers/operations_helper.rb
+2
-2
ee/spec/helpers/ee/operations_helper_spec.rb
ee/spec/helpers/ee/operations_helper_spec.rb
+21
-3
No files found.
ee/app/helpers/operations_helper.rb
View file @
538a8ecc
...
@@ -22,8 +22,8 @@ module OperationsHelper
...
@@ -22,8 +22,8 @@ module OperationsHelper
def
status_page_settings_data
(
status_page_setting
)
def
status_page_settings_data
(
status_page_setting
)
{
{
'user-can-enable-status-page'
=>
can?
(
current_user
,
:admin_operations
,
project
).
to_s
,
'user-can-enable-status-page'
=>
can?
(
current_user
,
:admin_operations
,
@
project
).
to_s
,
'setting-enabled'
=>
status_page_setting
&
.
enabled?
,
'setting-enabled'
=>
status_page_setting
&
.
enabled?
.
to_s
,
'setting-aws-access-key'
=>
status_page_setting
&
.
aws_access_key
,
'setting-aws-access-key'
=>
status_page_setting
&
.
aws_access_key
,
'setting-masked-aws-secret-key'
=>
status_page_setting
&
.
masked_aws_secret_key
,
'setting-masked-aws-secret-key'
=>
status_page_setting
&
.
masked_aws_secret_key
,
'setting-aws-region'
=>
status_page_setting
&
.
aws_region
,
'setting-aws-region'
=>
status_page_setting
&
.
aws_region
,
...
...
ee/spec/helpers/ee/operations_helper_spec.rb
View file @
538a8ecc
...
@@ -4,10 +4,16 @@ require 'spec_helper'
...
@@ -4,10 +4,16 @@ require 'spec_helper'
describe
OperationsHelper
do
describe
OperationsHelper
do
describe
'#status_page_settings_data'
do
describe
'#status_page_settings_data'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:private
)
}
subject
{
helper
.
status_page_settings_data
(
status_page_setting
)
}
subject
{
helper
.
status_page_settings_data
(
status_page_setting
)
}
before
do
before
do
allow
(
helper
).
to
receive
(
:can?
)
{
true
}
helper
.
instance_variable_set
(
:@project
,
project
)
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
helper
)
.
to
receive
(
:can?
).
with
(
user
,
:admin_operations
,
project
)
{
true
}
end
end
context
'setting does not exist'
do
context
'setting does not exist'
do
...
@@ -25,8 +31,19 @@ describe OperationsHelper do
...
@@ -25,8 +31,19 @@ describe OperationsHelper do
)
)
end
end
it
'returns nil for the values'
do
it
'returns nil or true for the values'
do
expect
(
subject
.
values
.
uniq
).
to
contain_exactly
(
nil
)
expect
(
subject
.
values
.
uniq
).
to
contain_exactly
(
'true'
,
nil
)
end
context
'user does not have permission'
do
before
do
allow
(
helper
)
.
to
receive
(
:can?
).
with
(
user
,
:admin_operations
,
project
)
{
false
}
end
it
'returns nil or true for the values'
do
expect
(
subject
.
values
.
uniq
).
to
contain_exactly
(
'false'
,
nil
)
end
end
end
end
end
...
@@ -35,6 +52,7 @@ describe OperationsHelper do
...
@@ -35,6 +52,7 @@ describe OperationsHelper do
it
'returns the correct values'
do
it
'returns the correct values'
do
aggregate_failures
do
aggregate_failures
do
expect
(
subject
[
'user-can-enable-status-page'
]).
to
eq
(
'true'
)
expect
(
subject
[
'setting-enabled'
]).
to
eq
(
status_page_setting
.
enabled
)
expect
(
subject
[
'setting-enabled'
]).
to
eq
(
status_page_setting
.
enabled
)
expect
(
subject
[
'setting-aws-access-key'
]).
to
eq
(
status_page_setting
.
aws_access_key
)
expect
(
subject
[
'setting-aws-access-key'
]).
to
eq
(
status_page_setting
.
aws_access_key
)
expect
(
subject
[
'setting-masked-aws-secret-key'
]).
to
eq
(
status_page_setting
.
masked_aws_secret_key
)
expect
(
subject
[
'setting-masked-aws-secret-key'
]).
to
eq
(
status_page_setting
.
masked_aws_secret_key
)
...
...
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