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 ({ ...@@ -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