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

Ensure rails 7.2 compatibility #1686

Merged
merged 3 commits into from
Aug 22, 2024
Merged

Conversation

Earlopain
Copy link
Contributor

@Earlopain Earlopain commented Aug 13, 2024

Closes #1685

This whole thing basically boils down to adding require "active_support".

Additionally, I did the following:

  • Bumped development dependencies. Older versions of sqlite3 fail to compile with gcc 14
  • Locked sqlite3 to ~> 1.4. Rails 7.1 and lower don't accept 2.0
  • Added rails 7.2 to CI
  • Resolved a deprecation warning in tests surrounding enums for rails 7.2 and main

Older versions of `sqlite3` don't compile on recent gcc versions.
Additionally, rails < 7.2 currently doesn't work with `sqlite3 ~> 2.0`
In order to use parts of active_support, active_support itself must be required first.
https://guides.rubyonrails.org/active_support_core_extensions.html#cherry-picking-a-definition

Fixes thoughtbot#1685
sandbergja added a commit to pulibrary/approvals that referenced this pull request Aug 13, 2024
Adds `require "active_support"` to address
thoughtbot/factory_bot#1686
christinach pushed a commit to pulibrary/approvals that referenced this pull request Aug 13, 2024
Adds `require "active_support"` to address
thoughtbot/factory_bot#1686
aramprice added a commit to cloudfoundry/bosh that referenced this pull request Aug 14, 2024
Currently `factory_bot` uses `active_support` but does not folow the
recommendation to require `active_support` before require'ing specific
internals. This is blocking updates to `active_support`.

A PR (thoughtbot/factory_bot#1686) exists to
address this in `factory_bot`. Once it is released this commit should be
reverted.
@rebase-master
Copy link

@sarahraqueld @smaboshe could you please review and merge if the changes look good?

Copy link
Member

@neilvcarvalho neilvcarvalho left a comment

Choose a reason for hiding this comment

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

(not a maintainer)

Looks great! I just added a minor suggestion for the version evaluation.

@@ -1,9 +1,17 @@
describe "enum traits" do
def define_model_with_enum(class_name, field, values)
define_model(class_name, status: :integer) do
if ActiveRecord::VERSION::STRING >= "7.2"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if ActiveRecord::VERSION::STRING >= "7.2"
if ActiveRecord::VERSION::STRING >= "7.0"

While the old syntax was removed on Rails 7.2, the new one was introduced on 7.0. By referencing the version when it was added we can more easily remove the old syntax when we drop support for Rails < 7.0.

(Rails 6.1 will stop receiving security updates in a month or so, by the way)

Copy link
Member

Choose a reason for hiding this comment

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

Oh, it was just deprecated, not removed. I thought it was deprecated when the new syntax landed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, thanks. I applied your suggestion.

> DEPRECATION WARNING: Defining enums with keyword arguments is deprecated and will be removed
in Rails 8.0. Positional arguments should be used instead:
>
> enum :status, {:queued=>0, :started=>1, :finished=>2}

The modern syntax was already introduced in 7.0
Copy link
Contributor

@smaboshe smaboshe left a comment

Choose a reason for hiding this comment

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

Thank you so much!

@smaboshe smaboshe merged commit 1133dcd into thoughtbot:main Aug 22, 2024
26 checks passed
@Earlopain Earlopain deleted the rails-7.2-compat branch August 22, 2024 14:51
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.

require 'factory_bot' fails with latest ActiveSupport gem (7.2.0)
4 participants