diff options
author | Rémy Coutable <remy@rymai.me> | 2019-09-02 11:43:21 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2019-09-02 11:43:21 +0300 |
commit | b7398bc1fdad6c721cfa35ff17cebc2cb00c8240 (patch) | |
tree | 48592d3a9f6d495b8b47b31c60dfa6eb17a00bb2 /app | |
parent | d6de7c65500b73f2e7f899e0c0a224aafca3d4d1 (diff) | |
parent | c2452db59cf045f01244b8d72e14cb0144d19722 (diff) |
Merge branch 'fix-peek-on-puma' into 'master'
Fix Peek on Puma
Closes #66528
See merge request gitlab-org/gitlab-ce!32213
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/concerns/with_performance_bar.rb | 16 | ||||
-rw-r--r-- | app/helpers/performance_bar_helper.rb | 4 | ||||
-rw-r--r-- | app/views/peek/_bar.html.haml | 4 |
3 files changed, 16 insertions, 8 deletions
diff --git a/app/controllers/concerns/with_performance_bar.rb b/app/controllers/concerns/with_performance_bar.rb index 4e0ae3c59eb..93ded59900d 100644 --- a/app/controllers/concerns/with_performance_bar.rb +++ b/app/controllers/concerns/with_performance_bar.rb @@ -3,15 +3,25 @@ module WithPerformanceBar extend ActiveSupport::Concern - def peek_enabled? - return false unless Gitlab::PerformanceBar.enabled?(current_user) + included do + before_action :set_peek_enabled_for_current_request + end + + private + def set_peek_enabled_for_current_request Gitlab::SafeRequestStore.fetch(:peek_enabled) { cookie_or_default_value } end - private + # Needed for Peek's routing to work; + # Peek::ResultsController#restrict_non_access calls this method. + def peek_enabled? + Gitlab::PerformanceBar.enabled_for_request? + end def cookie_or_default_value + return false unless Gitlab::PerformanceBar.enabled_for_user?(current_user) + if cookies[:perf_bar_enabled].present? cookies[:perf_bar_enabled] == 'true' else diff --git a/app/helpers/performance_bar_helper.rb b/app/helpers/performance_bar_helper.rb index 7518cec160c..b225e4206a9 100644 --- a/app/helpers/performance_bar_helper.rb +++ b/app/helpers/performance_bar_helper.rb @@ -1,9 +1,7 @@ # frozen_string_literal: true 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? + Gitlab::PerformanceBar.enabled_for_request? end end diff --git a/app/views/peek/_bar.html.haml b/app/views/peek/_bar.html.haml index 5228930293c..9725f640be9 100644 --- a/app/views/peek/_bar.html.haml +++ b/app/views/peek/_bar.html.haml @@ -1,6 +1,6 @@ -- return unless peek_enabled? +- return unless performance_bar_enabled? #js-peek{ data: { env: Peek.env, - request_id: Peek.request_id, + request_id: peek_request_id, peek_url: "#{peek_routes_path}/results" }, class: Peek.env } |