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