Commit a9310972 authored by Nikola Milojevic's avatar Nikola Milojevic

Merge branch '344802-fix-vsa-summary-endpoint-ff-scoping' into 'master'

Fix VSA FF scope to groups

See merge request gitlab-org/gitlab!76436
parents 037420e3 6740701a
......@@ -4,6 +4,7 @@ module Groups
module Analytics
module CycleAnalytics
class SummaryController < Groups::Analytics::ApplicationController
extend ::Gitlab::Utils::Override
include CycleAnalyticsParams
before_action :load_group
......@@ -27,6 +28,11 @@ module Groups
def authorize_access
return render_403 unless can?(current_user, :read_group_cycle_analytics, @group)
end
override :all_cycle_analytics_params
def all_cycle_analytics_params
super.merge({ group: @group })
end
end
end
end
......
......@@ -19,6 +19,8 @@ module Analytics
@cursor = cursor
@updated_at_before = updated_at_before
@upsert_count = 0
load_stages # ensure stages are loaded/created
end
def execute
......@@ -54,7 +56,7 @@ module Analytics
private
attr_reader :group, :model, :cursor, :updated_at_before, :upsert_count
attr_reader :group, :model, :cursor, :updated_at_before, :upsert_count, :stages
def error(error_reason)
ServiceResponse.error(
......@@ -172,8 +174,8 @@ module Analytics
"column_" + event.hash_code[0...10]
end
def stages
@stages ||= Gitlab::Analytics::CycleAnalytics::DistinctStageLoader
def load_stages
@stages ||= ::Gitlab::Analytics::CycleAnalytics::DistinctStageLoader
.new(group: group)
.stages
.select { |stage| stage.start_event.object_type == model }
......
......@@ -48,5 +48,25 @@ RSpec.describe Groups::Analytics::CycleAnalytics::SummaryController do
subject { get :time_summary, params: params }
it_behaves_like 'summary endpoint'
it 'passes the group to RequestParams' do
expect_next_instance_of(Gitlab::Analytics::CycleAnalytics::RequestParams) do |instance|
expect(instance.group).to eq(group)
end
subject
end
it 'uses the aggregated VSA data collector' do
# Ensure stage_hash_id is present for Lead Time and CycleTime
Analytics::CycleAnalytics::DataLoaderService.new(group: group, model: Issue).execute
# Calculating Cycle Time and Lead Time
expect(Gitlab::Analytics::CycleAnalytics::Aggregated::DataCollector).to receive(:new).twice.and_call_original
subject
expect(response).to be_successful
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment