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
Rails5 Support #51
Rails5 Support #51
Conversation
The specs were expecting a successful response, but the request was raising an error. The spec's regex was then matching the exception message rather than the response body. Note: The new spec now fails with rails 5 due to the fact that rails 5 does not autoload constants in production anymore.
@vlymar, hope you don't mind -- I added |
Here's the plan for handling exceptions:
|
@@ -33,11 +36,29 @@ | |||
end | |||
|
|||
it "should not allow me to define widgets outside of app/views/" do | |||
expect_exception('widget_defined_outside_app_views', 'ActionView::MissingTemplate', /class_loading_system_spec\/widget_defined_outside_app_views/) | |||
# TODO: what is this spec testing? the action doesn't tell rails to render the outside 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.
im guessing this spec is testing that rails/fortitude doesn't autoload and use a widget defined outside of app/views, but im not 100% sure. Will investigate this along with the rest of the autoloading questions
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.
yeah, that seems to be it. the controller action for this spec loads in a rails file that defines Views::ClassLoadingSystemSpec::WidgetDefinedOutsideAppViews
. This spec is testing to make sure that implicit rendering does not render that widget, since demands that all templates are under app/views
I was thinking about this question:
Do you have any theories about the answer? To me, I'm just seeing one failing spec when commenting-out I'm almost more comfortable removing the spec instead of continuing to enforce autoloading. |
re. the spec that fails if we disable autoloading: i think in the absence of any new info, we can disable it. I'm just made uncomfortable by the fact that I don't understand why it is there. That spec is basically testing that if you have an empty directory like All the actual real widgets get eager loaded, so before initialization finishes they already have constants defined. |
update readme
Rails 5 by default disables autoloading after initialization in production. There is one spec in the fortitude test suite that depends on this autoloading behavior, but it tests a strange use case and we are not supporting it. The use case is the ability to reference a constant like Views::SomeNamespace that corresponds to an empty directory app/views/some_namespace/ . All actual widgets are eager loaded. Autoloading after initialization is not thread safe. For more info on why it was disabled, see rails/rails#13142
Important note about this PR: I've replaced It would be possible to preserve backwards compatibility and remove the deprecation warning by unpacking alias_method_chain into the two alias_methods that make it up, or by doing some extra conditions by rails version to include if rails < 5, prepend otherwise, but both of these are ugly and problematic in their own ways. |
Ruby 1.9 is already EOL, and JRuby 1.7.x (1.9 equivalent) will follow shortly at the end of this year: jruby/jruby#4112 IMO trying to maintain 1.9 support is somewhat of a waste of effort, especially since Rails 5 doesn't even support 1.9, and the current version of Fortitude works fine for Rails 4.2. |
This has now been fixed in 0.9.5, which I just released. It’s completely compatible with all Rails versions from 3.0 through 5.0. While I didn’t end up merging this PR exactly, I did take a look at many of the fixes from this branch as models — thank you so much, @vlymar, for the PR! |
Adds rails 5 to fortitude's testing matrix, fixes specs that break with rails 5.
To run the specs on your machine:
FORTITUDE_SPECS_RAILS_VERSION=4.2.5.1 bundle exec rspec spec/
FORTITUDE_SPECS_RAILS_VERSION=5.0.0.1 bundle exec rspec spec/
Note: we've forked the oop_rails_server gem with some minor changes, so you may need to re-bundle to install it.
See dobtco/oop_rails_server#1 for oop_rails_server PR
Rails 5 Changes that affect fortitude (or its specs):
Rails falls back on non-thread-safe autoloading even when eager_load is true rails/rails#13142
204 No Content
Lock down new
ImplicitRender
behavior for 5.0 RC rails/rails#23827ActionView::Template::Error
. In rails 4, as the exception propagated up, the fortitude original_exception was then extracted and propagated. It is no longer extracted, so we get theActionView::Template::Error
wrapping the fortitude error.rails/rails@e35b98e#diff-81f758fb88f738604ba750f9dde1f6bbL9
TODO:
a) ignore it - An error is raise regardless, and the original error message is contained within it. oop_rails_server already implements a handler in
rescue_from
, so we can unwrap the exception there and leave existing error checking specs as is. The disadvantage here is if someone is already explicitly handling/rescuing from fortitude specific errors anywhere, they will now suddenly get Template::Errors instead.b) prevent rails from wrapping fortitude's exceptions somehow. I have an idea on how to do this, will update this PR in a few minutes if successful.