2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe AnalyticsSummarySerializer do
|
2017-08-17 22:00:37 +05:30
|
|
|
subject do
|
|
|
|
described_class.new.represent(resource)
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project) { create(:project) }
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
let(:resource) do
|
|
|
|
Gitlab::CycleAnalytics::Summary::Issue
|
2021-09-04 01:27:46 +05:30
|
|
|
.new(project: double, options: { from: 1.day.ago }, current_user: user)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
2020-01-01 13:55:28 +05:30
|
|
|
allow_next_instance_of(Gitlab::CycleAnalytics::Summary::Issue) do |instance|
|
|
|
|
allow(instance).to receive(:value).and_return(1.12)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
it 'generates payload for single object' do
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(subject).to be_kind_of Hash
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains important elements of AnalyticsStage' do
|
|
|
|
expect(subject).to include(:title, :value)
|
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
it 'does not include unit' do
|
|
|
|
expect(subject).not_to include(:unit)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when representing with unit' do
|
|
|
|
let(:resource) do
|
|
|
|
Gitlab::CycleAnalytics::Summary::DeploymentFrequency
|
2021-09-04 01:27:46 +05:30
|
|
|
.new(deployments: 10, options: { from: 1.day.ago })
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
subject { described_class.new.represent(resource, with_unit: true) }
|
|
|
|
|
|
|
|
it 'contains unit' do
|
|
|
|
expect(subject).to include(:unit)
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|