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