Record source project when adding ExCS projects - #989
Conversation
Test coverage93.51% line coverage reported by SimpleCov. |
There was a problem hiding this comment.
Pull request overview
This PR introduces a dedicated source_project_id lineage field on Project to track Experience CS “source” projects separately from remix lineage, avoiding behavior/permission regressions tied to remixed_from_id.
Changes:
- Add
projects.source_project_idwith a self-referential FK (nullified on source deletion) and correspondingProjectassociations (source_project/derived_projects). - Ensure lesson project creation records
source_project_idand explicitly clears remix fields during ExCS-to-lesson copying. - Add specs covering association behavior, lesson copy behavior, and remix behavior when a project already has a
source_project.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
app/models/project.rb |
Adds self-referential associations for source_project and derived_projects. |
lib/concepts/lesson/operations/create.rb |
Sets source_project_id for ExCS-based lesson project copies and clears remix fields. |
db/migrate/20260828095502_add_source_project_to_projects.rb |
Adds source_project reference to projects with FK nullify-on-delete. |
db/schema.rb |
Reflects the new column, index, and FK. |
spec/models/project_spec.rb |
Adds association coverage and verifies nullification when source project is destroyed. |
spec/concepts/project/create_remix_spec.rb |
Verifies remixes preserve source_project_id while remixed_from_id points to the immediate parent. |
spec/concepts/lesson/create_spec.rb |
Asserts lesson creation records source_project_id and does not inherit remix fields from the source. |
spec/concepts/lesson/create_copy_spec.rb |
Ensures lesson copy preserves source_project_id when copying a lesson whose project already has a source. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Thanks for investigating. I want to think about this a bit more - I'm worried adding another similar column to projects might be confusing so want to think through if there any any alternatives or ways to make this clearer. |
There was a problem hiding this comment.
Great,
I've had a longer think about this, the thing I don't like about the existing code is how the permissions rely on remixed_from_id to determine what students and teachers should do with a project. I think if a project has been remixed should be a separate concern to if a student or teacher should be able to see it. Currently checking remixes does add complexity to the abilities as we're doing additional database loads for this.
But, even if we changed the abilities, I don't think it would be right to populate the remixed_from_id as part of this - remixing is a different action to what we're doing here (as you said in the description).
Status
Why not reuse
remixed_from_id?What's changed?
source_project_idcolumn