Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: makes changes to accomodate removing seeding #4220

Merged

Conversation

elasticspoon
Copy link
Collaborator

@elasticspoon elasticspoon commented Mar 25, 2024

Related to #4199

Makes changes to factories, models, and rails helper needed to allow removal of seeding.
Adds RSpec meta tag seed_items when set to false will disable seeding of items on a per test basis.
ENV flag SKIP_SEED=true will prevent rspec seeding before the suite runs.

Note

I added some comments in places because I found stuff confusing. Those can be removed in the final PR but most of them felt like stuff worth bringing up.

Additional note: the speedup was actually much less than I expected, across all the models I saw only a 5s speedup, from 29s to 25s

Type of change

  • Refactor

How Has This Been Tested?

Passes all tests

@@ -26,7 +26,7 @@ class Kit < ApplicationRecord
scope :by_partner_key, ->(key) { joins(:items).where(items: { partner_key: key }) }
scope :by_name, ->(name) { where("name ILIKE ?", "%#{name}%") }

validates :organization, :name, presence: true
validates :name, presence: true
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It belong_to an org, validation feels unneseccary.

Copy link
Collaborator

Choose a reason for hiding this comment

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

belongs_to used to imply optional - that switched to mandatory by default, so yep, a validation is redundant.

@elasticspoon elasticspoon force-pushed the remove-spec-seeding-base-changes branch 2 times, most recently from ef7303c to aa72dd5 Compare March 25, 2024 00:33
Makes changes to factories, models, and
rails helper needed to allow removal of seeding.

Adds RSpec meta tag seed_items when set to false
will disable seeding of items on a per test basis.

ENV flag SKIP_SEED=true will prevent rspec seeding
before the suite runs.
Copy link
Collaborator

@dorner dorner left a comment

Choose a reason for hiding this comment

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

Like the approach. I do think the comments should be stripped before merging - feel free to open some additional PRs with some function or variable renames. (You can probably put them in a single PR.)

app/models/base_item.rb Outdated Show resolved Hide resolved
@@ -26,7 +26,7 @@ class Kit < ApplicationRecord
scope :by_partner_key, ->(key) { joins(:items).where(items: { partner_key: key }) }
scope :by_name, ->(name) { where("name ILIKE ?", "%#{name}%") }

validates :organization, :name, presence: true
validates :name, presence: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

belongs_to used to imply optional - that switched to mandatory by default, so yep, a validation is redundant.

app/models/organization.rb Outdated Show resolved Hide resolved
app/models/product_drive.rb Outdated Show resolved Hide resolved
app/models/product_drive.rb Outdated Show resolved Hide resolved
spec/factories/distributions.rb Outdated Show resolved Hide resolved
spec/factories/organizations.rb Show resolved Hide resolved
spec/factories/kits.rb Outdated Show resolved Hide resolved
spec/factories/partners/child.rb Outdated Show resolved Hide resolved
@dorner dorner added the BLOCKER This issue blocks others and should be prioritized label Mar 26, 2024
@dorner
Copy link
Collaborator

dorner commented Mar 28, 2024

@elasticspoon all looks good to me! Some conflicts though ☹️

@elasticspoon
Copy link
Collaborator Author

elasticspoon commented Mar 28, 2024

@dorner fixed (failure is a flake i'm pretty sure)

@dorner dorner merged commit fdbf4c0 into rubyforgood:main Mar 28, 2024
19 checks passed
@dorner
Copy link
Collaborator

dorner commented Mar 28, 2024

Nice! Thank you!

@elasticspoon elasticspoon deleted the remove-spec-seeding-base-changes branch March 28, 2024 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BLOCKER This issue blocks others and should be prioritized
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants