diff options
Diffstat (limited to 'spec/models/packages')
-rw-r--r-- | spec/models/packages/package_file_spec.rb | 22 | ||||
-rw-r--r-- | spec/models/packages/package_spec.rb | 4 |
2 files changed, 24 insertions, 2 deletions
diff --git a/spec/models/packages/package_file_spec.rb b/spec/models/packages/package_file_spec.rb index fd453d8e5a9..f6af8f6a951 100644 --- a/spec/models/packages/package_file_spec.rb +++ b/spec/models/packages/package_file_spec.rb @@ -23,6 +23,28 @@ RSpec.describe Packages::PackageFile, type: :model do describe 'validations' do it { is_expected.to validate_presence_of(:package) } + + context 'with pypi package' do + let_it_be(:package) { create(:pypi_package) } + + let(:package_file) { package.package_files.first } + let(:status) { :default } + let(:file) { fixture_file_upload('spec/fixtures/dk.png') } + + subject { package.package_files.create!(file: file, file_name: package_file.file_name, status: status) } + + it 'can not save a duplicated file' do + expect { subject }.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: File name has already been taken") + end + + context 'with a pending destruction package duplicated file' do + let(:status) { :pending_destruction } + + it 'can save it' do + expect { subject }.to change { package.package_files.count }.from(1).to(2) + end + end + end end context 'with package filenames' do diff --git a/spec/models/packages/package_spec.rb b/spec/models/packages/package_spec.rb index 52ed52de193..6c86db1197f 100644 --- a/spec/models/packages/package_spec.rb +++ b/spec/models/packages/package_spec.rb @@ -1021,13 +1021,13 @@ RSpec.describe Packages::Package, type: :model do context 'ascending direction' do let(:direction) { :asc } - it { is_expected.to eq('projects.name asc NULLS LAST, "packages_packages"."id" ASC') } + it { is_expected.to eq('"projects"."name" ASC NULLS LAST, "packages_packages"."id" ASC') } end context 'descending direction' do let(:direction) { :desc } - it { is_expected.to eq('projects.name desc NULLS FIRST, "packages_packages"."id" DESC') } + it { is_expected.to eq('"projects"."name" DESC NULLS FIRST, "packages_packages"."id" DESC') } end end end |