gitlab-org--gitlab-foss/spec/policies/namespace_policy_spec.rb
Alessio Caiazza 606a1d2d31 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
    }
  }
}
2019-08-22 22:08:28 +00:00

42 lines
1,016 B
Ruby

require 'spec_helper'
describe NamespacePolicy do
let(:user) { create(:user) }
let(:owner) { create(:user) }
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, owner: owner) }
let(:owner_permissions) { [:create_projects, :admin_namespace, :read_namespace, :read_statistics] }
subject { described_class.new(current_user, namespace) }
context 'with no user' do
let(:current_user) { nil }
it { is_expected.to be_banned }
end
context 'regular user' do
let(:current_user) { user }
it { is_expected.to be_disallowed(*owner_permissions) }
end
context 'owner' do
let(:current_user) { owner }
it { is_expected.to be_allowed(*owner_permissions) }
context 'user who has exceeded project limit' do
let(:owner) { create(:user, projects_limit: 0) }
it { is_expected.to be_disallowed(:create_projects) }
end
end
context 'admin' do
let(:current_user) { admin }
it { is_expected.to be_allowed(*owner_permissions) }
end
end