create SQL function for get citizen votes with multiple target ids
add updated_at field on vote table
This commit is contained in:
@@ -29,3 +29,10 @@ Feature: vote Article
|
||||
| limit | 50 |
|
||||
| total | 1 |
|
||||
| result[0].note | 1 |
|
||||
|
||||
Scenario: Can get votes of current citizen by target ids
|
||||
Given I am authenticated as John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd"
|
||||
When I send a GET request to "/citizens/64b7b379-2298-43ec-b428-ba134930cabd/votes?id=9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b&id=64b1f265-bfb3-332b-eef9-d00f63a3beaa"
|
||||
Then the response status code should be 200
|
||||
And the response should contain object:
|
||||
| [0].note | 1 |
|
||||
|
||||
@@ -38,6 +38,7 @@ declare
|
||||
$json$;
|
||||
votes jsonb;
|
||||
votes_of_citizen json;
|
||||
votes_of_citizen_for_targets json;
|
||||
votes_total int;
|
||||
begin
|
||||
-- insert user for context
|
||||
@@ -97,6 +98,11 @@ begin
|
||||
assert (votes_total = 1), format('votes count for user %s must be 1, instead of %s', _citizen_id, votes_total);
|
||||
assert ((votes_of_citizen#>>'{0,note}')::int = -1), format('the note must be -1, instead of %s', (votes_of_citizen#>>'{0,note}'));
|
||||
|
||||
-- test "find_citizen_votes_by_target_ids"
|
||||
select find_citizen_votes_by_target_ids(_citizen_id, array[(created_article->>'id')]::uuid[]) into votes_of_citizen_for_targets;
|
||||
assert (json_array_length(votes_of_citizen_for_targets) = 1), format('the function must be return 1 vote, instead of %s', json_array_length(votes_of_citizen_for_targets));
|
||||
assert (votes_of_citizen_for_targets#>>'{0,target_id}' = created_article->>'id'), format('target_id of vote must be %s, instead of %s', created_article->>'id', votes_of_citizen_for_targets#>>'{0,target_id}');
|
||||
|
||||
-- delete vote and context
|
||||
delete from vote;
|
||||
delete from article;
|
||||
|
||||
Reference in New Issue
Block a user