Commit cbe9ed0b authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'ta-convert-additional-purchased-storage-size-in-api' into 'master'

Convert additional purchased storage size in api

See merge request gitlab-org/gitlab!45210
parents 67e1bd90 f2b7bab3
......@@ -9,7 +9,8 @@ module EE
field :additional_purchased_storage_size,
GraphQL::FLOAT_TYPE,
null: true,
description: 'Additional storage purchased for the root namespace in bytes'
description: 'Additional storage purchased for the root namespace in bytes',
resolve: -> (obj, _args, _ctx) { obj.additional_purchased_storage_size.megabytes }
field :total_repository_size_excess,
GraphQL::FLOAT_TYPE,
......
......@@ -18,4 +18,31 @@ RSpec.describe GitlabSchema.types['Namespace'] do
expect(described_class).to include_graphql_fields(*expected_fields)
end
describe 'Customized fields' do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group, additional_purchased_storage_size: 100, repository_size_limit: 10_240) }
let_it_be(:group_member) { create(:group_member, group: group, user: user) }
let_it_be(:query) do
%(
query {
namespace(fullPath: "#{group.full_path}") {
additionalPurchasedStorageSize
containsLockedProjects
actualRepositorySizeLimit
}
}
)
end
subject { GitlabSchema.execute(query, context: { current_user: user }).as_json }
it "returns the expected values for customized fields defined in NamespaceType" do
namespace = subject.dig('data', 'namespace')
expect(namespace['additionalPurchasedStorageSize']).to eq(100.megabytes)
expect(namespace['containsLockedProjects']).to eq(false)
expect(namespace['actualRepositorySizeLimit']).to eq(10_240)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment