61 lines
2.2 KiB
MySQL
61 lines
2.2 KiB
MySQL
|
-- Test edit_page
|
||
|
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_page', array ['uuid', 'text', 'text']);
|
||
|
select function_lang_is('camper', 'edit_page', array ['uuid', 'text', 'text'], 'sql');
|
||
|
select function_returns('camper', 'edit_page', array ['uuid', 'text', 'text'], 'uuid');
|
||
|
select isnt_definer('camper', 'edit_page', array ['uuid', 'text', 'text']);
|
||
|
select volatility_is('camper', 'edit_page', array ['uuid', 'text', 'text'], 'volatile');
|
||
|
select function_privs_are('camper', 'edit_page', array ['uuid', 'text', 'text'], 'guest', array[]::text[]);
|
||
|
select function_privs_are('camper', 'edit_page', array ['uuid', 'text', 'text'], 'employee', array[]::text[]);
|
||
|
select function_privs_are('camper', 'edit_page', array ['uuid', 'text', 'text'], 'admin', array['EXECUTE']);
|
||
|
select function_privs_are('camper', 'edit_page', array ['uuid', 'text', 'text'], 'authenticator', array[]::text[]);
|
||
|
|
||
|
|
||
|
set client_min_messages to warning;
|
||
|
truncate page 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 page (company_id, slug, title, content)
|
||
|
values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 'Page A', '<p>A</p>')
|
||
|
, (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 'Page B', '<p>B</p>')
|
||
|
;
|
||
|
|
||
|
select lives_ok(
|
||
|
$$ select edit_page('87452b88-b48f-48d3-bb6c-0296de64164e', 'Page 1', '<p>1</p>') $$,
|
||
|
'Should be able to edit the first type'
|
||
|
);
|
||
|
|
||
|
select lives_ok(
|
||
|
$$ select edit_page('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'Page 2', '<p>2</p>') $$,
|
||
|
'Should be able to edit the second type'
|
||
|
);
|
||
|
|
||
|
select bag_eq(
|
||
|
$$ select slug::text, title, content::text from page $$,
|
||
|
$$ values ('87452b88-b48f-48d3-bb6c-0296de64164e', 'Page 1', '<p>1</p>')
|
||
|
, ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'Page 2', '<p>2</p>')
|
||
|
$$,
|
||
|
'Should have updated all pages.'
|
||
|
);
|
||
|
|
||
|
|
||
|
select *
|
||
|
from finish();
|
||
|
|
||
|
rollback;
|