Skip to content
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

Merged
merged 1 commit into from
Jan 22, 2015

Conversation

grosser
Copy link
Contributor

@grosser grosser commented Dec 13, 2014

@matthewd
Copy link
Member

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 test?

@grosser
Copy link
Contributor Author

grosser commented Dec 13, 2014

it is in test, but doing const_defined? is always true / there is no way to
check if it is actually loaded

>> defined?(ActionView::TestCase)
=> "constant"
>> ActionView.const_defined?(:TestCase)
=> true
>> ActionView::TestCase
actual load -> booom

On Sat, Dec 13, 2014 at 1:40 AM, Matthew Draper [email protected]
wrote:

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 test?


Reply to this email directly or view it on GitHub
#33 (comment).

@grosser
Copy link
Contributor Author

grosser commented Jan 15, 2015

@guigs
Copy link

guigs commented Jan 15, 2015

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?
Copy link
Member

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)?

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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.

@grosser
Copy link
Contributor Author

grosser commented Jan 22, 2015

@rafaelfranca good to go now ?

@rafaelfranca
Copy link
Member

I still don't think checking environment is a good option 😢, but I guess there is no other way of doing it.

rafaelfranca added a commit that referenced this pull request Jan 22, 2015
fix test-case vs devise vs rails 4.2
@rafaelfranca rafaelfranca merged commit 13f2ca7 into rails:master Jan 22, 2015
@grosser
Copy link
Contributor Author

grosser commented Jan 22, 2015

Let's wait for the next PR complaining on this ;)

On Thu, Jan 22, 2015 at 10:41 AM, Rafael Mendonça França <
[email protected]> wrote:

Merged #33 #33.


Reply to this email directly or view it on GitHub
#33 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants