I intend to use the same SVG file for customers and employees, so i had to change Oriol’s design to add a class to layers that are supposed to be only for customers, like trees. These are hidden in the admin area. I understood that customers and employees have to click on a campsite to select it, and then they can book or whatever they need to do to them. Since customers and employees most certainly will need to have different listeners on campsites, i decided to add the link with JavaScript. To do so, i need a custom XML attribute with the campsite’s identifier. Since i have seen that all campsites have a label, i changed the “identifier” to the unique combination (company_id, label). The company_id is there because different companies could have the same label; i left the campsite_id primary key for foreign constraints. In this case, as a test, i add an <a> element to the campsite with a link to edit it; we’ll discuss with Oriol what exactly it needs to do. However, the original design had the labels in a different layer, that interfered with the link, as the numbers must be above the path and the link must wrap the path in order to “inherit” its shape. I had no other recourse than to move the labels in the same layer as the paths’.
77 lines
2.7 KiB
PL/PgSQL
77 lines
2.7 KiB
PL/PgSQL
-- Test edit_campsite
|
|
set client_min_messages to warning;
|
|
create extension if not exists pgtap;
|
|
reset client_min_messages;
|
|
|
|
begin;
|
|
|
|
set search_path to camper, public;
|
|
|
|
select plan(12);
|
|
|
|
select has_function('camper', 'edit_campsite', array ['integer', 'integer', 'text', 'boolean']);
|
|
select function_lang_is('camper', 'edit_campsite', array ['integer', 'integer', 'text', 'boolean'], 'sql');
|
|
select function_returns('camper', 'edit_campsite', array ['integer', 'integer', 'text', 'boolean'], 'integer');
|
|
select isnt_definer('camper', 'edit_campsite', array ['integer', 'integer', 'text', 'boolean']);
|
|
select volatility_is('camper', 'edit_campsite', array ['integer', 'integer', 'text', 'boolean'], 'volatile');
|
|
select function_privs_are('camper', 'edit_campsite', array ['integer', 'integer', 'text', 'boolean'], 'guest', array[]::text[]);
|
|
select function_privs_are('camper', 'edit_campsite', array ['integer', 'integer', 'text', 'boolean'], 'employee', array[]::text[]);
|
|
select function_privs_are('camper', 'edit_campsite', array ['integer', 'integer', 'text', 'boolean'], 'admin', array['EXECUTE']);
|
|
select function_privs_are('camper', 'edit_campsite', array ['integer', 'integer', 'text', 'boolean'], 'authenticator', array[]::text[]);
|
|
|
|
set client_min_messages to warning;
|
|
truncate campsite cascade;
|
|
truncate campsite_type cascade;
|
|
truncate media cascade;
|
|
truncate media_content cascade;
|
|
truncate company cascade;
|
|
reset client_min_messages;
|
|
|
|
|
|
insert into company (company_id, business_name, vatin, trade_name, phone, email, web, address, city, province, postal_code, country_code, currency_code, default_lang_tag)
|
|
values (1, 'Company 2', 'XX123', '', '555-555-555', 'a@a', '', '', '', '', '', 'ES', 'EUR', 'ca')
|
|
;
|
|
|
|
insert into media_content (media_type, bytes)
|
|
values ('image/x-xpixmap', 'static char *s[]={"1 1 1 1","a c #ffffff","a"};')
|
|
;
|
|
|
|
insert into media (media_id, company_id, original_filename, content_hash)
|
|
values (3, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};'))
|
|
;
|
|
|
|
insert into campsite_type (campsite_type_id, company_id, media_id, name)
|
|
values (11, 1, 3, 'Type A')
|
|
, (12, 1, 3, 'Type B')
|
|
, (13, 1, 3, 'Type C')
|
|
;
|
|
|
|
insert into campsite (campsite_id, company_id, campsite_type_id, label, active)
|
|
values (21, 1, 11, 'A1', true)
|
|
, (22, 1, 12, 'B1', false)
|
|
;
|
|
|
|
select lives_ok(
|
|
$$ select edit_campsite(21, 13, 'C1', false) $$,
|
|
'Should be able to edit the first campsite.'
|
|
);
|
|
|
|
select lives_ok(
|
|
$$ select edit_campsite(22, 12, 'B2', true) $$,
|
|
'Should be able to edit the second campsite.'
|
|
);
|
|
|
|
select bag_eq(
|
|
$$ select campsite_id, campsite_type_id, label, active from campsite $$,
|
|
$$ values (21, 13, 'C1', false)
|
|
, (22, 12, 'B2', true)
|
|
$$,
|
|
'Should have updated all campsites.'
|
|
);
|
|
|
|
|
|
select *
|
|
from finish();
|
|
|
|
rollback;
|