mirror of
https://github.com/github/rails.git
synced 2026-02-10 14:15:00 -05:00
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
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -807,7 +807,7 @@ module ActionView
|
||||
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 @@ module ActionView
|
||||
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]
|
||||
|
||||
@@ -391,6 +391,18 @@ return array.reverse();
|
||||
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 @@ return array.reverse();
|
||||
assert_equal "Form.focus(\"my_field\");", @generator.to_s
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user