diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/models/packages/package_file_spec.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/models/packages/package_file_spec.rb')
-rw-r--r-- | spec/models/packages/package_file_spec.rb | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/spec/models/packages/package_file_spec.rb b/spec/models/packages/package_file_spec.rb index 7758ed4a500..7cc8e13d449 100644 --- a/spec/models/packages/package_file_spec.rb +++ b/spec/models/packages/package_file_spec.rb @@ -32,11 +32,17 @@ RSpec.describe Packages::PackageFile, type: :model do end end - it_behaves_like 'UpdateProjectStatistics' do - subject { build(:package_file, :jar, size: 42) } + context 'updating project statistics' do + context 'when the package file has an explicit size' do + it_behaves_like 'UpdateProjectStatistics' do + subject { build(:package_file, :jar, size: 42) } + end + end - before do - allow_any_instance_of(Packages::PackageFileUploader).to receive(:size).and_return(42) + context 'when the package file does not have a size' do + it_behaves_like 'UpdateProjectStatistics' do + subject { build(:package_file, size: nil) } + end end end @@ -52,7 +58,7 @@ RSpec.describe Packages::PackageFile, type: :model do end describe '#update_file_metadata callback' do - let_it_be(:package_file) { build(:package_file, :nuget, file_store: nil, size: nil) } + let_it_be(:package_file) { build(:package_file, :nuget, size: nil) } subject { package_file.save! } @@ -61,9 +67,14 @@ RSpec.describe Packages::PackageFile, type: :model do .to receive(:update_file_metadata) .and_call_original - expect { subject } - .to change { package_file.file_store }.from(nil).to(::Packages::PackageFileUploader::Store::LOCAL) - .and change { package_file.size }.from(nil).to(3513) + # This expectation uses a stub because we can no longer test a change from + # `nil` to `1`, because the field is no longer nullable, and it defaults + # to `1`. + expect(package_file) + .to receive(:update_column) + .with(:file_store, ::Packages::PackageFileUploader::Store::LOCAL) + + expect { subject }.to change { package_file.size }.from(nil).to(3513) end end end |