Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix mixed case enumerable methods in the JavaScript Collection Proxy …

…(closes #4314) [codyfauser@gmail.com]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3984 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit a6cfb4e0e4209e06b4ba561b688ee2c3b942e3dd 1 parent 9a72cd2
@technoweenie technoweenie authored
View
2  actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fix mixed case enumerable methods in the JavaScript Collection Proxy (closes #4314) [codyfauser@gmail.com]
+
* Undo accidental escaping for mail_to; add regression test. [Nicholas Seckar]
* Added nicer message for assert_redirected_to (closes #4294) [court3nay]
View
4 actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -807,7 +807,7 @@ def append_to_function_chain!(call)
end
class JavaScriptCollectionProxy < JavaScriptProxy #:nodoc:
- ENUMERABLE_METHODS_WITH_RETURN = [:all, :any, :collect, :map, :detect, :find, :findAll, :select, :max, :min, :partition, :reject, :sortBy]
+ ENUMERABLE_METHODS_WITH_RETURN = [:all, :any, :collect, :map, :detect, :find, :find_all, :select, :max, :min, :partition, :reject, :sort_by]
ENUMERABLE_METHODS = ENUMERABLE_METHODS_WITH_RETURN + [:each]
attr_reader :generator
delegate :arguments_for_call, :to => :generator
@@ -865,7 +865,7 @@ def enumerate(enumerable, options = {}, &block)
method_args = arguments_for_call options[:method_args] # foo, bar, function
method_args << ', ' unless method_args.blank?
add_variable_assignment!(options[:variable]) if options[:variable]
- append_enumerable_function!("#{enumerable}(#{method_args}function(#{yield_args}) {")
+ append_enumerable_function!("#{enumerable.to_s.first}#{enumerable.to_s.camelize[1..-1]}(#{method_args}function(#{yield_args}) {")
# only yield as many params as were passed in the block
yield *options[:yield_args].collect { |p| JavaScriptVariableProxy.new(@generator, p) }[0..block.arity-1]
add_return_statement! if options[:return]
View
13 actionpack/test/template/prototype_helper_test.rb
@@ -391,6 +391,18 @@ def test_collection_proxy_with_zip
EOS
end
+ def test_collection_proxy_with_find_all
+ @generator.select('p').find_all 'a' do |value, index|
+ @generator << '(value.className == "welcome")'
+ end
+
+ assert_equal <<-EOS.strip, @generator.to_s
+var a = $$("p").findAll(function(value, index) {
+return (value.className == "welcome");
+});
+ EOS
+ end
+
def test_debug_rjs
ActionView::Base.debug_rjs = true
@generator['welcome'].replace_html 'Welcome'
@@ -404,3 +416,4 @@ def test_class_proxy
assert_equal "Form.focus(\"my_field\");", @generator.to_s
end
end
+
Please sign in to comment.
Something went wrong with that request. Please try again.