-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Migrate to Rails 7.1's file_fixture_upload
naming approach
#2718
base: main
Are you sure you want to change the base?
Conversation
8a17e8d
to
d3e1c4b
Compare
I'm surprised by the test failures here, and am curious if they are due to something recent in another rspec gem (tests haven't been run on |
This is actually due to the ameter gem adding a deprecation warning to a matcher we apparently used in our generator specs it looks like its an RSpec problem but its just we check our builds for warnings and so the error is hidden slightly, working on a fix in #2719 and then this can be rebased :) |
71f11b4
to
bc7d3b1
Compare
@JonRowe thanks for the quick fix there! I've rebased this and gotten tests passing. It took an extra pass to add the appropriate testing for Rails 7.1+ and < 7.1, but I think things are in good shape now. Let me know if there's anything else I should change. |
module FixtureFileUploadSupport | ||
delegate :fixture_file_upload, to: :rails_fixture_file_wrapper | ||
module FileFixtureUploadSupport | ||
delegate :file_fixture_upload, :fixture_file_upload, to: :rails_file_fixture_wrapper |
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.
One minor note... I have included the delegation for file_fixture_upload
in all Rails versions, even though it's only available in Rails 7.1.+. It should raise a NoMethodError
if called in Rails < 7.1.
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.
I'm confused as to what provides the old behaviour with this change, I can see the build passing but I don't understand what now provides fixture_file_upload
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.
@JonRowe it's hard to see, since file_fixture_upload
and fixture_file_upload
look so similar, but fixture_file_upload
is on this same delegate
line, after file_fixture_upload
.
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.
Ah I see, sorry!
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.
No problem!
Overall this looks fine, but I'm nervous of the support differences for 6.1 and 7.x, especially the change in module. Could I be a pain and ask you split this into two, with the old module for the old behaviour and the new module, and conditionally include the right module? If you don't want to I'm happy to finish this off |
Happy to, @JonRowe! I should be able to do that tonight. |
rails/rails#48857 renamed `fixture_file_upload` to `file_fixture_upload` to reduce "confusion and surprise". With this change, `file_fixture_upload` now works in RSpec, with `fixture_file_upload` still functional to maintain backwards compatibility.
bc7d3b1
to
d5c6107
Compare
@JonRowe when I started looking at this, I actually noticed that rspec-rails/lib/rspec/rails/fixture_file_upload_support.rb Lines 31 to 35 in cbc6fcc
With that in mind, I made a change that is more explicit about which methods are supported, but I left it in the same module. I'm curious if you think that's reasonable, or if you'd still prefer to break things apart. |
rails/rails#48857 renamed
fixture_file_upload
tofile_fixture_upload
to reduce "confusion and surprise". With this change,file_fixture_upload
now works in RSpec, withfixture_file_upload
still functional to maintain backwards compatibility.