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

[#5851] Review new framework defaults #8120

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from

Conversation

gbp
Copy link
Member

@gbp gbp commented Feb 5, 2024

Relevant issue(s)

Fixes #5851

What does this do?

Lazy review of the new framework defaults. Testing to see if the specs pass with the new defaults used.

Why was this needed?

So we can upgrade Rails further.

@gbp gbp marked this pull request as draft February 5, 2024 10:01
@gbp gbp force-pushed the review-new-framework-defaults branch from 4ed6ccb to 3af87a4 Compare April 16, 2024 09:03
@gbp gbp added the on-staging label Apr 16, 2024
@gbp gbp marked this pull request as ready for review April 16, 2024 11:03
@gbp
Copy link
Member Author

gbp commented Apr 16, 2024

This is on deployed to staging. I'm thinking this might be good to merge but will see if there are issues when testing other features on there.

@gbp gbp removed the on-staging label Apr 30, 2024
config/application.rb Outdated Show resolved Hide resolved
@gbp gbp marked this pull request as draft August 14, 2024 11:09
@gbp gbp force-pushed the review-new-framework-defaults branch 2 times, most recently from 0b4ab2b to 2731159 Compare December 17, 2024 06:20
gbp added 4 commits December 20, 2024 11:56
Ensure categories have parent associations.

This change enforces parent associations for categories to support
Rails 5.0's `active_record.belongs_to_required_by_default` setting.
Disable parent/child relation validation.

This change is needed so test examples pass after enabling support for
Rails 5.0's `active_record.belongs_to_required_by_default` setting.
Use test factory so the instance has belongs_to associated objects.

This change is needed so this test example passes after enabling support
for Rails 5.0's `active_record.belongs_to_required_by_default` setting.
Configure Comment#user to be optional.

Although we have a DB not null constraint we need to allow user to be
optional as the controller calls `invalid?` and to allow the form to be
rendered prior login.
@gbp gbp force-pushed the review-new-framework-defaults branch from 2731159 to 3b3765f Compare December 20, 2024 16:50
gbp added 15 commits December 20, 2024 16:52
Configure optional associations.

This change is needed so test examples pass after enabling support for
Rails 5.0's `active_record.belongs_to_required_by_default` setting.
Check errors include message for required belongs_to associations.

This change ensures these test examples will pass after enabling support
for Rails 5.0's `active_record.belongs_to_required_by_default` setting.
In the test environment some `script` test examples look at output
stderr. When doing Rails upgrades we sometimes see deprecation warnings
on boot and these examples will fail.

This change adds a new ENV which can be set to silence these warnings.
Ensures translation objects are correctly build with `globalized_model`
association.

This change is needed so test examples pass after enabling support for
Rails 5.0's `active_record.belongs_to_required_by_default` setting.
Added so we can review these options.
Add examples where we already validated belongs_to associations.

These additional test examples will be useful after we turn on Rails
5.0's `active_record.belongs_to_required_by_default` setting as we will
be able to clean up the `validates presence` calls.
Don't validate this association is present as we already have
validation in place with a custom error message.
These validations are now covered by the relevant belongs_to
association.
This is already called from an before action hook.

Calling it a second time works until we enable the Rails 6.1's framework
default configuration options due to Rails now tracking built associated
objects resulting in two TrackThing instances, but only one being assign
values for required attributes.
So there is better visibility why these have been set without going into
the git commit history.
It appears Rails 6.1's `active_record.has_many_inversing` configuration
option change has introduced a regression in Rails which causes issues
with our code base.

We expect the follow to work, but with this configuration options this
breaks due to how we associated objects via FactoryBot in our test
suite:

  user = User.new
  info_request = InfoRequest.new(user: user)
  comment = Comment.create!(info_request: info_request, user: user)
@gbp gbp force-pushed the review-new-framework-defaults branch from 3b3765f to 6925bdf Compare December 20, 2024 16:52
@gbp gbp marked this pull request as ready for review December 20, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Review new framework defaults
1 participant