Commit f8f7aaf4 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '326930-settings-search-should-not-appear-in-billings-page' into 'master'

Settings search should not appear in billings page

See merge request gitlab-org/gitlab!63731
parents 527dd932 537bfae6
- return if @hide_search_settings
- container_class = local_assigns.fetch(:container_class, 'gl-mt-5')
%div{ class: container_class }
......
......@@ -9,6 +9,7 @@ class Groups::BillingsController < Groups::ApplicationController
feature_category :purchase
def index
@hide_search_settings = true
@top_most_group = @group.root_ancestor if @group.has_parent?
relevant_group = (@top_most_group || @group)
current_plan = relevant_group.plan_name_for_upgrading
......
......@@ -6,6 +6,7 @@ class Profiles::BillingsController < Profiles::ApplicationController
feature_category :purchase
def index
@hide_search_settings = true
@plans_data = GitlabSubscriptions::FetchSubscriptionPlansService
.new(plan: current_user.namespace.plan_name_for_upgrading, namespace_id: current_user.namespace_id)
.execute
......
......@@ -29,12 +29,18 @@ RSpec.describe 'Groups > Billing', :js do
sign_in(user)
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
before do
stub_eoa_eligibility_request(group.id)
stub_full_request("#{EE::SUBSCRIPTIONS_URL}/gitlab_plans?plan=#{plan}&namespace_id=#{group.id}")
.with(headers: { 'Accept' => 'application/json' })
.to_return(status: 200, body: File.new(Rails.root.join('ee/spec/fixtures/gitlab_com_plans.json')))
stub_billing_plans(group.id, plan)
end
context 'with a free plan' do
......@@ -44,6 +50,8 @@ RSpec.describe 'Groups > Billing', :js do
create(:gitlab_subscription, namespace: group, hosted_plan: nil, seats: 15)
end
it_behaves_like 'hides search settings'
it 'shows the proper title and subscription data' do
visit group_billings_path(group)
......@@ -63,6 +71,8 @@ RSpec.describe 'Groups > Billing', :js do
create(:gitlab_subscription, namespace: group, hosted_plan: bronze_plan, seats: 15)
end
it_behaves_like 'hides search settings'
it 'shows the proper title and subscription data' do
extra_seats_url = "#{EE::SUBSCRIPTIONS_URL}/gitlab/namespaces/#{group.id}/extra_seats"
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'
RSpec.describe 'Show trial banner', :js do
include StubRequests
include SubscriptionPortalHelpers
let!(:user) { create(:user) }
let!(:group) { create(:group) }
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
stub_application_setting(check_namespace_plan: true)
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}")
.to_return(status: 200, body: plans_data.to_json)
stub_billing_plans(namespace_id)
group.add_owner(user)
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
)
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
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)
{
"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