-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Rails 5.1 compatibility #1790
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 5.1 compatibility #1790
Conversation
Rails 5.1 removes `rails:template` in favour of `app:template` to generate templates. This change sets our rakefile up to usee the `app:template` command if the rails version is greater than or equal to 5.1
@yui-knk btw, here's the current failure output when I run |
@samphippen any reason not to update this to 5.1.0.rc1? That's going to be closer to the 5.1 final release, and it's possible the build failures are related to a regression in beta1 that's fixed in rc1. |
No reason, just haven't had the time.
Sent from my phone please excuse my brevity.
… On 23 Mar 2017, at 10:06, Myron Marston ***@***.***> wrote:
@samphippen any reason not to update this to 5.1.0.rc1? That's going to be closer to the 5.1 final release, and it's possible the build failures are related to a regression in beta1 that's fixed in rc1.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
From Rails 5.1, a form view which is generated by scaffold command uses `form_with`. `form_with` does not append id attribute for form tags or input tags. So our templates should not use id selectors. rails/rails@d3b798b
I create #1797. Can you merge this to run CI? |
Bump up Rails version to 5.1.0.rc1
`render :text` has been deprecated for a while now, and is removed in rails 5.1. It has been replaced by either `render :plain` or `render :html` (depending on which `Content-Encoding` header you want). This patch uses our existing cucumber tags `@rails_pre_5` and `@rails_post_5` to switch which we use depending on the Rails verison. We can't simply replace all the references here because Rails 3 does not have this option.
@rspec/rspec this is now ready for review. I've tested it locally against 5.1 and 5.0 and everything still works. Travis is cooking the other versions, but I don't expect much variance there. |
When I run `rspec spec/requests/widget_management_spec.rb` | ||
Then the example should pass | ||
|
||
|
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.
Extra ws here
@@ -136,7 +162,6 @@ Feature: `have_http_status` matcher | |||
visit "/widgets/new" | |||
expect(page).to have_http_status(200) | |||
|
|||
fill_in "Name", :with => "My Widget" |
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.
unrelated?
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.
has no effect and breaks in Rails 5.1 for really weird reasons.
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.
Is that indicative that we have an issue here?
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.
There's no issue here. In rails 5.1 they've changed the form generation logic so this finder fails. However, this fill_in
has nothing to do with the test. I think we should remove it
- for compatibility
- because it doesn't aid in being documenting of this feature
@@ -16,8 +16,12 @@ | |||
assert_select "form[action=?][method=?]", <%= ns_file_name %>_path(@<%= ns_file_name %>), "post" do | |||
<% for attribute in output_attributes -%> | |||
<%- name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name %> | |||
<% if Rails.version.to_f >= 5.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.
Worth indenting to match above? Makes it slightly clearer too.
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.
The problem here is that indentation here affects the output. We want the output to look 'normal' do we don't indent here.
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.
You could indent inside the tag if thats your concern?
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.
Can you show how you'd like this to look, I'm not sure I fully follow?
@@ -15,8 +15,12 @@ | |||
assert_select "form[action=?][method=?]", <%= index_helper %>_path, "post" do | |||
<% for attribute in output_attributes -%> | |||
<%- name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name %> | |||
<% if Rails.version.to_f >= 5.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.
As above
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.
same
Seems sane to me but I've not run it, if you're happy with it I'm happy with it. I've left a few non blocking comments on style. |
Rakefile
Outdated
@@ -11,6 +11,15 @@ require 'rspec' | |||
require 'rspec/core/rake_task' | |||
require 'cucumber/rake/task' | |||
|
|||
def rails_template_command | |||
require "rails" | |||
if Rails.version.to_f >= 5.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 think if Rails.version.to_f >= 5.0
is better, because "rails:template"
was deprecated on Rails 5.0.
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 it passes on CI it's good with me :)
@JonRowe I've just pushed some review tweaks and answered a few of your review pieces. WDYT? |
@JonRowe I'm gonna go ahead and merge this. If you feel particularly strongly on the indentation or the deleted line, I think we can open a fresh PR. |
No description provided.