I do not have more time to update the update to the company today, but i believe this is already a good amount of work for a commit. The company is going to be used for row level security, as users will only have access to the data from companies they are granted access, by virtue of being in the company_user relation. I did not know how add a row level security policy to the company_user because i needed the to select on the same relation and this is not allowed, because it would create an infinite loop. Had to add the vat, pg_libphonenumber, and uri extensions in order to validate VAT identification numbers, phone numbers, and URIs, repectively. These libraries are not in Debian, but i created packages for them all in https://dev.tandem.ws/tandem.
43 lines
1.3 KiB
PL/PgSQL
43 lines
1.3 KiB
PL/PgSQL
-- Test currency
|
|
set client_min_messages to warning;
|
|
create extension if not exists pgtap;
|
|
reset client_min_messages;
|
|
|
|
begin;
|
|
|
|
select plan(20);
|
|
|
|
set search_path to numerus, public;
|
|
|
|
select has_table('currency');
|
|
select has_pk('currency');
|
|
select table_privs_are('currency', 'guest', array []::text[]);
|
|
select table_privs_are('currency', 'invoicer', array ['SELECT']);
|
|
select table_privs_are('currency', 'admin', array ['SELECT']);
|
|
select table_privs_are('currency', 'authenticator', array []::text[]);
|
|
|
|
select has_column('currency', 'currency_code');
|
|
select col_is_pk('currency', 'currency_code');
|
|
select col_type_is('currency', 'currency_code', 'currency_code');
|
|
select col_not_null('currency', 'currency_code');
|
|
select col_hasnt_default('currency', 'currency_code');
|
|
|
|
select has_column('currency', 'currency_symbol');
|
|
select col_type_is('currency', 'currency_symbol', 'text');
|
|
select col_not_null('currency', 'currency_symbol');
|
|
select col_hasnt_default('currency', 'currency_symbol');
|
|
|
|
select has_column('currency', 'decimal_digits');
|
|
select col_type_is('currency', 'decimal_digits', 'integer');
|
|
select col_not_null('currency', 'decimal_digits');
|
|
select col_has_default('currency', 'decimal_digits');
|
|
select col_default_is('currency', 'decimal_digits', 2);
|
|
|
|
set client_min_messages to warning;
|
|
truncate currency cascade;
|
|
reset client_min_messages;
|
|
|
|
|
|
select finish();
|
|
rollback;
|