Skip to content
Snippets Groups Projects
Commit 33e395d7 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

#655 - fallback to default account if placeholder account is selected

parent 030dd1ee
Branches
Tags
No related merge requests found
......@@ -287,7 +287,7 @@ public class AccountService implements Resettable, AccessAllEntities<Account>, A
public Account getSelectedAccountOrDefaultAsFallback()
{
final Account selectedAccount = accountRepository.findByIsSelected(true);
if(selectedAccount != null)
if(selectedAccount != null && selectedAccount.getType() == AccountType.CUSTOM)
{
return selectedAccount;
}
......
......@@ -312,4 +312,13 @@ class AccountServiceTest
assertThat(accountService.getSelectedAccountOrDefaultAsFallback()).isEqualTo(ACCOUNT_DEFAULT);
}
@Test
void test_getSelectedAccountOrDefaultAsFallback_fallbackIfPlaceholderAccountIsSelected()
{
Mockito.when(accountRepository.findByIsSelected(true)).thenReturn(ACCOUNT_PLACEHOLDER);
Mockito.when(accountRepository.findByIsDefault(true)).thenReturn(ACCOUNT_DEFAULT);
assertThat(accountService.getSelectedAccountOrDefaultAsFallback()).isEqualTo(ACCOUNT_DEFAULT);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment