Commit 04610cf
committed
Return a 404 if a Scratch project doesn't exist
Fixes RaspberryPiFoundation/digital-editor-issues#1269
Previously a 500 was raised because we would try to access the scratch component of an `nil` object or if we tried to load a project that was of another type.
I think we've overcomplicated this by using the ProjectFinder and loading by locale. API requests from Scratch won't have a locale set so it's confusing to make it look like we're supporting multiple locales from Scratch.
Instead use the Rails Finders for loading, which will raise as expected if a record isn't found.1 parent 38be3fb commit 04610cf
3 files changed
Lines changed: 16 additions & 9 deletions
File tree
- app/controllers/api/scratch
- spec/features/scratch
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
| 65 | + | |
72 | 66 | | |
73 | 67 | | |
74 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
| 21 | + | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
21 | 35 | | |
0 commit comments