From 2f57eee7dabd10ebd31afd30dbfd6f4752135859 Mon Sep 17 00:00:00 2001
From: Timothy Andrew <mail@timothyandrew.net>
Date: Fri, 26 Aug 2016 16:24:30 +0530
Subject: [PATCH] Authorize access to cycle analytics.

All users with "Reporter" access (and above) to a project can see the
Cycle Analytics page.
---
 app/controllers/projects/cycle_analytics_controller.rb | 2 ++
 app/models/ability.rb                                  | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/app/controllers/projects/cycle_analytics_controller.rb b/app/controllers/projects/cycle_analytics_controller.rb
index 002a71b593d..68cc79fb166 100644
--- a/app/controllers/projects/cycle_analytics_controller.rb
+++ b/app/controllers/projects/cycle_analytics_controller.rb
@@ -1,4 +1,6 @@
 class Projects::CycleAnalyticsController < Projects::ApplicationController
+  before_action :authorize_read_cycle_analytics!
+
   def show
     @cycle_analytics = CycleAnalytics.new(@project, from: parse_start_date)
   end
diff --git a/app/models/ability.rb b/app/models/ability.rb
index a49dd703926..5293be33e5a 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -265,7 +265,8 @@ class Ability
         :read_container_image,
         :read_pipeline,
         :read_environment,
-        :read_deployment
+        :read_deployment,
+        :read_cycle_analytics
       ]
     end
 
-- 
GitLab