Commit 3206fa5b authored by Heinrich Lee Yu's avatar Heinrich Lee Yu Committed by Eugenia Grieff

Fix update project statistic specs

These specs require an already persisted project for the statistics
to be reloaded or updated
parent 81ff89a6
......@@ -20,7 +20,9 @@ RSpec.describe Ci::JobArtifact do
it_behaves_like 'having unique enum values'
it_behaves_like 'UpdateProjectStatistics' do
subject { build(:ci_job_artifact, :archive, size: 107464) }
let_it_be(:job, reload: true) { create(:ci_build) }
subject { build(:ci_job_artifact, :archive, job: job, size: 107464) }
end
describe '.not_expired' do
......
......@@ -13,7 +13,9 @@ RSpec.describe Ci::PipelineArtifact, type: :model do
it_behaves_like 'having unique enum values'
it_behaves_like 'UpdateProjectStatistics' do
subject { build(:ci_pipeline_artifact) }
let_it_be(:pipeline, reload: true) { create(:ci_pipeline) }
subject { build(:ci_pipeline_artifact, pipeline: pipeline) }
end
describe 'validations' do
......
......@@ -33,15 +33,17 @@ RSpec.describe Packages::PackageFile, type: :model do
end
context 'updating project statistics' do
let_it_be(:package, reload: true) { create(:package) }
context 'when the package file has an explicit size' do
it_behaves_like 'UpdateProjectStatistics' do
subject { build(:package_file, :jar, size: 42) }
subject { build(:package_file, :jar, package: package, size: 42) }
end
end
context 'when the package file does not have a size' do
it_behaves_like 'UpdateProjectStatistics' do
subject { build(:package_file, size: nil) }
subject { build(:package_file, package: package, size: nil) }
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