Conversation
Test coverage90.15% line coverage reported by SimpleCov. |
There was a problem hiding this comment.
Pull request overview
This PR turns POST /api/scratch/projects into a real “remix-only” endpoint and aligns Scratch remix creation with the shared remix creation path used by HTML/Python, while fixing context loading for remixed projects without lessons.
Changes:
- Implement Scratch remix creation in
Api::Scratch::ProjectsController#create, including original project loading and authorization. - Extend
Project::CreateRemixto generate identifiers server-side and to copy components/Scratch content from the original when not supplied. - Fix project context JSON rendering and authorization for student remixes without lessons, with supporting request/spec updates.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| app/controllers/api/scratch/projects_controller.rb | Implements real Scratch remix creation flow and request parsing for Scratch content. |
| lib/concepts/project/operations/create_remix.rb | Updates shared remix operation to support server-side identifiers and Scratch content copying/override. |
| app/models/ability.rb | Grants show_context ability for relevant project-access paths (own projects + student remixes). |
| app/views/api/projects/context.json.jbuilder | Makes class_id derivation nil-safe when a project has no lesson. |
| spec/requests/projects/show_context_spec.rb | Adds coverage for student loading context of their own remix without a lesson. |
| spec/features/scratch/creating_a_scratch_project_spec.rb | Expands request coverage for Scratch remix creation (auth, gating, missing/invalid original, unauthorized original, success behavior). |
| spec/concepts/project/create_remix_spec.rb | Adds unit coverage for copying/overriding Scratch component content during remix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d6300e3 to
1ae87ea
Compare
Thanks for explaining, but still don't fully understand this problem and the need for the new permission. Is this something that is not working at the moment for non-scratch projects? Around for talking though if easier. |
d6e4f8b to
555891d
Compare
Replace the stubbed POST /api/scratch/projects flow with a real remix-only create path for Scratch saves. This keeps the Scratch request/response contract intact while validating the source project, user access, and submitted Scratch payload.
Keep the existing non-Scratch remix flow intact and add a Scratch-specific branch that stores scratch_component content for remixed projects. The unit coverage now exercises the Scratch remix path directly.
555891d to
24cfdd7
Compare
Closes: https://github.com/RaspberryPiFoundation/digital-editor-issues/issues/1237
POST /api/scratch/projects now performs the real Scratch first-save remix flow for logged-in users with Scratch enabled. The endpoint is remix-only: it requires is_remix=1 and original_id, loads the original project from original_id, returns 401 if the current user cannot access that project, translates the Scratch save payload into scratch_component content, calls Project::CreateRemix, and returns the Scratch response shape:
{ "status": "ok", "content-name": "" }
Also included:
remix-flow.mov