Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 10:33:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 10:33:21 +0300
commit36a59d088eca61b834191dacea009677a96c052f (patch)
treee4f33972dab5d8ef79e3944a9f403035fceea43f /spec/models/raw_usage_data_spec.rb
parenta1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff)
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/models/raw_usage_data_spec.rb')
-rw-r--r--spec/models/raw_usage_data_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/models/raw_usage_data_spec.rb b/spec/models/raw_usage_data_spec.rb
index 6ff4c6eb19b..95b98279a27 100644
--- a/spec/models/raw_usage_data_spec.rb
+++ b/spec/models/raw_usage_data_spec.rb
@@ -3,6 +3,31 @@
require 'spec_helper'
RSpec.describe RawUsageData do
+ context 'scopes' do
+ describe '.for_current_reporting_cycle' do
+ subject(:recent_service_ping_reports) { described_class.for_current_reporting_cycle }
+
+ before_all do
+ create(:raw_usage_data, created_at: (described_class::REPORTING_CADENCE + 1.day).ago)
+ end
+
+ it 'returns nil where no records match filter criteria' do
+ expect(recent_service_ping_reports).to be_empty
+ end
+
+ context 'with records matching filtering criteria' do
+ let_it_be(:fresh_record) { create(:raw_usage_data) }
+ let_it_be(:record_at_edge_of_time_range) do
+ create(:raw_usage_data, created_at: described_class::REPORTING_CADENCE.ago)
+ end
+
+ it 'return records within reporting cycle time range ordered by creation time' do
+ expect(recent_service_ping_reports).to eq [fresh_record, record_at_edge_of_time_range]
+ end
+ end
+ end
+ end
+
describe 'validations' do
it { is_expected.to validate_presence_of(:payload) }
it { is_expected.to validate_presence_of(:recorded_at) }