Commit 578273be authored by Alex Buijs's avatar Alex Buijs

Don't override setup_for_company in subscription flow

When in the subscription flow, a false value of
setup_for_company would be overridden for existing
users. This fixes that bug.

Changelog: fixed
parent ec270fb9
......@@ -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