Commit 5d61f9af authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ)

Merge branch 'am-improve-usage-data-system_usage_data_monthly-specs' into 'master'

Improve usage_data monthly specs

See merge request gitlab-org/gitlab!46111
parents 23dbbddb dde06370
...@@ -591,9 +591,21 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -591,9 +591,21 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
describe '.system_usage_data_monthly' do describe '.system_usage_data_monthly' do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let!(:ud) { build(:usage_data) }
before do before do
project = create(:project)
env = create(:environment)
create(:package, project: project, created_at: 3.days.ago)
create(:package, created_at: 2.months.ago, project: project)
[3, 31].each do |n|
deployment_options = { created_at: n.days.ago, project: env.project, environment: env }
create(:deployment, :failed, deployment_options)
create(:deployment, :success, deployment_options)
create(:project_snippet, project: project, created_at: n.days.ago)
create(:personal_snippet, created_at: n.days.ago)
end
stub_application_setting(self_monitoring_project: project) stub_application_setting(self_monitoring_project: project)
for_defined_days_back do for_defined_days_back do
...@@ -609,10 +621,10 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -609,10 +621,10 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
expect(counts_monthly[:deployments]).to eq(2) expect(counts_monthly[:deployments]).to eq(2)
expect(counts_monthly[:successful_deployments]).to eq(1) expect(counts_monthly[:successful_deployments]).to eq(1)
expect(counts_monthly[:failed_deployments]).to eq(1) expect(counts_monthly[:failed_deployments]).to eq(1)
expect(counts_monthly[:snippets]).to eq(3) expect(counts_monthly[:snippets]).to eq(2)
expect(counts_monthly[:personal_snippets]).to eq(1) expect(counts_monthly[:personal_snippets]).to eq(1)
expect(counts_monthly[:project_snippets]).to eq(2) expect(counts_monthly[:project_snippets]).to eq(1)
expect(counts_monthly[:packages]).to eq(3) expect(counts_monthly[:packages]).to eq(1)
expect(counts_monthly[:promoted_issues]).to eq(1) expect(counts_monthly[:promoted_issues]).to eq(1)
end 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