diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/services/namespaces/statistics_refresher_service_spec.rb | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/services/namespaces/statistics_refresher_service_spec.rb')
-rw-r--r-- | spec/services/namespaces/statistics_refresher_service_spec.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/services/namespaces/statistics_refresher_service_spec.rb b/spec/services/namespaces/statistics_refresher_service_spec.rb index d3379e843ec..2d5f9235bd4 100644 --- a/spec/services/namespaces/statistics_refresher_service_spec.rb +++ b/spec/services/namespaces/statistics_refresher_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Namespaces::StatisticsRefresherService, '#execute' do let(:group) { create(:group) } + let(:subgroup) { create(:group, parent: group) } let(:projects) { create_list(:project, 5, namespace: group) } let(:service) { described_class.new } @@ -23,6 +24,14 @@ RSpec.describe Namespaces::StatisticsRefresherService, '#execute' do service.execute(group) end + + context 'when given a subgroup' do + it 'does not create statistics for the subgroup' do + service.execute(subgroup) + + expect(subgroup.reload.root_storage_statistics).not_to be_present + end + end end context 'with a root storage statistics relation', :sidekiq_might_not_need_inline do @@ -43,6 +52,16 @@ RSpec.describe Namespaces::StatisticsRefresherService, '#execute' do service.execute(group) end + + context 'when given a subgroup' do + it "recalculates the root namespace's statistics" do + expect(Namespace::RootStorageStatistics) + .to receive(:safe_find_or_create_by!).with({ namespace_id: group.id }) + .and_return(group.root_storage_statistics) + + service.execute(subgroup) + end + end end context 'when something goes wrong' do |