Commit f2b7bab3 authored by Tyler Amos's avatar Tyler Amos

Convert additional purchased storage size in api

Converts additional_purchased_storage_size returned from megabytes to
bytes as expected.  As it turns out the unit of measure stored in the
DB was MB so this value must be converted to be consistent with other
endpoint values (e.g. total_repository_size,
actual_repository_size_limit)
parent ed32becc
...@@ -9,7 +9,8 @@ module EE ...@@ -9,7 +9,8 @@ module EE
field :additional_purchased_storage_size, field :additional_purchased_storage_size,
GraphQL::FLOAT_TYPE, GraphQL::FLOAT_TYPE,
null: true, 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, field :total_repository_size_excess,
GraphQL::FLOAT_TYPE, GraphQL::FLOAT_TYPE,
......
...@@ -18,4 +18,31 @@ RSpec.describe GitlabSchema.types['Namespace'] do ...@@ -18,4 +18,31 @@ RSpec.describe GitlabSchema.types['Namespace'] do
expect(described_class).to include_graphql_fields(*expected_fields) expect(described_class).to include_graphql_fields(*expected_fields)
end 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 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