Review fixes

This commit is contained in:
Nithin David Thomas
2024-02-15 21:45:38 +05:30
parent e0b60eb3b6
commit 90a6a9d058
5 changed files with 16 additions and 8 deletions
@@ -45,7 +45,8 @@ class Api::V1::AccountsController < Api::BaseController
def update
@account.assign_attributes(account_params.slice(:name, :locale, :domain, :support_email, :auto_resolve_duration))
@account.custom_attributes['onboarding_step'] = 'invite_team' if custom_attributes_params[:onboarding_step].present?
@account.custom_attributes.merge!(custom_attributes_params)
@account.custom_attributes['onboarding_step'] = 'invite_team' if @account.custom_attributes['onboarding_step'] == 'account_update'
@account.save!
end
@@ -6,10 +6,12 @@ export const findMatchingOption = (value, options, defaultValue) => {
};
export const findCompanySizeMatch = (options, size) => {
if (!size) return undefined;
if (Number.isNaN(size)) return undefined;
return (
options.find(option => {
const upperLimit = option.value.split('-')[1]?.split('+')[0];
return size < (upperLimit ? Number(upperLimit) : Infinity);
})?.value || this.companySizeOptions[0].value
})?.value || options[0].value
);
};
@@ -8,8 +8,8 @@ describe('getBrowserLocale', () => {
configurable: true,
});
const languages = [{ iso_639_1_code: 'en' }, { iso_639_1_code: 'en-US' }];
expect(getBrowserLocale(languages)).toBe('en-US');
const languages = [{ iso_639_1_code: 'en' }, { iso_639_1_code: 'en_US' }];
expect(getBrowserLocale(languages)).toBe('en');
});
it('should return the correct locale code when only a partial match is found', () => {
@@ -25,11 +25,16 @@ describe('findCompanySizeMatch', () => {
it('should return the correct company size range', () => {
const size = 25;
expect(findCompanySizeMatch(size, mockCompanySizeOptions)).toBe('11-50');
expect(findCompanySizeMatch(mockCompanySizeOptions, size)).toBe('11-50');
});
it('should return the first company size range when no match is found', () => {
it('should return the last company size range when limit exceeds', () => {
const size = 1500;
expect(findCompanySizeMatch(size, mockCompanySizeOptions)).toBe('1-10');
expect(findCompanySizeMatch(mockCompanySizeOptions, size)).toBe('1001+');
});
it('should return the undefined when no match is found', () => {
const size = undefined;
expect(findCompanySizeMatch(mockCompanySizeOptions, size)).toBe(undefined);
});
});
@@ -29,7 +29,7 @@ module Enterprise::Api::V2::AccountsController
'company_size' => data[:company_size],
'timezone' => data[:timezone],
'logo' => data[:logo],
'onboarding_step' => 'account_update'
'onboarding_step' => 'profile_update'
)
)
end