Commit c689980
authored
Make SchoolProject destroy dependent Transitions (#667)
Fix an incorrect `depdendent:` rule between `SchoolProject` and
`SchoolProjectTransition`.
## Status
- Closes RaspberryPiFoundation/digital-editor-issues#1126
## Points for consideration:
- Security
- Performance
## What's changed?
### Database and Model Relations and Nullify Rules
Previously, when a SchoolProject was destroyed, there was a rule that
dependent `school_project_transitions` would be nullified rather than
destroyed.
At the same time, the definition of a `SchoolProjectTransition` states
that the `school_project_id`, which refers to the project being
transitioned, CANNOT be null.
Therefore, when PR
[#637](#637)
allowed deletion of Students and, consequently, Projects, the error in
these relations and nullification rules was exposed.
This leads to an error when deleting a Student who owns projects which
have been transitioned.
This PR changes the `dependent:` rule between SchoolProject and
SchoolProjectTransition to destroy the transition when the Proejct is
destroyed. It also adds a test to ensure this happens.
## Follow on Work
While this PR fixes the immediate problem, there remains an issue that
`SchoolStudentsController#destroy_batch` will return a `200` status code
on both success and failure. I suggest we address this in a follow up
issue.
## Steps to perform after deploying to production
NA1 parent 549f781 commit c689980
3 files changed
Lines changed: 18 additions & 2 deletions
File tree
- app/models
- spec
- models
- services
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
82 | 98 | | |
83 | 99 | | |
84 | 100 | | |
| |||
0 commit comments