Refactor example data seeds from global variables to library classes
The example data seeds were split across 7 files with dependencies shared via global variables ($project, $guest_person, etc.), making them difficult to test and maintain.
Changes
-
Created
Seek::ExampleDataSeederorchestrator class - coordinates seeding with explicit dependency management through constructor injection, eliminating global variables -
Extracted 7 specialized seeder classes in
lib/seek/example_data/:-
ProjectsSeeder,UsersSeeder,IsaStructureSeeder,SamplesSeeder -
DataFilesAndModelsSeeder,PublicationsSeeder,ConfigurationSeeder
-
- Added unit tests covering seeder classes with validation of object creation and database population
-
Simplified main seed file from 8
require_relativestatements to:
seeder = Seek::ExampleDataSeeder.new
seeder.seed_all
- Removed 7 legacy seed files (621 lines) replaced by library classes (915 lines)
-
Added README in
lib/seek/example_data/documenting structure and extension patterns
Structure
Each seeder returns created objects via hash, enabling explicit dependency flow:
def seed_users
seeder = Seek::ExampleData::UsersSeeder.new(@workgroup, @project, @institution)
result = seeder.seed
@admin_user = result[:admin_user]
@guest_person = result[:guest_person]
end
Dependencies cascade through orchestrator methods, making the data creation flow clear and testable in isolation.
Original prompt
This section details on the original issue you should resolve
<issue_title>Clean up the example data seeds into a single seed that calls a class in the library</issue_title> <issue_description>Currently the example_data seed (db/seeds/example_data/) is split across multiple seeds, with dependencies and global variables spread between them.
Refactor into a single seed that calls a separate class to populate the data, possibly with multiple classes for each type. Some simple unit tests can then be created to provide some sanity checks that it is populating the database correctly.
Make it so it is easier to maintain and add new example data in the future.</issue_description>
Comments on the Issue (you are @copilot in this section)
- Fixes seek4science/seek#2382
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.