-
Notifications
You must be signed in to change notification settings - Fork 145
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
fix test-case vs devise vs rails 4.2 #33
Conversation
Checking the environment really is very dirty... can we: if ActionView.const_defined?(:TestCase) && !ActionView.autoload?(:TestCase) ? Or isn't TestCase loaded yet, even in |
it is in test, but doing const_defined? is always true / there is no way to
On Sat, Dec 13, 2014 at 1:40 AM, Matthew Draper [email protected]
|
I've applied this to 4.2 branch in my fork of prototype-rails and it is working with my app. |
ActionView::TestCase.class_eval do | ||
include ActionView::Helpers::PrototypeHelper | ||
include ActionView::Helpers::ScriptaculousHelper | ||
if defined?(Rails) && Rails.env.test? |
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 we check defined?(Rails.env)
?
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 with this is if users is testing in a cucumber environment it will not load these helpers.
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 idea was to only load it in test mode, so defined?(Rails.env)
will also be true for development and others
how about ['cucumber', 'test'].include?(Rails.env)
?
there is always the fallback option of doing the include manually, so even if we miss some edge case it's not that bad
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 mean if defined?(Rails.env) && Rails.env.test?
.
I really thing we should not check any environment but I can't think in a better option besides a configuration.
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 yes, that should work and is a bit safer, changed!
On Wed, Jan 21, 2015 at 7:48 AM, Rafael Mendonça França <
[email protected]> wrote:
In lib/prototype-rails/on_load_action_view.rb
#33 (comment):@@ -14,9 +14,11 @@
include ActionView::Helpers::ScriptaculousHelper
end-ActionView::TestCase.class_eval do
- include ActionView::Helpers::PrototypeHelper
- include ActionView::Helpers::ScriptaculousHelper
+if defined?(Rails) && Rails.env.test?I mean if defined?(Rails.env) && Rails.env.test?.
I really thing we should not check any environment but I can't think in a
better option besides a configuration.—
Reply to this email directly or view it on GitHub
https://github.com/rails/prototype-rails/pull/33/files#r23308286.
…-load"" This reverts commit bc80415.
@rafaelfranca good to go now ? |
I still don't think checking environment is a good option 😢, but I guess there is no other way of doing it. |
fix test-case vs devise vs rails 4.2
Let's wait for the next PR complaining on this ;) On Thu, Jan 22, 2015 at 10:41 AM, Rafael Mendonça França <
|
should solve #23 and #32
@rafaelfranca @walterdavis @guigs