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

Rails 7 mvp (just get it runnable with rails 7) #146

Merged
merged 4 commits into from
Jul 23, 2024

Conversation

jrafanie
Copy link
Member

@jrafanie jrafanie commented Jun 21, 2024

These were extracted from #133

  • Allow rails 7 in gemspec
  • Use new location for grouped_records in rails 7, add our patches to it
  • Remove rails 6.0 and lower code

Additionally, I added warnings if the expected class is missing instance methods for the different versions of rails. That way, if we try to prepend methods in future versions, we'll know if they were renamed or removed.

💚 Cross repo

@miq-bot miq-bot added the wip Work in progress label Jun 21, 2024
klass.instance_method(instance_method)
rescue NameError => err
msg = "#{klass} is missing the method our prepended code is expecting to patch. Was the undefined method removed or renamed upstream?\nSee: #{__FILE__}.\nThe NameError was: #{err}. "
raise NameError, msg
Copy link
Member Author

Choose a reason for hiding this comment

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

Wording is hard. Here's what it looks like when I run the tests with a bogus xxx method added to the list of methods we expect to be there:

NameError:
  ActiveRecord::Associations::Preloader is missing the method our prepended code is expecting to patch. Was the undefined method removed or renamed upstream?
  See: /Users/joerafaniello/Code/activerecord-virtual_attributes/lib/active_record/virtual_attributes/virtual_fields.rb.
  The NameError was: undefined method `xxx' for class `ActiveRecord::Associations::Preloader'

      klass.instance_method(instance_method)
           ^^^^^^^^^^^^^^^^.

      raise NameError, msg
      ^^^^^

Copy link
Member Author

Choose a reason for hiding this comment

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

We will have to bump the minor version for this anyway with adding rails 7 support but since we're already dropping 6.0 and older, we can include this and just bump the major version.

Copy link
Member

Choose a reason for hiding this comment

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

remember, this is not semver, we need to follow versions that signify this is good for rails 7.0.x - so we'll be using 7.0.y (y is not x, x is theirs, y is ours)

@jrafanie
Copy link
Member Author

@miq-bot cross-repo-tests /all

@jrafanie
Copy link
Member Author

jrafanie commented Jun 28, 2024

Cross repo is green for this on rails 6.1. I'm continuing to look at rails 7 failures in cross repo plus this branch but they may be unrelated to this branch. Getting this merged into master will help. We can release a tag when I confirm there are no other rails 7 fixes needed.

@jrafanie jrafanie added enhancement New feature or request and removed wip Work in progress labels Jun 28, 2024
@jrafanie jrafanie changed the title [WIP] Rails 7 mvp (just get it runnable with rails 7) Rails 7 mvp (just get it runnable with rails 7) Jun 28, 2024
@jrafanie
Copy link
Member Author

jrafanie commented Jul 9, 2024

@kbrock this is ready for review/merge. Thanks!

@jrafanie jrafanie force-pushed the rails7_mvp branch 3 times, most recently from b375aa9 to bb51ec9 Compare July 10, 2024 15:10
@jrafanie
Copy link
Member Author

I fixed most of the cops, leaving the remaining as that is how it was coming from rails with our minor changes.

@miq-bot
Copy link
Member

miq-bot commented Jul 10, 2024

Checked commits jrafanie/activerecord-virtual_attributes@9885686~...f8b0bc7 with ruby 3.1.5, rubocop 1.56.3, haml-lint 0.51.0, and yamllint
1 file checked, 3 offenses detected

lib/active_record/virtual_attributes/virtual_fields.rb

@jrafanie
Copy link
Member Author

Ok, I've addressed the comments, most of the cops and cross repo is green on Rails 6.1.

@jrafanie
Copy link
Member Author

@Fryguy this is ready for review/merge

@jrafanie
Copy link
Member Author

This is ready for review/merge. Thanks!

@jrafanie
Copy link
Member Author

@kbrock what are your thoughts on merging/releasing this one?

@kbrock
Copy link
Member

kbrock commented Jul 23, 2024

I admit I'm a little hesitant on deleting the calculate.
Hard to remember the exact issue why e needed to add that clause.

But LGTM

UPDATE: those virtual total tests are very pedantic. Feeling much more comfortable after reading through those again. Feels like it would be very tricky for anything to sneak by

@kbrock kbrock merged commit f1bd0ae into ManageIQ:master Jul 23, 2024
5 checks passed
@jrafanie jrafanie deleted the rails7_mvp branch January 16, 2025 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants