diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/services/packages/create_package_file_service_spec.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/services/packages/create_package_file_service_spec.rb')
-rw-r--r-- | spec/services/packages/create_package_file_service_spec.rb | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/spec/services/packages/create_package_file_service_spec.rb b/spec/services/packages/create_package_file_service_spec.rb index 93dde54916a..12fd1039d30 100644 --- a/spec/services/packages/create_package_file_service_spec.rb +++ b/spec/services/packages/create_package_file_service_spec.rb @@ -2,7 +2,10 @@ require 'spec_helper' RSpec.describe Packages::CreatePackageFileService do - let(:package) { create(:maven_package) } + let_it_be(:package) { create(:maven_package) } + let_it_be(:user) { create(:user) } + + subject { described_class.new(package, params) } describe '#execute' do context 'with valid params' do @@ -14,7 +17,7 @@ RSpec.describe Packages::CreatePackageFileService do end it 'creates a new package file' do - package_file = described_class.new(package, params).execute + package_file = subject.execute expect(package_file).to be_valid expect(package_file.file_name).to eq('foo.jar') @@ -29,9 +32,17 @@ RSpec.describe Packages::CreatePackageFileService do end it 'raises an error' do - service = described_class.new(package, params) + expect { subject.execute }.to raise_error(ActiveRecord::RecordInvalid) + end + end + + context 'with a build' do + let_it_be(:pipeline) { create(:ci_pipeline, user: user) } + let(:build) { double('build', pipeline: pipeline) } + let(:params) { { file: Tempfile.new, file_name: 'foo.jar', build: build } } - expect { service.execute }.to raise_error(ActiveRecord::RecordInvalid) + it 'creates a build_info' do + expect { subject.execute }.to change { Packages::PackageFileBuildInfo.count }.by(1) end end end |