-
-
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
Various fixes for Rails 6 #2100
Conversation
945cbee
to
2f646a9
Compare
Hi, thanks for this, Rails 6 support work is on going in |
I suggest you rebase if you can! |
Argh ok sorry about that I hadn't spotted that branch. I have rebased as requested. Thanks for taking a look! |
2f646a9
to
1350b53
Compare
lib/rspec/rails/view_rendering.rb
Outdated
@@ -56,7 +56,7 @@ def self.nullify_template_rendering(templates) | |||
template.identifier, | |||
EmptyTemplateHandler, | |||
:virtual_path => template.virtual_path, | |||
:format => template.formats | |||
:format => template.respond_to?(:format) ? template.format : template.formats |
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.
Great, is this a Rails specific or object specific? e.g. will we encounter both methods in one version of Rails? If so we prefer conditionally defining a method to extract this to save runtime conditionals.
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.
template.formats
is deprecated in Rails 6, so we could rely on the Rails version instead, perhaps something like this?:
def self.template_format(template)
if Rails::VERSION::STRING >= '6'
template.format
else
template.formats
end
end
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.
Right so if this is Rails 6 only we'd typically do:
if Rails::VERSION::STRING >= '6'
def self.template_format(format)
template.format
end
else
def self.template_format(format)
template.formats
end
end
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.
That makes sense, thanks @JonRowe!
1350b53
to
712c099
Compare
I have fixed up the suggested changes in ( |
In Rails 6 the `ActionView::Template#formats` method has been deprecated [1] and replaced with `ActionView::Template#format` method. I have attempted to retain support for Rails <= 5.2. [1] https://www.github.com/rails/rails/commit/ca5e23ed4d8
712c099
to
81fdc8a
Compare
Thanks! |
Thanks a lot @sebjacobs |
Whilst investigating a Rails 6 upgrade (
6.0.0.beta3
) I discovered the following issues:ActionView::Template#formats
method has been deprecated [1]The Template handler API has changed [2](already fixed on4-0-dev
)This branch attempts to fix these issues whilst retaining support for Rails <= 5.2.
[1] https://www.github.com/rails/rails/commit/ca5e23ed4d8
[2] https://www.github.com/rails/rails/commit/28f88e0074