diff options
Diffstat (limited to 'spec/models/namespace')
-rw-r--r-- | spec/models/namespace/aggregation_schedule_spec.rb | 26 | ||||
-rw-r--r-- | spec/models/namespace/package_setting_spec.rb | 9 |
2 files changed, 30 insertions, 5 deletions
diff --git a/spec/models/namespace/aggregation_schedule_spec.rb b/spec/models/namespace/aggregation_schedule_spec.rb index 38bf8089411..45b66fa12dd 100644 --- a/spec/models/namespace/aggregation_schedule_spec.rb +++ b/spec/models/namespace/aggregation_schedule_spec.rb @@ -5,8 +5,24 @@ require 'spec_helper' RSpec.describe Namespace::AggregationSchedule, :clean_gitlab_redis_shared_state, type: :model do include ExclusiveLeaseHelpers + let(:default_timeout) { described_class.default_lease_timeout } + it { is_expected.to belong_to :namespace } + describe "#default_lease_timeout" do + subject(:default_lease_timeout) { default_timeout } + + it { is_expected.to eq 30.minutes.to_i } + + context 'when remove_namespace_aggregator_delay FF is disabled' do + before do + stub_feature_flags(remove_namespace_aggregator_delay: false) + end + + it { is_expected.to eq 1.hour.to_i } + end + end + describe '#schedule_root_storage_statistics' do let(:namespace) { create(:namespace) } let(:aggregation_schedule) { namespace.build_aggregation_schedule } @@ -14,7 +30,7 @@ RSpec.describe Namespace::AggregationSchedule, :clean_gitlab_redis_shared_state, context "when we can't obtain the lease" do it 'does not schedule the workers' do - stub_exclusive_lease_taken(lease_key, timeout: described_class::DEFAULT_LEASE_TIMEOUT) + stub_exclusive_lease_taken(lease_key, timeout: default_timeout) expect(Namespaces::RootStatisticsWorker) .not_to receive(:perform_async) @@ -28,20 +44,20 @@ RSpec.describe Namespace::AggregationSchedule, :clean_gitlab_redis_shared_state, context 'when we can obtain the lease' do it 'schedules a root storage statistics after create' do - stub_exclusive_lease(lease_key, timeout: described_class::DEFAULT_LEASE_TIMEOUT) + stub_exclusive_lease(lease_key, timeout: default_timeout) expect(Namespaces::RootStatisticsWorker) .to receive(:perform_async).once expect(Namespaces::RootStatisticsWorker) .to receive(:perform_in).once - .with(described_class::DEFAULT_LEASE_TIMEOUT, aggregation_schedule.namespace_id) + .with(default_timeout, aggregation_schedule.namespace_id) aggregation_schedule.save! end it 'does not release the lease' do - stub_exclusive_lease(lease_key, timeout: described_class::DEFAULT_LEASE_TIMEOUT) + stub_exclusive_lease(lease_key, timeout: default_timeout) aggregation_schedule.save! @@ -58,7 +74,7 @@ RSpec.describe Namespace::AggregationSchedule, :clean_gitlab_redis_shared_state, expect(Namespaces::RootStatisticsWorker) .to receive(:perform_in).once - .with(described_class::DEFAULT_LEASE_TIMEOUT, aggregation_schedule.namespace_id) + .with(default_timeout, aggregation_schedule.namespace_id) .and_return(nil) # Scheduling workers for the first time diff --git a/spec/models/namespace/package_setting_spec.rb b/spec/models/namespace/package_setting_spec.rb index 4308c8c06bc..2584fa597ad 100644 --- a/spec/models/namespace/package_setting_spec.rb +++ b/spec/models/namespace/package_setting_spec.rb @@ -85,4 +85,13 @@ RSpec.describe Namespace::PackageSetting do end end end + + describe 'package forwarding attributes' do + %i[maven_package_requests_forwarding + pypi_package_requests_forwarding + npm_package_requests_forwarding].each do |attribute| + it_behaves_like 'a cascading namespace setting boolean attribute', settings_attribute_name: attribute, + settings_association: :package_settings + end + end end |