Commit 326d2782 authored by Adam Hegyi's avatar Adam Hegyi

Fix passing filter params to VSA time summary

This MR fixes a bug where the issuable filter params were ignored.
parent 6ac20f41
---
title: Fix passing filter params to VSA time summary queries
merge_request: 36441
author:
type: fixed
......@@ -45,7 +45,7 @@ module Gitlab
to: @options[:to] || DateTime.now,
project_ids: @options[:projects],
current_user: @current_user
}
}.merge(@options.slice(*::Gitlab::Analytics::CycleAnalytics::RequestParams::FINDER_PARAM_NAMES))
)
end
end
......
......@@ -8,14 +8,63 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::GroupStageTimeSummary do
let_it_be(:user) { create(:user, :admin) }
let(:from) { 1.day.ago }
let(:to) { nil }
let(:options) { { from: from, to: to, current_user: user } }
subject { described_class.new(group, options: { from: from, to: to, current_user: user }).data }
subject { described_class.new(group, options: options).data }
around do |example|
Timecop.freeze { example.run }
end
describe '#lead_time' do
describe 'issuable filter parameters' do
let_it_be(:label) { create(:group_label, group: group) }
before do
create(:closed_issue, project: project, created_at: 1.day.ago, closed_at: Time.zone.now, author: user, labels: [label])
end
context 'when `author_username` is given' do
before do
options[:author_username] = user.username
end
it 'returns the correct lead time' do
expect(subject.first[:value]).to eq('1.0')
end
end
context 'when unknown `author_username` is given' do
before do
options[:author_username] = 'unknown_user'
end
it 'returns `-`' do
expect(subject.first[:value]).to eq('-')
end
end
context 'when `label_name` is given' do
before do
options[:label_name] = [label.name]
end
it 'returns the correct lead time' do
expect(subject.first[:value]).to eq('1.0')
end
end
context 'when unknown `label_name` is given' do
before do
options[:label_name] = ['unknown_label']
end
it 'returns `-`' do
expect(subject.first[:value]).to eq('-')
end
end
end
context 'with `from` date' do
let(:from) { 6.days.ago }
......
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