Skip to content

Endure seeding test#733

Merged
abcampo-iry merged 2 commits intomainfrom
issues/727-endure-seeding-task
Mar 13, 2026
Merged

Endure seeding test#733
abcampo-iry merged 2 commits intomainfrom
issues/727-endure-seeding-task

Conversation

@abcampo-iry
Copy link
Contributor

@abcampo-iry abcampo-iry commented Mar 13, 2026

Reported:

1) test_seeds :seed_a_school_with_lessons_and_students creates class with lessons for the owner
     Failure/Error: expect(Lesson.where(school_id:, school_class_id: school_class.id).length).to eq(2)

       expected: 2
            got: 4

       (compared using ==)
     # ./spec/lib/test_seeds_spec.rb:67:in 'block (3 levels) in <top (required)>'
     # ./spec/rails_helper.rb:108:in 'block (3 levels) in <top (required)>'
     # ./spec/rails_helper.rb:106:in 'block (2 levels) in <top (required)>'

Updated rake task to avoid duplicating Lesson.
Added a test to make sure idempotency on this rake task.

Diff seems bigger than it is, only small replacement.

- After seeing the flakiness, I've endured a bit the test to ensure is
  idempotent and we can run without flakyness
Copilot AI review requested due to automatic review settings March 13, 2026 13:36
@cla-bot cla-bot bot added the cla-signed label Mar 13, 2026
@github-actions
Copy link

github-actions bot commented Mar 13, 2026

Test coverage

90.09% line coverage reported by SimpleCov.
Run: https://github.com/RaspberryPiFoundation/editor-api/actions/runs/23053695799

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes flaky/accumulative behavior in the test_seeds:create rake task by preventing re-seeding into an already-seeded test school, and adds a spec asserting the task is idempotent to avoid future regressions.

Changes:

  • Update test_seeds:create to detect an existing seeded school by ID and no-op instead of re-creating seed data.
  • Add an RSpec example verifying re-invoking the rake task doesn’t change counts for classes/lessons/projects.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
lib/tasks/test_seeds.rake Prevents duplicate seed creation by skipping the seeding transaction when the test school already exists.
spec/lib/test_seeds_spec.rb Adds an idempotency test to ensure the seeding task doesn’t create duplicates when invoked multiple times.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@abcampo-iry abcampo-iry changed the title Enduring seeding test Endure seeding test Mar 13, 2026
Copy link
Contributor

@zetter-rpf zetter-rpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great spot on the id/code miss-match

@abcampo-iry abcampo-iry merged commit 726c3fa into main Mar 13, 2026
6 checks passed
@abcampo-iry abcampo-iry deleted the issues/727-endure-seeding-task branch March 13, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants