diff options
Diffstat (limited to 'spec/models/packages/nuget/symbol_spec.rb')
-rw-r--r-- | spec/models/packages/nuget/symbol_spec.rb | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/spec/models/packages/nuget/symbol_spec.rb b/spec/models/packages/nuget/symbol_spec.rb index f43f3a3bdeb..bae8f90c7d5 100644 --- a/spec/models/packages/nuget/symbol_spec.rb +++ b/spec/models/packages/nuget/symbol_spec.rb @@ -7,6 +7,7 @@ RSpec.describe Packages::Nuget::Symbol, type: :model, feature_category: :package it { is_expected.to be_a FileStoreMounter } it { is_expected.to be_a ShaAttribute } + it { is_expected.to be_a Packages::Destructible } describe 'relationships' do it { is_expected.to belong_to(:package).inverse_of(:nuget_symbols) } @@ -26,6 +27,63 @@ RSpec.describe Packages::Nuget::Symbol, type: :model, feature_category: :package it { is_expected.to delegate_method(:project_id).to(:package) } end + describe 'scopes' do + describe '.stale' do + subject { described_class.stale } + + let_it_be(:symbol) { create(:nuget_symbol) } + let_it_be(:stale_symbol) { create(:nuget_symbol, :stale) } + + it { is_expected.to contain_exactly(stale_symbol) } + end + + describe '.pending_destruction' do + subject { described_class.pending_destruction } + + let_it_be(:symbol) { create(:nuget_symbol, :stale, :processing) } + let_it_be(:stale_symbol) { create(:nuget_symbol, :stale) } + + it { is_expected.to contain_exactly(stale_symbol) } + end + + describe '.with_signature' do + subject(:with_signature) { described_class.with_signature(signature) } + + let_it_be(:signature) { 'signature' } + let_it_be(:symbol) { create(:nuget_symbol, signature: signature) } + + it 'returns symbols with the given signature' do + expect(with_signature).to eq([symbol]) + end + end + + describe '.with_file_name' do + subject(:with_file_name) { described_class.with_file_name(file_name) } + + let_it_be(:file_name) { 'file_name' } + let_it_be(:symbol) { create(:nuget_symbol) } + + before do + symbol.update_column(:file, file_name) + end + + it 'returns symbols with the given file_name' do + expect(with_file_name).to eq([symbol]) + end + end + + describe '.with_file_sha256' do + subject(:with_file_sha256) { described_class.with_file_sha256(checksums) } + + let_it_be(:checksums) { OpenSSL::Digest.hexdigest('SHA256', 'checksums') } + let_it_be(:symbol) { create(:nuget_symbol, file_sha256: checksums) } + + it 'returns symbols with the given checksums' do + expect(with_file_sha256).to eq([symbol]) + end + end + end + describe 'callbacks' do describe 'before_validation' do describe '#set_object_storage_key' do |