Commit 537bfae6 authored by Alper Akgun's avatar Alper Akgun Committed by Jose Ivan Vargas

Settings search should not appear in billings page

parent c61122f9
- return if @hide_search_settings
- container_class = local_assigns.fetch(:container_class, 'gl-mt-5') - container_class = local_assigns.fetch(:container_class, 'gl-mt-5')
%div{ class: container_class } %div{ class: container_class }
......
...@@ -9,6 +9,7 @@ class Groups::BillingsController < Groups::ApplicationController ...@@ -9,6 +9,7 @@ class Groups::BillingsController < Groups::ApplicationController
feature_category :purchase feature_category :purchase
def index def index
@hide_search_settings = true
@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
......
...@@ -6,6 +6,7 @@ class Profiles::BillingsController < Profiles::ApplicationController ...@@ -6,6 +6,7 @@ class Profiles::BillingsController < Profiles::ApplicationController
feature_category :purchase feature_category :purchase
def index def index
@hide_search_settings = true
@plans_data = GitlabSubscriptions::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
......
...@@ -29,12 +29,18 @@ RSpec.describe 'Groups > Billing', :js do ...@@ -29,12 +29,18 @@ RSpec.describe 'Groups > Billing', :js do
sign_in(user) sign_in(user)
end end
shared_examples 'hides search settings' do
it 'does not have search settings' do
visit group_billings_path(group)
expect(page).not_to have_field(placeholder: SearchHelpers::INPUT_PLACEHOLDER)
end
end
context 'when CustomersDot is available' do context 'when CustomersDot is available' do
before do before do
stub_eoa_eligibility_request(group.id) stub_eoa_eligibility_request(group.id)
stub_full_request("#{EE::SUBSCRIPTIONS_URL}/gitlab_plans?plan=#{plan}&namespace_id=#{group.id}") stub_billing_plans(group.id, plan)
.with(headers: { 'Accept' => 'application/json' })
.to_return(status: 200, body: File.new(Rails.root.join('ee/spec/fixtures/gitlab_com_plans.json')))
end end
context 'with a free plan' do context 'with a free plan' do
...@@ -44,6 +50,8 @@ RSpec.describe 'Groups > Billing', :js do ...@@ -44,6 +50,8 @@ RSpec.describe 'Groups > Billing', :js do
create(:gitlab_subscription, namespace: group, hosted_plan: nil, seats: 15) create(:gitlab_subscription, namespace: group, hosted_plan: nil, seats: 15)
end end
it_behaves_like 'hides search settings'
it 'shows the proper title and subscription data' do it 'shows the proper title and subscription data' do
visit group_billings_path(group) visit group_billings_path(group)
...@@ -63,6 +71,8 @@ RSpec.describe 'Groups > Billing', :js do ...@@ -63,6 +71,8 @@ RSpec.describe 'Groups > Billing', :js do
create(:gitlab_subscription, namespace: group, hosted_plan: bronze_plan, seats: 15) create(:gitlab_subscription, namespace: group, hosted_plan: bronze_plan, seats: 15)
end end
it_behaves_like 'hides search settings'
it 'shows the proper title and subscription data' do it 'shows the proper title and subscription data' do
extra_seats_url = "#{EE::SUBSCRIPTIONS_URL}/gitlab/namespaces/#{group.id}/extra_seats" extra_seats_url = "#{EE::SUBSCRIPTIONS_URL}/gitlab/namespaces/#{group.id}/extra_seats"
renew_url = "#{EE::SUBSCRIPTIONS_URL}/gitlab/namespaces/#{group.id}/renew" renew_url = "#{EE::SUBSCRIPTIONS_URL}/gitlab/namespaces/#{group.id}/renew"
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Profiles > Billing', :js do
include StubRequests
include SubscriptionPortalHelpers
let_it_be(:namespace) { create(:namespace) }
let_it_be(:user) { create(:user, namespace: namespace) }
let_it_be(:bronze_plan) { create(:bronze_plan) }
def formatted_date(date)
date.strftime("%B %-d, %Y")
end
def subscription_table
'.subscription-table'
end
before do
allow(Gitlab).to receive(:com?).and_return(true)
stub_application_setting(check_namespace_plan: true)
sign_in(user)
end
context 'when CustomersDot is available' do
let(:plan) { 'free' }
before do
stub_billing_plans(user.namespace.id, plan)
end
context 'with a free plan' do
let!(:subscription) do
create(:gitlab_subscription, namespace: user.namespace, hosted_plan: nil)
end
it 'does not have search settings field' do
visit profile_billings_path
expect(page).not_to have_field(placeholder: SearchHelpers::INPUT_PLACEHOLDER)
end
end
end
end
...@@ -4,21 +4,16 @@ require 'spec_helper' ...@@ -4,21 +4,16 @@ require 'spec_helper'
RSpec.describe 'Show trial banner', :js do RSpec.describe 'Show trial banner', :js do
include StubRequests include StubRequests
include SubscriptionPortalHelpers
let!(:user) { create(:user) } let!(:user) { create(:user) }
let!(:group) { create(:group) } let!(:group) { create(:group) }
let!(:ultimate_plan) { create(:ultimate_plan) } let!(:ultimate_plan) { create(:ultimate_plan) }
let(:plans_data) do
Gitlab::Json.parse(File.read(Rails.root.join('ee/spec/fixtures/gitlab_com_plans.json'))).map do |data|
data.deep_symbolize_keys
end
end
before do before do
stub_application_setting(check_namespace_plan: true) stub_application_setting(check_namespace_plan: true)
allow(Gitlab).to receive(:com?).and_return(true).at_least(:once) allow(Gitlab).to receive(:com?).and_return(true).at_least(:once)
stub_full_request("#{EE::SUBSCRIPTIONS_URL}/gitlab_plans?plan=free&namespace_id=#{namespace_id}") stub_billing_plans(namespace_id)
.to_return(status: 200, body: plans_data.to_json)
group.add_owner(user) group.add_owner(user)
create(:gitlab_subscription, namespace: user.namespace, hosted_plan: ultimate_plan, trial: true, trial_ends_on: Date.current + 1.month) create(:gitlab_subscription, namespace: user.namespace, hosted_plan: ultimate_plan, trial: true, trial_ends_on: Date.current + 1.month)
......
...@@ -21,8 +21,24 @@ module SubscriptionPortalHelpers ...@@ -21,8 +21,24 @@ module SubscriptionPortalHelpers
) )
end end
def billing_plans_data
Gitlab::Json.parse(plans_fixture).map do |data|
data.deep_symbolize_keys
end
end
def stub_billing_plans(namespace_id, plan = 'free')
stub_full_request("#{EE::SUBSCRIPTIONS_URL}/gitlab_plans?namespace_id=#{namespace_id}&plan=#{plan}")
.with(headers: { 'Accept' => 'application/json' })
.to_return(status: 200, body: plans_fixture)
end
private private
def plans_fixture
File.new(Rails.root.join('ee/spec/fixtures/gitlab_com_plans.json'))
end
def stubbed_eoa_eligibility_response_body(eligible, free_upgrade_plan_id, assisted_upgrade_plan_id) def stubbed_eoa_eligibility_response_body(eligible, free_upgrade_plan_id, assisted_upgrade_plan_id)
{ {
"data": { "data": {
......
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