Repository navigation
Conversation
The database the app runs on has constraints the migration-built schema does not: datasets.website_id is a foreign key that defaults to 1, and units.name is unique. With a schema dumped from that database 53 specs failed on the first and 3 on the second. - the dataset factory gives each dataset the lter website, creating it when the spec has not (find_or_create_by, so a spec that makes its own does not get a second one) - the unit factory numbers its names - the csv_headers spec no longer makes a second lter website; the factory's dataset already has one with that url The suite passes on both the migration-built schema and the one from the real database. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016AR3uoZS1uCC8hXmojk3K7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The database the app runs on has constraints the migration-built schema (
db/schema.rbbefore 7f502da, and #57) doesn't. A schema dumped from it made the suite fail, because the factories made records that break those constraints:datasets.website_idis a foreign key towebsitesthat defaults to 1. The:datasetfactory never set a website, so every dataset got website 1, which doesn't exist in a test database. This caused 53 of 53 failures.units.nameis unique (unit_names_key). The:unitfactory always used'per something', so a spec that made two variates failed. This caused the next 3.Changes (tests only; no app or production code):
website { Website.find_or_create_by!(name: 'lter') { |site| site.url = 'lter.kbs.msu.edu' } }. Each dataset gets thelterwebsite, and it is created when the spec hasn't, so a spec that makes its own doesn't end up with a second.per something 1,per something 2, ...).spec/models/datatable_spec.rb: the#csv_headersspecs created a secondlterwebsite after the factory had made one, andWebsiterejects duplicate names. The factory's dataset already has a site with that URL, so the redundantbeforeblock is removed.If a new spec creates
Website.create!(name: 'lter')after a factory dataset exists, it will hit the same duplicate-name error. Usefind_or_create_by!there, or create the site first.Testing
321 examples, 0 failures, 3 pending, on both:
barcode,spatial_ref_sysand thetopologytables, and with two legacy sequence names changed to serial), loaded into a fresh PostgreSQL 17 database with PostGIS.Master's current
db/schema.rbstill can't be loaded into a fresh database; that's #57. This PR doesn't depend on it and the two don't conflict.Generated by Claude Code