Commit 614e2c10 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch 'fix-trial-start-billing-members' into 'master'

Fix namespace billing page incorrectly accessing billable members

See merge request gitlab-org/gitlab!49677
parents 1bb4b4af 4e6d7554
......@@ -26,12 +26,14 @@ export default {
default: false,
},
},
inject: ['billableSeatsHref'],
inject: ['billableSeatsHref', 'isGroup'],
computed: {
...mapState(['hasBillableGroupMembers']),
},
created() {
if (this.isGroup) {
this.fetchHasBillableGroupMembers();
}
},
methods: {
...mapActions(['fetchHasBillableGroupMembers']),
......
......@@ -16,6 +16,7 @@ export default (containerId = 'js-billing-plans') => {
namespaceId,
namespaceName,
addSeatsHref,
isGroup,
planUpgradeHref,
planRenewHref,
customerPortalUrl,
......@@ -29,6 +30,7 @@ export default (containerId = 'js-billing-plans') => {
namespaceId,
namespaceName,
addSeatsHref,
isGroup,
planUpgradeHref,
planRenewHref,
customerPortalUrl,
......
......@@ -9,17 +9,18 @@ module BillingPlansHelper
number_to_currency(value, unit: '$', strip_insignificant_zeros: true, format: "%u%n")
end
def subscription_plan_data_attributes(group, plan)
return {} unless group
def subscription_plan_data_attributes(namespace, plan)
return {} unless namespace
{
namespace_id: group.id,
namespace_name: group.name,
add_seats_href: add_seats_url(group),
plan_upgrade_href: plan_upgrade_url(group, plan),
plan_renew_href: plan_renew_url(group),
namespace_id: namespace.id,
namespace_name: namespace.name,
is_group: namespace.group?,
add_seats_href: add_seats_url(namespace),
plan_upgrade_href: plan_upgrade_url(namespace, plan),
plan_renew_href: plan_renew_url(namespace),
customer_portal_url: "#{EE::SUBSCRIPTIONS_URL}/subscriptions",
billable_seats_href: billable_seats_href(group)
billable_seats_href: billable_seats_href(namespace)
}
end
......
......@@ -39,7 +39,11 @@ describe('subscription table row', () => {
const defaultProps = { header: HEADER, columns: COLUMNS };
const createComponent = ({ props = {}, billableSeatsHref = BILLABLE_SEATS_URL } = {}) => {
const createComponent = ({
props = {},
billableSeatsHref = BILLABLE_SEATS_URL,
isGroup = true,
} = {}) => {
if (wrapper) {
throw new Error('wrapper already exists!');
}
......@@ -51,6 +55,7 @@ describe('subscription table row', () => {
},
provide: {
billableSeatsHref,
isGroup,
},
store,
localVue,
......@@ -86,13 +91,21 @@ describe('subscription table row', () => {
.at(0)
.find('[data-testid="seats-usage-button"]');
describe('default', () => {
beforeEach(() => {
describe('dispatched actions', () => {
it('dispatches action when created if namespace is group', () => {
createComponent();
expect(store.dispatch).toHaveBeenCalledWith('fetchHasBillableGroupMembers');
});
it('dispatches correct actions when created', () => {
expect(store.dispatch).toHaveBeenCalledWith('fetchHasBillableGroupMembers');
it('does not dispatch action when created if namespace is not group', () => {
createComponent({ isGroup: false });
expect(store.dispatch).not.toHaveBeenCalledWith('fetchHasBillableGroupMembers');
});
});
describe('default', () => {
beforeEach(() => {
createComponent();
});
it(`should render one header cell and ${COLUMNS.length} visible columns in total`, () => {
......
......@@ -21,6 +21,7 @@ RSpec.describe BillingPlansHelper do
expect(helper.subscription_plan_data_attributes(group, plan))
.to eq(namespace_id: group.id,
namespace_name: group.name,
is_group: true,
add_seats_href: add_seats_href,
plan_upgrade_href: upgrade_href,
plan_renew_href: renew_href,
......@@ -48,6 +49,7 @@ RSpec.describe BillingPlansHelper do
expect(helper.subscription_plan_data_attributes(group, plan))
.to eq(namespace_id: group.id,
namespace_name: group.name,
is_group: true,
customer_portal_url: customer_portal_url,
billable_seats_href: billable_seats_href,
add_seats_href: add_seats_href,
......@@ -55,6 +57,16 @@ RSpec.describe BillingPlansHelper do
plan_upgrade_href: nil)
end
end
context 'when namespace is passed in' do
it 'returns false for is_group' do
namespace = build(:namespace)
result = helper.subscription_plan_data_attributes(namespace, plan)
expect(result).to include(is_group: false)
end
end
end
describe '#use_new_purchase_flow?' do
......
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