From bd7a2f13940668097b6f7d0c78b6d3c0bb7ca9b7 Mon Sep 17 00:00:00 2001 From: Vijay Hawoldar <vhawoldar@gitlab.com> Date: Tue, 5 Dec 2023 09:18:04 +0000 Subject: [PATCH] Include purchased storage in banner Combined storage and free user limit banners should include any purchased storage as part of the limit --- .../combined_storage_users/base_alert_component.rb | 2 +- .../non_owner_alert_component_spec.rb | 9 +++++++++ .../combined_storage_users/owner_alert_component_spec.rb | 9 +++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ee/app/components/namespaces/combined_storage_users/base_alert_component.rb b/ee/app/components/namespaces/combined_storage_users/base_alert_component.rb index 6685706bfa90d..801803655f4ba 100644 --- a/ee/app/components/namespaces/combined_storage_users/base_alert_component.rb +++ b/ee/app/components/namespaces/combined_storage_users/base_alert_component.rb @@ -93,7 +93,7 @@ def free_users_limit end def free_storage_limit - limit = root_namespace.actual_limits.storage_size_limit.megabytes + limit = ::Namespaces::Storage::RootSize.new(root_namespace).dashboard_limit number_to_human_size(limit, precision: 0) end diff --git a/ee/spec/components/namespaces/combined_storage_users/non_owner_alert_component_spec.rb b/ee/spec/components/namespaces/combined_storage_users/non_owner_alert_component_spec.rb index e2dd58d30eb22..ab80751835f6d 100644 --- a/ee/spec/components/namespaces/combined_storage_users/non_owner_alert_component_spec.rb +++ b/ee/spec/components/namespaces/combined_storage_users/non_owner_alert_component_spec.rb @@ -88,6 +88,15 @@ expect(page).to have_content(alert_title) end end + + context 'when the user has purchased additional storage' do + it 'includes the purchased storage in the alert' do + namespace.additional_purchased_storage_size = 10_240 + render_inline(component) + + expect(page).to have_content('15 GiB') + end + end end context 'when not over one of the limits' do diff --git a/ee/spec/components/namespaces/combined_storage_users/owner_alert_component_spec.rb b/ee/spec/components/namespaces/combined_storage_users/owner_alert_component_spec.rb index 17dd6f394632b..779e78e1b8908 100644 --- a/ee/spec/components/namespaces/combined_storage_users/owner_alert_component_spec.rb +++ b/ee/spec/components/namespaces/combined_storage_users/owner_alert_component_spec.rb @@ -88,6 +88,15 @@ expect(page).to have_content(alert_title) end end + + context 'when the user has purchased additional storage' do + it 'includes the purchased storage in the alert' do + namespace.additional_purchased_storage_size = 10_240 + render_inline(component) + + expect(page).to have_content('15 GiB') + end + end end context 'when not over one of the limits' do -- GitLab