-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Conversation
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
4e54390
to
d12b7af
Compare
Adds `require "active_support"` to address thoughtbot/factory_bot#1686
Adds `require "active_support"` to address thoughtbot/factory_bot#1686
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.
@sarahraqueld @smaboshe could you please review and merge if the changes look good? |
There was a problem hiding this 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.
spec/acceptance/enum_traits_spec.rb
Outdated
@@ -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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
d12b7af
to
192d5f5
Compare
There was a problem hiding this 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!
Closes #1685
This whole thing basically boils down to adding
require "active_support"
.Additionally, I did the following:
sqlite3
fail to compile with gcc 14sqlite3
to~> 1.4
. Rails 7.1 and lower don't accept 2.0