Commit effa7178 authored by Vijay Hawoldar's avatar Vijay Hawoldar

Move FetchSubscriptionPlansService into namespace

Moves the service to the `GitlabSubscriptions` namespace as
part of the effrot to have everything aligned within namespaces
parent a4771b1a
......@@ -2358,7 +2358,6 @@ Gitlab/NamespacedClass:
- 'ee/app/serializers/vulnerability_note_serializer.rb'
- 'ee/app/serializers/vulnerability_serializer.rb'
- 'ee/app/services/clear_namespace_shared_runners_minutes_service.rb'
- 'ee/app/services/fetch_subscription_plans_service.rb'
- 'ee/app/services/ldap_group_reset_service.rb'
- 'ee/app/services/start_pull_mirroring_service.rb'
- 'ee/app/services/timebox_report_service.rb'
......
......@@ -16,7 +16,9 @@ class Groups::BillingsController < Groups::ApplicationController
@top_most_group = @group.root_ancestor if @group.has_parent?
relevant_group = (@top_most_group || @group)
current_plan = relevant_group.plan_name_for_upgrading
@plans_data = FetchSubscriptionPlansService.new(plan: current_plan, namespace_id: relevant_group.id).execute
@plans_data = GitlabSubscriptions::FetchSubscriptionPlansService
.new(plan: current_plan, namespace_id: relevant_group.id)
.execute
track_experiment_event(:contact_sales_btn_in_app, 'page_view:billing_plans:group')
record_experiment_user(:contact_sales_btn_in_app)
end
......
......@@ -6,7 +6,7 @@ class Profiles::BillingsController < Profiles::ApplicationController
feature_category :purchase
def index
@plans_data = FetchSubscriptionPlansService
@plans_data = GitlabSubscriptions::FetchSubscriptionPlansService
.new(plan: current_user.namespace.plan_name_for_upgrading, namespace_id: current_user.namespace_id)
.execute
track_experiment_event(:contact_sales_btn_in_app, 'page_view:billing_plans:profile')
......
......@@ -31,7 +31,7 @@ module SubscriptionsHelper
end
def plans_data
FetchSubscriptionPlansService.new(plan: :free).execute
GitlabSubscriptions::FetchSubscriptionPlansService.new(plan: :free).execute
.map(&:symbolize_keys)
.reject { |plan_data| plan_data[:free] }
.map { |plan_data| plan_data.slice(:id, :code, :price_per_year, :deprecated, :name) }
......
# frozen_string_literal: true
class FetchSubscriptionPlansService
class GitlabSubscriptions::FetchSubscriptionPlansService
URL = "#{EE::SUBSCRIPTIONS_URL}/gitlab_plans".freeze
def initialize(plan:, namespace_id: nil)
......
......@@ -26,7 +26,7 @@ RSpec.describe Groups::BillingsController do
context 'authorized' do
before do
add_group_owner
allow_next_instance_of(FetchSubscriptionPlansService) do |instance|
allow_next_instance_of(GitlabSubscriptions::FetchSubscriptionPlansService) do |instance|
allow(instance).to receive(:execute)
end
allow(controller).to receive(:track_experiment_event)
......@@ -41,7 +41,7 @@ RSpec.describe Groups::BillingsController do
it 'fetches subscription plans data from customers.gitlab.com' do
data = double
expect_next_instance_of(FetchSubscriptionPlansService) do |instance|
expect_next_instance_of(GitlabSubscriptions::FetchSubscriptionPlansService) do |instance|
expect(instance).to receive(:execute).and_return(data)
end
......
......@@ -10,7 +10,7 @@ RSpec.describe Profiles::BillingsController do
sign_in(user)
stub_application_setting(check_namespace_plan: true)
allow(Gitlab).to receive(:com?) { true }
allow_next_instance_of(FetchSubscriptionPlansService) do |instance|
allow_next_instance_of(GitlabSubscriptions::FetchSubscriptionPlansService) do |instance|
allow(instance).to receive(:execute)
end
allow(controller).to receive(:track_experiment_event)
......@@ -31,7 +31,7 @@ RSpec.describe Profiles::BillingsController do
it 'fetch subscription plans data from customers.gitlab.com' do
data = double
expect_next_instance_of(FetchSubscriptionPlansService) do |instance|
expect_next_instance_of(GitlabSubscriptions::FetchSubscriptionPlansService) do |instance|
expect(instance).to receive(:execute).and_return(data)
end
......
......@@ -26,7 +26,7 @@ RSpec.describe SubscriptionsHelper do
before do
stub_feature_flags(hide_deprecated_billing_plans: false)
allow(helper).to receive(:params).and_return(plan_id: 'bronze_id', namespace_id: nil)
allow_next_instance_of(FetchSubscriptionPlansService) do |instance|
allow_next_instance_of(GitlabSubscriptions::FetchSubscriptionPlansService) do |instance|
allow(instance).to receive(:execute).and_return(raw_plan_data)
end
end
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe FetchSubscriptionPlansService do
RSpec.describe GitlabSubscriptions::FetchSubscriptionPlansService do
describe '#execute' do
subject(:execute_service) { described_class.new(plan: plan).execute }
......
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