-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: application list should retrieve the latest *submitted* status
- Loading branch information
1 parent
3f77cf6
commit ee2507c
Showing
9 changed files
with
124 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
schema/deploy/computed_columns/application_latest_submitted_revision_status.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-- Deploy ggircs-portal:computed_columns/application_latest_submitted_revision_status to pg | ||
|
||
begin; | ||
|
||
create or replace function ggircs_portal.application_latest_submitted_revision_status(app ggircs_portal.application) | ||
returns ggircs_portal.ciip_application_revision_status | ||
as $$ | ||
select application_revision_status | ||
from ggircs_portal.application_revision_status | ||
where application_id = app.id | ||
and version_number = (ggircs_portal.application_latest_submitted_revision(app::ggircs_portal.application)).version_number | ||
order by id desc | ||
limit 1; | ||
$$ language sql stable; | ||
|
||
comment on function ggircs_portal.application_latest_submitted_revision_status(ggircs_portal.application) is E'@sortable\nReturns the current status of an application, excluding application revisions that are not submitted yet (i.e. in draft)'; | ||
|
||
commit; |
7 changes: 7 additions & 0 deletions
7
schema/revert/computed_columns/application_latest_submitted_revision_status.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Revert ggircs-portal:computed_columns/application_latest_submitted_revision_status from pg | ||
|
||
begin; | ||
|
||
drop function ggircs_portal.application_latest_submitted_revision_status; | ||
|
||
commit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
schema/test/unit/computed_columns/application_latest_submitted_revision_status_test.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
begin; | ||
set client_min_messages to warning; | ||
create extension if not exists pgtap; | ||
|
||
select plan(3); | ||
truncate ggircs_portal.application restart identity cascade; | ||
select test_helper.modify_triggers('disable'); | ||
reset client_min_messages; | ||
select test_helper.mock_open_window(2019); | ||
select ggircs_portal.create_application_mutation_chain(1); | ||
|
||
select is( | ||
( | ||
select * from ggircs_portal.application_latest_submitted_revision_status((select row(application.*)::ggircs_portal.application from ggircs_portal.application where id = 1)) | ||
), | ||
null, | ||
'The latest submitted revision status should be null if the application was not submitted' | ||
); | ||
|
||
insert into ggircs_portal.application_revision_status(application_id, version_number, application_revision_status) values (1, 1, 'submitted'); | ||
|
||
select is( | ||
( | ||
select * from ggircs_portal.application_latest_submitted_revision_status((select row(application.*)::ggircs_portal.application from ggircs_portal.application where id = 1)) | ||
), | ||
'submitted', | ||
'The latest submitted revision status should be "submitted" if the application was submitted' | ||
); | ||
|
||
select ggircs_portal.create_application_revision_mutation_chain(1,1); | ||
|
||
select is( | ||
( | ||
select * from ggircs_portal.application_latest_submitted_revision_status((select row(application.*)::ggircs_portal.application from ggircs_portal.application where id = 1)) | ||
), | ||
'submitted', | ||
'The latest submitted revision status should remain "submitted" if a new application revision was started' | ||
); | ||
|
||
rollback; |
7 changes: 7 additions & 0 deletions
7
schema/verify/computed_columns/application_latest_submitted_revision_status.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Verify ggircs-portal:computed_columns/application_latest_submitted_revision_status on pg | ||
|
||
begin; | ||
|
||
select pg_get_functiondef('ggircs_portal.application_latest_submitted_revision_status(ggircs_portal.application)'::regprocedure); | ||
|
||
rollback; |