Customer does not want a contact page, but a page where they can write the direction on how to reach the campground, with a Google map embed instead of using Leaflet, because Google Maps shows the reviews right in the map. That means i had to replace the GPS locations with XML fields for the customer to write. In all four languages. This time i tried a translation approach inspired by PrestaShop: instead of opening a new page for each language, i have all languages in the same page and use AlpineJS to show just a single language. It is far easier to write the translations, even though you do not have the source text visible, specially in this section that there is no place for me to put the language links.
77 lines
2.9 KiB
PL/PgSQL
77 lines
2.9 KiB
PL/PgSQL
-- Test setup_location
|
|
set client_min_messages to warning;
|
|
create extension if not exists pgtap;
|
|
reset client_min_messages;
|
|
|
|
begin;
|
|
|
|
select plan(15);
|
|
|
|
set search_path to camper, public;
|
|
|
|
select has_function('camper', 'setup_location', array['integer', 'text', 'text', 'text']);
|
|
select function_lang_is('camper', 'setup_location', array['integer', 'text', 'text', 'text'], 'sql');
|
|
select function_returns('camper', 'setup_location', array['integer', 'text', 'text', 'text'], 'void');
|
|
select isnt_definer('camper', 'setup_location', array['integer', 'text', 'text', 'text']);
|
|
select volatility_is('camper', 'setup_location', array['integer', 'text', 'text', 'text'], 'volatile');
|
|
select function_privs_are('camper', 'setup_location', array ['integer', 'text', 'text', 'text'], 'guest', array[]::text[]);
|
|
select function_privs_are('camper', 'setup_location', array ['integer', 'text', 'text', 'text'], 'employee', array[]::text[]);
|
|
select function_privs_are('camper', 'setup_location', array ['integer', 'text', 'text', 'text'], 'admin', array['EXECUTE']);
|
|
select function_privs_are('camper', 'setup_location', array ['integer', 'text', 'text', 'text'], 'authenticator', array[]::text[]);
|
|
|
|
set client_min_messages to warning;
|
|
truncate location 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, rtc_number, country_code, currency_code, default_lang_tag)
|
|
values (1, 'Company 2', 'XX123', '', '555-555-555', 'a@a', '', '', '', '', '', '', 'ES', 'EUR', 'ca')
|
|
, (2, 'Company 4', 'XX234', '', '666-666-666', 'b@b', '', '', '', '', '', '', 'FR', 'USD', 'ca')
|
|
;
|
|
|
|
prepare location_data as
|
|
select company_id, directions::text, map_embed::text, opening_dates::text
|
|
from location
|
|
;
|
|
|
|
select lives_ok(
|
|
$$ select setup_location(1, '<p>Up</p>', '<map/>', '<p>Today</p>') $$,
|
|
'Should be able to setup location parameters for the first company'
|
|
);
|
|
|
|
select lives_ok(
|
|
$$ select setup_location(2, '<p>Left</p>', '<leaflet/>', '<p>Tomorrow</p>') $$,
|
|
'Should be able to setup location parameters for the second company'
|
|
);
|
|
|
|
select bag_eq(
|
|
'location_data',
|
|
$$ values (1, '<p>Up</p>', '<map/>', '<p>Today</p>'),
|
|
(2, '<p>Left</p>', '<leaflet/>', '<p>Tomorrow</p>')
|
|
$$,
|
|
'Should have inserted all location parameters'
|
|
);
|
|
|
|
select lives_ok(
|
|
$$ select setup_location(1, '<p>Down</p>', '<google/>', '<p>Never</p>') $$,
|
|
'Should be able to update location parameters for the first company'
|
|
);
|
|
|
|
select lives_ok(
|
|
$$ select setup_location(2, '<p>Right</p>', '<map/>', '<p>Yesterday</p>') $$,
|
|
'Should be able to update location parameters for the second company'
|
|
);
|
|
|
|
select bag_eq(
|
|
'location_data',
|
|
$$ values (1, '<p>Down</p>', '<google/>', '<p>Never</p>'),
|
|
(2, '<p>Right</p>', '<map/>', '<p>Yesterday</p>')
|
|
$$,
|
|
'Should have updated all location parameters'
|
|
);
|
|
|
|
select *
|
|
from finish();
|
|
|
|
rollback;
|