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

Merge branch...

Merge branch '336975-users-setup-for-company-field-is-overridden-to-true-for-existing-users-during-subscription' into 'master'

Resolve "Users "Setup for company" field is overridden to true for existing users during subscription purchase"

See merge request gitlab-org/gitlab!68868
parents bfbf3c53 578273be
......@@ -55,7 +55,7 @@ export default ({
const groups = parseGroupData(groupData);
return {
isSetupForCompany: parseBoolean(setupForCompany) || !isNewUser,
isSetupForCompany: setupForCompany === '' ? !isNewUser : parseBoolean(setupForCompany),
availablePlans,
selectedPlan: determineSelectedPlan(planId, availablePlans),
isNewUser,
......
......@@ -5,7 +5,7 @@ module SubscriptionsHelper
def subscription_data(eligible_groups)
{
setup_for_company: (current_user.setup_for_company == true).to_s,
setup_for_company: current_user.setup_for_company.to_s,
full_name: current_user.name,
available_plans: subscription_available_plans.to_json,
plan_id: params[:plan_id],
......
......@@ -70,27 +70,22 @@ describe('projectsSelector default state', () => {
});
});
describe('isSetupForCompany', () => {
it('sets the isSetupForCompany to true if provided setupForCompany is "true" and the provided newUser is "true"', () => {
expect(state.isSetupForCompany).toEqual(true);
});
it('sets the isSetupForCompany to true if provided newUser is "false"', () => {
const modifiedState = createState({
...initialData,
...{ newUser: 'false' },
});
expect(modifiedState.isSetupForCompany).toEqual(true);
});
it('sets the isSetupForCompany to false if provided setupForCompany is "false"', () => {
describe.each`
setupForCompanyValue | newUserValue | expectedValue
${''} | ${'true'} | ${false}
${''} | ${'false'} | ${true}
${'false'} | ${'true'} | ${false}
${'false'} | ${'false'} | ${false}
${'true'} | ${'true'} | ${true}
${'true'} | ${'false'} | ${true}
`('isSetupForCompany', ({ setupForCompanyValue, newUserValue, expectedValue }) => {
it(`sets the isSetupForCompany to ${expectedValue} if provided setupForCompany is "${setupForCompanyValue}" and newUser is "${newUserValue}"`, () => {
const modifiedState = createState({
...initialData,
...{ setupForCompany: 'false' },
...{ setupForCompany: setupForCompanyValue, newUser: newUserValue },
});
expect(modifiedState.isSetupForCompany).toEqual(false);
expect(modifiedState.isSetupForCompany).toEqual(expectedValue);
});
});
......
......@@ -45,7 +45,7 @@ RSpec.describe SubscriptionsHelper do
subject { helper.subscription_data([group]) }
it { is_expected.to include(setup_for_company: 'false') }
it { is_expected.to include(setup_for_company: '') }
it { is_expected.to include(full_name: 'First Last') }
it { is_expected.to include(available_plans: '[{"id":"bronze_id","code":"bronze","price_per_year":48.0,"name":"Bronze Plan"}]') }
it { is_expected.to include(plan_id: 'bronze_id') }
......
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