diff --git a/.rubocop_todo/rspec/missing_feature_category.yml b/.rubocop_todo/rspec/missing_feature_category.yml index 1c887978de82bd5f9f3387186db8ff68edc527f0..7e1dc4b4cf93622082e344d8390ba12632b0fa01 100644 --- a/.rubocop_todo/rspec/missing_feature_category.yml +++ b/.rubocop_todo/rspec/missing_feature_category.yml @@ -495,7 +495,6 @@ RSpec/MissingFeatureCategory: - 'ee/spec/helpers/ee/labels_helper_spec.rb' - 'ee/spec/helpers/ee/lock_helper_spec.rb' - 'ee/spec/helpers/ee/namespace_user_cap_reached_alert_helper_spec.rb' - - 'ee/spec/helpers/ee/namespaces_helper_spec.rb' - 'ee/spec/helpers/ee/operations_helper_spec.rb' - 'ee/spec/helpers/ee/personal_access_tokens_helper_spec.rb' - 'ee/spec/helpers/ee/profiles_helper_spec.rb' @@ -2625,7 +2624,6 @@ RSpec/MissingFeatureCategory: - 'spec/helpers/markup_helper_spec.rb' - 'spec/helpers/members_helper_spec.rb' - 'spec/helpers/milestones_helper_spec.rb' - - 'spec/helpers/namespaces_helper_spec.rb' - 'spec/helpers/nav/top_nav_helper_spec.rb' - 'spec/helpers/notifications_helper_spec.rb' - 'spec/helpers/notify_helper_spec.rb' diff --git a/ee/app/assets/javascripts/usage_quotas/pipelines/components/app.vue b/ee/app/assets/javascripts/usage_quotas/pipelines/components/app.vue index 8658e66906e15ae976a1671e80c83361dacc7f5c..b53bcecb9984ca45015389ae3d32e66794496994 100644 --- a/ee/app/assets/javascripts/usage_quotas/pipelines/components/app.vue +++ b/ee/app/assets/javascripts/usage_quotas/pipelines/components/app.vue @@ -182,6 +182,7 @@ export default { </gl-button> </div> <usage-overview + :class="{ 'gl-pt-5': !shouldShowBuyAdditionalMinutes }" :minutes-title="monthlyUsageTitle" :minutes-used="monthlyMinutesUsed" minutes-used-qa-selector="plan_ci_minutes" diff --git a/ee/app/helpers/ee/namespaces_helper.rb b/ee/app/helpers/ee/namespaces_helper.rb index 60157735fb0d0a0e3423f6fd0ad04049285866c8..290327ab9c654f780b6c0bf0e4f5bf21fe09ff84 100644 --- a/ee/app/helpers/ee/namespaces_helper.rb +++ b/ee/app/helpers/ee/namespaces_helper.rb @@ -34,23 +34,30 @@ def buy_storage_url(namespace) override :pipeline_usage_app_data def pipeline_usage_app_data(namespace) - return super unless ::Gitlab::CurrentSettings.should_check_namespace_plan? - minutes_usage = namespace.ci_minutes_usage minutes_usage_presenter = ::Ci::Minutes::UsagePresenter.new(minutes_usage) + # EE data + ci_minutes = { + any_project_enabled: minutes_usage_presenter.any_project_enabled?.to_s, + last_reset_date: minutes_usage.reset_date, + display_minutes_available_data: minutes_usage_presenter.display_minutes_available_data?.to_s, + monthly_minutes_used: minutes_usage_presenter.monthly_minutes_report.used, + monthly_minutes_used_percentage: minutes_usage_presenter.monthly_percent_used, + monthly_minutes_limit: minutes_usage_presenter.monthly_minutes_report.limit + } + + return super.merge(ci_minutes: ci_minutes) unless ::Gitlab::CurrentSettings.should_check_namespace_plan? + + # SaaS data + ci_minutes.merge!({ + purchased_minutes_used: minutes_usage_presenter.purchased_minutes_report.used, + purchased_minutes_used_percentage: minutes_usage_presenter.purchased_percent_used, + purchased_minutes_limit: minutes_usage_presenter.purchased_minutes_report.limit + }) + super.merge( - ci_minutes: { - any_project_enabled: minutes_usage_presenter.any_project_enabled?.to_s, - last_reset_date: minutes_usage.reset_date, - display_minutes_available_data: minutes_usage_presenter.display_minutes_available_data?.to_s, - monthly_minutes_used: minutes_usage_presenter.monthly_minutes_report.used, - monthly_minutes_used_percentage: minutes_usage_presenter.monthly_percent_used, - monthly_minutes_limit: minutes_usage_presenter.monthly_minutes_report.limit, - purchased_minutes_used: minutes_usage_presenter.purchased_minutes_report.used, - purchased_minutes_used_percentage: minutes_usage_presenter.purchased_percent_used, - purchased_minutes_limit: minutes_usage_presenter.purchased_minutes_report.limit - }, + ci_minutes: ci_minutes, buy_additional_minutes_path: buy_additional_minutes_path(namespace), buy_additional_minutes_target: buy_addon_target_attr(namespace) ) diff --git a/ee/spec/helpers/ee/namespaces_helper_spec.rb b/ee/spec/helpers/ee/namespaces_helper_spec.rb index b38af6df5f912a4e9eb71c4824045ec138f3253f..72f6226e297548788d7f47fab7449ed3711aeffb 100644 --- a/ee/spec/helpers/ee/namespaces_helper_spec.rb +++ b/ee/spec/helpers/ee/namespaces_helper_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -RSpec.describe EE::NamespacesHelper do +RSpec.describe EE::NamespacesHelper, feature_category: :subgroups do using RSpec::Parameterized::TableSyntax include NamespacesTestHelper @@ -200,10 +200,10 @@ end describe '#pipeline_usage_app_data', feature_category: :consumables_cost_management do - context 'when gitlab sass', :saas do - let(:minutes_usage) { user_group.ci_minutes_usage } - let(:minutes_usage_presenter) { ::Ci::Minutes::UsagePresenter.new(minutes_usage) } + let(:minutes_usage) { user_group.ci_minutes_usage } + let(:minutes_usage_presenter) { ::Ci::Minutes::UsagePresenter.new(minutes_usage) } + context 'when gitlab sass', :saas do before do allow(Gitlab).to receive(:com?).and_return(true) stub_ee_application_setting(should_check_namespace_plan: true) @@ -246,7 +246,15 @@ namespace_path: user_group.full_path, namespace_id: user_group.id, user_namespace: user_group.user_namespace?.to_s, - page_size: Kaminari.config.default_per_page + page_size: Kaminari.config.default_per_page, + ci_minutes: { + any_project_enabled: minutes_usage_presenter.any_project_enabled?.to_s, + last_reset_date: minutes_usage.reset_date, + display_minutes_available_data: minutes_usage_presenter.display_minutes_available_data?.to_s, + monthly_minutes_used: minutes_usage_presenter.monthly_minutes_report.used, + monthly_minutes_used_percentage: minutes_usage_presenter.monthly_percent_used, + monthly_minutes_limit: minutes_usage_presenter.monthly_minutes_report.limit + } }) end end diff --git a/spec/helpers/namespaces_helper_spec.rb b/spec/helpers/namespaces_helper_spec.rb index e288a604be6743a2c9f2509cae2921e829ace74b..e7c8e40da7f5aebe3cea88c5651173f5adcff22e 100644 --- a/spec/helpers/namespaces_helper_spec.rb +++ b/spec/helpers/namespaces_helper_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe NamespacesHelper do +RSpec.describe NamespacesHelper, feature_category: :subgroups do let!(:admin) { create(:admin) } let!(:admin_project_creation_level) { nil } let!(:admin_group) do @@ -121,7 +121,7 @@ end end - describe '#pipeline_usage_app_data' do + describe '#pipeline_usage_app_data', unless: Gitlab.ee?, feature_category: :consumables_cost_management do it 'returns a hash with necessary data for the frontend' do expect(helper.pipeline_usage_app_data(user_group)).to eql({ namespace_actual_plan_name: user_group.actual_plan_name,