Commit 1133f57a authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'nicolasdular/temporary-storage-increase' into 'master'

Use temporary storage increase date

See merge request gitlab-org/gitlab!37511
parents 49c013c2 82bcdd66
......@@ -5054,6 +5054,11 @@ type Group {
"""
id: ID!
"""
Status of the temporary storage increase
"""
isTemporaryStorageIncreaseEnabled: Boolean!
"""
Issues of the group
"""
......@@ -8316,6 +8321,11 @@ type Namespace {
"""
id: ID!
"""
Status of the temporary storage increase
"""
isTemporaryStorageIncreaseEnabled: Boolean!
"""
Indicates if Large File Storage (LFS) is enabled for namespace
"""
......
......@@ -14079,6 +14079,24 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "isTemporaryStorageIncreaseEnabled",
"description": "Status of the temporary storage increase",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "issues",
"description": "Issues of the group",
......@@ -24824,6 +24842,24 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "isTemporaryStorageIncreaseEnabled",
"description": "Status of the temporary storage increase",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "lfsEnabled",
"description": "Indicates if Large File Storage (LFS) is enabled for namespace",
......@@ -821,6 +821,7 @@ Autogenerated return type of EpicTreeReorder
| `fullPath` | ID! | Full path of the namespace |
| `groupTimelogsEnabled` | Boolean | Indicates if Group timelogs are enabled for namespace |
| `id` | ID! | ID of the namespace |
| `isTemporaryStorageIncreaseEnabled` | Boolean! | Status of the temporary storage increase |
| `label` | Label | A label available on this group |
| `lfsEnabled` | Boolean | Indicates if Large File Storage (LFS) is enabled for namespace |
| `mentionsDisabled` | Boolean | Indicates if a group is disabled from getting mentioned |
......@@ -1278,6 +1279,7 @@ Contains statistics about a milestone
| `fullName` | String! | Full name of the namespace |
| `fullPath` | ID! | Full path of the namespace |
| `id` | ID! | ID of the namespace |
| `isTemporaryStorageIncreaseEnabled` | Boolean! | Status of the temporary storage increase |
| `lfsEnabled` | Boolean | Indicates if Large File Storage (LFS) is enabled for namespace |
| `name` | String! | Name of the namespace |
| `path` | String! | Path of the namespace |
......
......@@ -12,6 +12,12 @@ module EE
description: 'Total storage limit of the root namespace in bytes',
resolve: -> (obj, _args, _ctx) { EE::Namespace::RootStorageSize.new(obj).limit }
field :is_temporary_storage_increase_enabled,
GraphQL::BOOLEAN_TYPE,
null: false,
description: 'Status of the temporary storage increase',
resolve: -> (obj, _args, _ctx) { obj.temporary_storage_increase_enabled? }
field :temporary_storage_increase_ends_on,
::Types::TimeType,
null: true,
......
......@@ -50,8 +50,8 @@ module EE
delegate :additional_purchased_storage_size, :additional_purchased_storage_size=,
:additional_purchased_storage_ends_on, :additional_purchased_storage_ends_on=,
:temporary_storage_increase_ends_on,
to: :namespace_limit, allow_nil: true
:temporary_storage_increase_ends_on, :temporary_storage_increase_ends_on=,
:temporary_storage_increase_enabled?, to: :namespace_limit, allow_nil: true
delegate :email, to: :owner, allow_nil: true, prefix: true
......
......@@ -11,6 +11,8 @@ module EE
end
def above_size_limit?
return false if root_namespace.temporary_storage_increase_enabled?
usage_ratio > 1
end
......
......@@ -4,4 +4,11 @@ class NamespaceLimit < ApplicationRecord
self.primary_key = :namespace_id
belongs_to :namespace, inverse_of: :namespace_limit
def temporary_storage_increase_enabled?
return false unless ::Feature.enabled?(:temporary_storage_increase, namespace)
return false if temporary_storage_increase_ends_on.nil?
temporary_storage_increase_ends_on >= Date.today
end
end
---
title: Expose status of temporary storage increase
merge_request: 37511
author:
type: added
# frozen_string_literal: true
FactoryBot.define do
factory :namespace_limit do
namespace
end
end
......@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe GitlabSchema.types['Namespace'] do
it 'has specific fields' do
expected_fields = %w[storage_size_limit temporary_storage_increase_ends_on]
expected_fields = %w[storage_size_limit is_temporary_storage_increase_enabled temporary_storage_increase_ends_on]
expect(described_class).to include_graphql_fields(*expected_fields)
end
......
......@@ -4,4 +4,38 @@ require 'spec_helper'
RSpec.describe NamespaceLimit do
it { is_expected.to belong_to(:namespace) }
describe '#temporary_storage_increase_enabled?' do
let(:namespace_limit) { build(:namespace_limit) }
subject { namespace_limit.temporary_storage_increase_enabled? }
context 'when date is not set' do
it { is_expected.to eq(false) }
end
context 'when temporary storage increase end date is today' do
before do
namespace_limit.temporary_storage_increase_ends_on = Date.today
end
it { is_expected.to eq(true) }
context 'when feature is disabled' do
before do
stub_feature_flags(temporary_storage_increase: false)
end
it { is_expected.to eq(false) }
end
end
context 'when temporary storage increase end date is exceeded' do
before do
namespace_limit.temporary_storage_increase_ends_on = Date.today - 1.day
end
it { is_expected.to eq(false) }
end
end
end
......@@ -29,6 +29,9 @@ RSpec.describe Namespace do
it { is_expected.to delegate_method(:additional_purchased_storage_size=).to(:namespace_limit).with_arguments(:args) }
it { is_expected.to delegate_method(:additional_purchased_storage_ends_on).to(:namespace_limit) }
it { is_expected.to delegate_method(:additional_purchased_storage_ends_on=).to(:namespace_limit).with_arguments(:args) }
it { is_expected.to delegate_method(:temporary_storage_increase_ends_on).to(:namespace_limit) }
it { is_expected.to delegate_method(:temporary_storage_increase_ends_on=).to(:namespace_limit).with_arguments(:args) }
it { is_expected.to delegate_method(:temporary_storage_increase_enabled?).to(:namespace_limit) }
shared_examples 'plan helper' do |namespace_plan|
let(:namespace) { create(:namespace_with_plan, plan: "#{plan_name}_plan") }
......
......@@ -21,6 +21,10 @@ RSpec.describe Namespace::RootStorageSize, type: :model do
describe '#above_size_limit?' do
subject { model.above_size_limit? }
before do
allow(namespace).to receive(:temporary_storage_increase_enabled?).and_return(false)
end
context 'when limit is 0' do
let(:limit) { 0 }
......@@ -34,8 +38,18 @@ RSpec.describe Namespace::RootStorageSize, type: :model do
context 'when above limit' do
let(:current_size) { 101.megabytes }
context 'when temporary storage increase is disabled' do
it { is_expected.to eq(true) }
end
context 'when temporary storage increase is enabled' do
before do
allow(namespace).to receive(:temporary_storage_increase_enabled?).and_return(true)
end
it { is_expected.to eq(false) }
end
end
end
describe '#usage_ratio' do
......
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