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
cdc1179f
Commit
cdc1179f
authored
Jul 03, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve feature flag check for the performance bar
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
19b8d8af
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
7 deletions
+37
-7
app/controllers/concerns/with_performance_bar.rb
app/controllers/concerns/with_performance_bar.rb
+0
-2
app/helpers/performance_bar_helper.rb
app/helpers/performance_bar_helper.rb
+7
-0
config/gitlab.yml.example
config/gitlab.yml.example
+1
-1
lib/feature.rb
lib/feature.rb
+3
-1
lib/gitlab/performance_bar.rb
lib/gitlab/performance_bar.rb
+2
-2
spec/lib/gitlab/performance_bar_spec.rb
spec/lib/gitlab/performance_bar_spec.rb
+24
-1
No files found.
app/controllers/concerns/with_performance_bar.rb
View file @
cdc1179f
...
@@ -3,8 +3,6 @@ module WithPerformanceBar
...
@@ -3,8 +3,6 @@ module WithPerformanceBar
included
do
included
do
include
Peek
::
Rblineprof
::
CustomControllerHelpers
include
Peek
::
Rblineprof
::
CustomControllerHelpers
alias_method
:performance_bar_enabled?
,
:peek_enabled?
helper_method
:performance_bar_enabled?
end
end
def
peek_enabled?
def
peek_enabled?
...
...
app/helpers/performance_bar_helper.rb
0 → 100644
View file @
cdc1179f
module
PerformanceBarHelper
# This is a hack since using `alias_method :performance_bar_enabled?, :peek_enabled?`
# in WithPerformanceBar breaks tests (but works in the browser).
def
performance_bar_enabled?
peek_enabled?
end
end
config/gitlab.yml.example
View file @
cdc1179f
...
@@ -462,7 +462,7 @@ production: &base
...
@@ -462,7 +462,7 @@ production: &base
# Performance bar settings
# Performance bar settings
performance_bar:
performance_bar:
# This setting controls what group can see the performance bar.
# This setting controls what group can see the performance bar.
# allowed_group: performance-group
# allowed_group:
my-org/
performance-group
#
#
# 4. Advanced settings
# 4. Advanced settings
...
...
lib/feature.rb
View file @
cdc1179f
...
@@ -60,7 +60,9 @@ class Feature
...
@@ -60,7 +60,9 @@ class Feature
def
register_feature_groups
def
register_feature_groups
Flipper
.
register
(
:performance_team
)
do
|
actor
|
Flipper
.
register
(
:performance_team
)
do
|
actor
|
actor
.
thing
&
.
is_a?
(
User
)
&&
Gitlab
::
PerformanceBar
.
allowed_user?
(
actor
.
thing
)
user
=
actor
.
thing
user
&
.
is_a?
(
User
)
&&
Gitlab
::
PerformanceBar
.
allowed_user?
(
user
)
end
end
end
end
end
end
...
...
lib/gitlab/performance_bar.rb
View file @
cdc1179f
...
@@ -21,10 +21,10 @@ module Gitlab
...
@@ -21,10 +21,10 @@ module Gitlab
if
RequestStore
.
active?
if
RequestStore
.
active?
RequestStore
.
fetch
(
'performance_bar:allowed_group'
)
do
RequestStore
.
fetch
(
'performance_bar:allowed_group'
)
do
Group
.
by
_path
(
Gitlab
.
config
.
performance_bar
.
allowed_group
)
Group
.
find_by_full
_path
(
Gitlab
.
config
.
performance_bar
.
allowed_group
)
end
end
else
else
Group
.
by
_path
(
Gitlab
.
config
.
performance_bar
.
allowed_group
)
Group
.
find_by_full
_path
(
Gitlab
.
config
.
performance_bar
.
allowed_group
)
end
end
end
end
...
...
spec/lib/gitlab/performance_bar_spec.rb
View file @
cdc1179f
...
@@ -74,10 +74,33 @@ describe Gitlab::PerformanceBar do
...
@@ -74,10 +74,33 @@ describe Gitlab::PerformanceBar do
let!
(
:my_group
)
{
create
(
:group
,
path:
'my-group'
)
}
let!
(
:my_group
)
{
create
(
:group
,
path:
'my-group'
)
}
context
'when user is not a member of the allowed group'
do
context
'when user is not a member of the allowed group'
do
it
'returns
false
'
do
it
'returns
the group
'
do
expect
(
described_class
.
allowed_group
).
to
eq
(
my_group
)
expect
(
described_class
.
allowed_group
).
to
eq
(
my_group
)
end
end
end
end
end
end
context
'when allowed group is nested'
,
:nested_groups
do
let!
(
:nested_my_group
)
{
create
(
:group
,
parent:
create
(
:group
,
path:
'my-org'
),
path:
'my-group'
)
}
before
do
create
(
:group
,
path:
'my-group'
)
stub_performance_bar_setting
(
allowed_group:
'my-org/my-group'
)
end
it
'returns the nested group'
do
expect
(
described_class
.
allowed_group
).
to
eq
(
nested_my_group
)
end
end
context
'when a nested group has the same path'
,
:nested_groups
do
before
do
create
(
:group
,
:nested
,
path:
'my-group'
)
end
it
'returns false'
do
expect
(
described_class
.
allowed_group
).
to
be_falsy
end
end
end
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