diff options
author | Alessio Caiazza <acaiazza@gitlab.com> | 2019-08-22 22:08:28 +0000 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2019-08-22 22:08:28 +0000 |
commit | 606a1d2d31aff69ddabe7e3794f61f3e778da3e8 (patch) | |
tree | bfaee792fd551070a3581c77bc52164610f03b2a /spec/models/namespace | |
parent | c65ea080ba8637f0e83ea97b091e4ab3ebbce635 (diff) | |
download | gitlab-ce-606a1d2d31aff69ddabe7e3794f61f3e778da3e8.tar.gz |
Expose namespace storage statistics with GraphQL
Root namespaces have storage statistics.
This commit allows namespace owners to get those stats via GraphQL
queries like the following one
{
namespace(fullPath: "a_namespace_path") {
rootStorageStatistics {
storageSize
repositorySize
lfsObjectsSize
buildArtifactsSize
packagesSize
wikiSize
}
}
}
Diffstat (limited to 'spec/models/namespace')
-rw-r--r-- | spec/models/namespace/root_storage_statistics_spec.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/models/namespace/root_storage_statistics_spec.rb b/spec/models/namespace/root_storage_statistics_spec.rb index 5341278db7c..9e12831a704 100644 --- a/spec/models/namespace/root_storage_statistics_spec.rb +++ b/spec/models/namespace/root_storage_statistics_spec.rb @@ -8,6 +8,19 @@ RSpec.describe Namespace::RootStorageStatistics, type: :model do it { is_expected.to delegate_method(:all_projects).to(:namespace) } + context 'scopes' do + describe '.for_namespace_ids' do + it 'returns only requested namespaces' do + stats = create_list(:namespace_root_storage_statistics, 3) + namespace_ids = stats[0..1].map { |s| s.namespace_id } + + requested_stats = described_class.for_namespace_ids(namespace_ids).pluck(:namespace_id) + + expect(requested_stats).to eq(namespace_ids) + end + end + end + describe '#recalculate!' do let(:namespace) { create(:group) } let(:root_storage_statistics) { create(:namespace_root_storage_statistics, namespace: namespace) } |