Skip to content

Commit

Permalink
fix: Analytics column permissions (#2403)
Browse files Browse the repository at this point in the history
* fix: Analytics column permissions

* test: Fix Hasura tests
  • Loading branch information
DafyddLlyr authored Nov 8, 2023
1 parent 2433093 commit 33a3e9b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
9 changes: 9 additions & 0 deletions hasura.planx.uk/metadata/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
columns:
- id
filter: {}
update_permissions:
- role: public
permission:
columns:
- ended_at
filter: {}
check: null
- table:
schema: public
name: analytics_logs
Expand All @@ -42,6 +49,7 @@
- analytics_id
- created_at
- id
- user_exit
filter: {}
update_permissions:
- role: public
Expand All @@ -51,6 +59,7 @@
- has_clicked_help
- metadata
- next_log_created_at
- user_exit
filter: {}
check: null
- table:
Expand Down
14 changes: 10 additions & 4 deletions hasura.planx.uk/tests/analytics.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ describe("analytics and analytics_logs", () => {
expect(i.queries).toContain("analytics_logs");
});

test("can create analytics but not update or delete them", () => {
test("can create analytics", () => {
expect(i.mutations).toContain("insert_analytics_one");
expect(i.mutations).not.toContain("update_analytics_by_pk");
expect(i.mutations).not.toContain("update_analytics");
});

test("can update analytics", () => {
expect(i.mutations).toContain("update_analytics_by_pk");
expect(i.mutations).toContain("update_analytics");
});

test("cannot delete analytics", () => {
expect(i.mutations).not.toContain("delete_analytics");
expect(i.mutations).not.toContain("delete_analytics_by_pk");
});
Expand All @@ -25,7 +31,7 @@ describe("analytics and analytics_logs", () => {
expect(i.mutations).toContain("update_analytics_logs_by_pk");
expect(i.mutations).not.toContain("delete_analytics_logs");
expect(i.mutations).not.toContain("delete_analytics_logs_by_pk");
})
});
});

describe("admin", () => {
Expand Down

0 comments on commit 33a3e9b

Please sign in to comment.