diff options
Diffstat (limited to 'spec/models/container_repository_spec.rb')
-rw-r--r-- | spec/models/container_repository_spec.rb | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/spec/models/container_repository_spec.rb b/spec/models/container_repository_spec.rb index da7b54644bd..e028a82ff76 100644 --- a/spec/models/container_repository_spec.rb +++ b/spec/models/container_repository_spec.rb @@ -528,6 +528,10 @@ RSpec.describe ContainerRepository, :aggregate_failures, feature_category: :cont describe '#each_tags_page' do let(:page_size) { 100 } + before do + allow(repository).to receive(:migrated?).and_return(true) + end + shared_examples 'iterating through a page' do |expected_tags: true| it 'iterates through one page' do expect(repository.gitlab_api_client).to receive(:tags) @@ -660,7 +664,7 @@ RSpec.describe ContainerRepository, :aggregate_failures, feature_category: :cont context 'calling on a non migrated repository' do before do - repository.update!(created_at: described_class::MIGRATION_PHASE_1_ENDED_AT - 3.days) + allow(repository).to receive(:migrated?).and_return(false) end it 'raises an Argument error' do @@ -795,6 +799,7 @@ RSpec.describe ContainerRepository, :aggregate_failures, feature_category: :cont freeze_time do expect { subject } .to change { repository.expiration_policy_started_at }.from(nil).to(Time.zone.now) + .and change { repository.expiration_policy_cleanup_status }.from('cleanup_unscheduled').to('cleanup_ongoing') .and change { repository.last_cleanup_deleted_tags_count }.from(10).to(nil) end end @@ -1236,6 +1241,8 @@ RSpec.describe ContainerRepository, :aggregate_failures, feature_category: :cont end before do + allow(group).to receive(:first_project_with_container_registry_tags).and_return(nil) + group.parent = test_group group.save! end @@ -1561,22 +1568,20 @@ RSpec.describe ContainerRepository, :aggregate_failures, feature_category: :cont describe '#migrated?' do subject { repository.migrated? } - it { is_expected.to eq(true) } - - context 'with a created_at older than phase 1 ends' do + context 'on gitlab.com' do before do - repository.update!(created_at: described_class::MIGRATION_PHASE_1_ENDED_AT - 3.days) + allow(::Gitlab).to receive(:com?).and_return(true) end - it { is_expected.to eq(false) } - - context 'with migration state set to import_done' do - before do - repository.update!(migration_state: 'import_done') - end + it { is_expected.to eq(true) } + end - it { is_expected.to eq(true) } + context 'not on gitlab.com' do + before do + allow(::Gitlab).to receive(:com?).and_return(false) end + + it { is_expected.to eq(false) } end end |