“Finish” the new booking form
Had to bring the same fields that i have for a payment to booking,
except that some of those should be nullable, because it is unreasonable
to ask front desk to gather all customer data when they have a booking
via phone, for instance.
Therefore, i can not take advantage of the validation for customer data
that i use in the public-facing form, but, fortunately, most of the
validations where in separated functions, thus only had to rewrite that
one for this case.
I already have to create a booking from a payment, when receiving a
payment from the public instance, thus i made that function and reused
it here. Then i “overwrite” the newly created pre-booking with the
customer data from the form, and set is as confirmed, as we do not see
any point of allowing pre-bookings from employees.
2024-04-24 18:12:29 +00:00
|
|
|
-- Test booking_option
|
|
|
|
set client_min_messages to warning;
|
|
|
|
create extension if not exists pgtap;
|
|
|
|
reset client_min_messages;
|
|
|
|
|
|
|
|
begin;
|
|
|
|
|
|
|
|
select plan(27);
|
|
|
|
|
|
|
|
set search_path to camper, public;
|
|
|
|
|
|
|
|
select has_table('booking_option');
|
|
|
|
select has_pk('booking_option');
|
|
|
|
select col_is_pk('booking_option', array['booking_id', 'campsite_type_option_id']);
|
2024-04-29 18:59:22 +00:00
|
|
|
select table_privs_are('booking_option', 'guest', array['SELECT', 'INSERT']);
|
“Finish” the new booking form
Had to bring the same fields that i have for a payment to booking,
except that some of those should be nullable, because it is unreasonable
to ask front desk to gather all customer data when they have a booking
via phone, for instance.
Therefore, i can not take advantage of the validation for customer data
that i use in the public-facing form, but, fortunately, most of the
validations where in separated functions, thus only had to rewrite that
one for this case.
I already have to create a booking from a payment, when receiving a
payment from the public instance, thus i made that function and reused
it here. Then i “overwrite” the newly created pre-booking with the
customer data from the form, and set is as confirmed, as we do not see
any point of allowing pre-bookings from employees.
2024-04-24 18:12:29 +00:00
|
|
|
select table_privs_are('booking_option', 'employee', array['SELECT', 'INSERT', 'UPDATE', 'DELETE']);
|
|
|
|
select table_privs_are('booking_option', 'admin', array['SELECT', 'INSERT', 'UPDATE', 'DELETE']);
|
|
|
|
select table_privs_are('booking_option', 'authenticator', array[]::text[]);
|
|
|
|
|
|
|
|
select has_column('booking_option', 'booking_id');
|
|
|
|
select col_is_fk('booking_option', 'booking_id');
|
|
|
|
select fk_ok('booking_option', 'booking_id', 'booking', 'booking_id');
|
|
|
|
select col_type_is('booking_option', 'booking_id', 'integer');
|
|
|
|
select col_not_null('booking_option', 'booking_id');
|
|
|
|
select col_hasnt_default('booking_option', 'booking_id');
|
|
|
|
|
|
|
|
select has_column('booking_option', 'campsite_type_option_id');
|
|
|
|
select col_is_fk('booking_option', 'campsite_type_option_id');
|
|
|
|
select fk_ok('booking_option', 'campsite_type_option_id', 'campsite_type_option', 'campsite_type_option_id');
|
|
|
|
select col_type_is('booking_option', 'campsite_type_option_id', 'integer');
|
|
|
|
select col_not_null('booking_option', 'campsite_type_option_id');
|
|
|
|
select col_hasnt_default('booking_option', 'campsite_type_option_id');
|
|
|
|
|
|
|
|
select has_column('booking_option', 'units');
|
|
|
|
select col_type_is('booking_option', 'units', 'positive_integer');
|
|
|
|
select col_not_null('booking_option', 'units');
|
|
|
|
select col_hasnt_default('booking_option', 'units');
|
|
|
|
|
|
|
|
select has_column('booking_option', 'subtotal');
|
|
|
|
select col_type_is('booking_option', 'subtotal', 'nonnegative_integer');
|
|
|
|
select col_not_null('booking_option', 'subtotal');
|
|
|
|
select col_hasnt_default('booking_option', 'subtotal');
|
|
|
|
|
|
|
|
|
|
|
|
select *
|
|
|
|
from finish();
|
|
|
|
|
|
|
|
rollback;
|
|
|
|
|