debian-mirror-gitlab/spec/requests/api/graphql/usage_trends_measurements_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
1.3 KiB
Ruby
Raw Normal View History

2020-11-24 15:15:51 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'UsageTrendsMeasurements', feature_category: :devops_reports do
2020-11-24 15:15:51 +05:30
include GraphqlHelpers
let(:current_user) { create(:user, :admin) }
2021-04-17 20:07:23 +05:30
let!(:usage_trends_measurement_1) { create(:usage_trends_measurement, :project_count, recorded_at: 20.days.ago, count: 5) }
let!(:usage_trends_measurement_2) { create(:usage_trends_measurement, :project_count, recorded_at: 10.days.ago, count: 10) }
2020-11-24 15:15:51 +05:30
2021-01-29 00:20:46 +05:30
let(:arguments) { 'identifier: PROJECTS' }
2021-04-17 20:07:23 +05:30
let(:query) { graphql_query_for(:UsageTrendsMeasurements, arguments, 'nodes { count identifier }') }
2020-11-24 15:15:51 +05:30
before do
post_graphql(query, current_user: current_user)
end
it 'returns measurement objects' do
2022-11-25 23:54:43 +05:30
expect(graphql_data.dig('usageTrendsMeasurements', 'nodes')).to eq(
[
{ "count" => 10, 'identifier' => 'PROJECTS' },
{ "count" => 5, 'identifier' => 'PROJECTS' }
])
2020-11-24 15:15:51 +05:30
end
2021-01-29 00:20:46 +05:30
context 'with recorded_at filters' do
2022-11-25 23:54:43 +05:30
let(:arguments) do
%(identifier: PROJECTS,
recordedAfter: "#{15.days.ago.to_date}",
recordedBefore: "#{5.days.ago.to_date}")
end
2021-01-29 00:20:46 +05:30
it 'returns filtered measurement objects' do
2022-11-25 23:54:43 +05:30
expect(graphql_data.dig('usageTrendsMeasurements', 'nodes')).to eq(
[
{ "count" => 10, 'identifier' => 'PROJECTS' }
])
2021-01-29 00:20:46 +05:30
end
end
2020-11-24 15:15:51 +05:30
end