From 197a995bc548e206bb907c40d75f8ed70fa5a923 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Mon, 27 Sep 2010 20:57:26 -0300 Subject: Move uri parser to AS as URI.parser method to reuse it in AP and ARes. --- actionpack/lib/action_controller.rb | 2 +- actionpack/lib/action_controller/caching/actions.rb | 4 +--- actionpack/lib/action_controller/caching/pages.rb | 8 +------- actionpack/lib/action_controller/uri_parser.rb | 9 --------- actionpack/lib/action_dispatch/routing/route_set.rb | 10 ++-------- 5 files changed, 5 insertions(+), 28 deletions(-) delete mode 100644 actionpack/lib/action_controller/uri_parser.rb (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb index 787439db87..5b81cd39f4 100644 --- a/actionpack/lib/action_controller.rb +++ b/actionpack/lib/action_controller.rb @@ -8,7 +8,6 @@ module ActionController autoload :Caching autoload :Metal autoload :Middleware - autoload :UriParser autoload_under "metal" do autoload :Compatibility @@ -73,4 +72,5 @@ require 'active_support/core_ext/load_error' require 'active_support/core_ext/module/attr_internal' require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/name_error' +require 'active_support/core_ext/uri' require 'active_support/inflector' diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb index cd352f69fc..d69d96b974 100644 --- a/actionpack/lib/action_controller/caching/actions.rb +++ b/actionpack/lib/action_controller/caching/actions.rb @@ -141,8 +141,6 @@ module ActionController #:nodoc: end class ActionCachePath - include UriParser - attr_reader :path, :extension # If +infer_extension+ is true, the cache path extension is looked up from the request's @@ -163,7 +161,7 @@ module ActionController #:nodoc: def normalize!(path) path << 'index' if path[-1] == ?/ path << ".#{extension}" if extension and !path.ends_with?(extension) - uri_parser.unescape(path) + URI.parser.unescape(path) end end end diff --git a/actionpack/lib/action_controller/caching/pages.rb b/actionpack/lib/action_controller/caching/pages.rb index f0e00718ac..df4d500069 100644 --- a/actionpack/lib/action_controller/caching/pages.rb +++ b/actionpack/lib/action_controller/caching/pages.rb @@ -57,8 +57,6 @@ module ActionController #:nodoc: end module ClassMethods - include UriParser - # Expires the page that was cached with the +path+ as a key. Example: # expire_page "/lists/show" def expire_page(path) @@ -100,7 +98,7 @@ module ActionController #:nodoc: private def page_cache_file(path) - name = (path.empty? || path == "/") ? "/index" : uri_parser.unescape(path.chomp('/')) + name = (path.empty? || path == "/") ? "/index" : URI.parser.unescape(path.chomp('/')) name << page_cache_extension unless (name.split('/').last || name).include? '.' return name end @@ -112,10 +110,6 @@ module ActionController #:nodoc: def instrument_page_cache(name, path) ActiveSupport::Notifications.instrument("#{name}.action_controller", :path => path){ yield } end - - def uri_parser - @uri_parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI - end end # Expires the page that was cached with the +options+ as a key. Example: diff --git a/actionpack/lib/action_controller/uri_parser.rb b/actionpack/lib/action_controller/uri_parser.rb deleted file mode 100644 index 8e2a3f69eb..0000000000 --- a/actionpack/lib/action_controller/uri_parser.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'uri' - -module ActionController #:nodoc: - module UriParser - def uri_parser - @uri_parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI - end - end -end diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 66b487ba6d..66e6ecc74c 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -5,8 +5,6 @@ require 'active_support/core_ext/object/to_query' module ActionDispatch module Routing class RouteSet #:nodoc: - include ActionController::UriParser - PARAMETERS_KEY = 'action_dispatch.request.path_parameters' class Dispatcher #:nodoc: @@ -68,7 +66,7 @@ module ActionDispatch end def split_glob_param!(params) - params[@glob_param] = params[@glob_param].split('/').map { |v| uri_parser.unescape(v) } + params[@glob_param] = params[@glob_param].split('/').map { |v| URI.parser.unescape(v) } end end @@ -546,7 +544,7 @@ module ActionDispatch params.each do |key, value| if value.is_a?(String) value = value.dup.force_encoding(Encoding::BINARY) if value.encoding_aware? - params[key] = uri_parser.unescape(value) + params[key] = URI.parser.unescape(value) end end @@ -563,10 +561,6 @@ module ActionDispatch end private - def uri_parser - @uri_parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI - end - def handle_positional_args(options) return unless args = options.delete(:_positional_args) -- cgit v1.2.3 From b8c565fbd68343b419b05a53b4e1844062d1197e Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 15:10:15 -0300 Subject: Initialize @app if it doesn't exists. --- actionpack/lib/action_dispatch/testing/integration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index 3204115e9f..8c05462d0d 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -308,7 +308,7 @@ module ActionDispatch include ActionDispatch::Assertions def app - @app + @app ||= nil end # Reset the current session. This is useful for testing multiple sessions -- cgit v1.2.3 From 4bce8e3c7510cd1bc1821af208d05e8c87349fb2 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 15:10:55 -0300 Subject: No need to call super here. Use yield instead block.call --- actionpack/lib/action_dispatch/middleware/stack.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch/middleware/stack.rb b/actionpack/lib/action_dispatch/middleware/stack.rb index db7f342bc5..9ea188c3e2 100644 --- a/actionpack/lib/action_dispatch/middleware/stack.rb +++ b/actionpack/lib/action_dispatch/middleware/stack.rb @@ -41,9 +41,8 @@ module ActionDispatch end end - def initialize(*args, &block) - super(*args) - block.call(self) if block_given? + def initialize(*args) + yield(self) if block_given? end def insert(index, *args, &block) -- cgit v1.2.3 From 8ee27afd064bccfc63b21f126109a9b20ce72bd5 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 15:21:44 -0300 Subject: Don't define _test_case method if already defined. --- actionpack/lib/action_view/test_case.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb index 32fd8c5e21..de23a67cb6 100644 --- a/actionpack/lib/action_view/test_case.rb +++ b/actionpack/lib/action_view/test_case.rb @@ -137,8 +137,10 @@ module ActionView def make_test_case_available_to_view! test_case_instance = self _helpers.module_eval do - define_method(:_test_case) { test_case_instance } - private :_test_case + unless private_method_defined?(:_test_case) + define_method(:_test_case) { test_case_instance } + private :_test_case + end end end -- cgit v1.2.3 From adcc5e11fe5edd2883b6ec4d08ab72180a973155 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 15:29:40 -0300 Subject: @selected may not be defined here, avoid warning. --- actionpack/lib/action_dispatch/testing/assertions/selector.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch/testing/assertions/selector.rb b/actionpack/lib/action_dispatch/testing/assertions/selector.rb index 353be10d20..9ae4f65db9 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/selector.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/selector.rb @@ -197,7 +197,7 @@ module ActionDispatch # This usually happens when passing a node/element that # happens to be nil. raise ArgumentError, "First argument is either selector or element to select, but nil found. Perhaps you called assert_select with an element that does not exist?" - elsif @selected + elsif defined?(@selected) && @selected root = HTML::Node.new(nil) root.children.concat @selected else -- cgit v1.2.3 From 04c4f47fed6ced3f4158107b7cc40a7ea1b4913c Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 15:33:48 -0300 Subject: Initialize @sub_templates --- actionpack/lib/action_view/template/error.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_view/template/error.rb b/actionpack/lib/action_view/template/error.rb index b1839b65e5..423e1e0bf5 100644 --- a/actionpack/lib/action_view/template/error.rb +++ b/actionpack/lib/action_view/template/error.rb @@ -52,6 +52,7 @@ module ActionView def initialize(template, assigns, original_exception) @template, @assigns, @original_exception = template, assigns.dup, original_exception + @sub_templates = nil @backtrace = original_exception.backtrace end -- cgit v1.2.3 From 059d609a1a59300faefdc2d4186bae13b30c9699 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 15:46:30 -0300 Subject: Avoid more uninitialized variable warnings. --- actionpack/lib/abstract_controller/rendering.rb | 2 +- actionpack/lib/action_dispatch/testing/assertions/selector.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index 5d9b35d297..cc6a7f4047 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -66,7 +66,7 @@ module AbstractController attr_writer :view_context_class def view_context_class - @view_context_class || self.class.view_context_class + (@view_context_class ||= nil) || self.class.view_context_class end def initialize(*) diff --git a/actionpack/lib/action_dispatch/testing/assertions/selector.rb b/actionpack/lib/action_dispatch/testing/assertions/selector.rb index 9ae4f65db9..f5ecb9a199 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/selector.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/selector.rb @@ -187,6 +187,7 @@ module ActionDispatch def assert_select(*args, &block) # Start with optional element followed by mandatory selector. arg = args.shift + @selected ||= nil if arg.is_a?(HTML::Node) # First argument is a node (tag or text, but also HTML root), @@ -197,7 +198,7 @@ module ActionDispatch # This usually happens when passing a node/element that # happens to be nil. raise ArgumentError, "First argument is either selector or element to select, but nil found. Perhaps you called assert_select with an element that does not exist?" - elsif defined?(@selected) && @selected + elsif @selected root = HTML::Node.new(nil) root.children.concat @selected else -- cgit v1.2.3 From 7c8b43ed4fba035033e28cc47358fc3908584880 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 15:53:32 -0300 Subject: Ask if the instance variable is defined before asking for it, avoid *many* warnings. --- actionpack/lib/action_view/helpers/form_helper.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 8bae6d2796..7e49052c24 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -991,7 +991,11 @@ module ActionView end def object - @object || @template_object.instance_variable_get("@#{@object_name}") + if @object + @object + elsif @template_object.instance_variable_defined?("@#{@object_name}") + @template_object.instance_variable_get("@#{@object_name}") + end rescue NameError # As @object_name may contain the nested syntax (item[subobject]) we # need to fallback to nil. -- cgit v1.2.3 From c9416546a209847e2167edf49de7b4f6c9950694 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 16:09:31 -0300 Subject: Use parenthesis to avoid ambiguous first argument warning. --- actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb b/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb index d18b162a93..c3fa4dba0a 100644 --- a/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb +++ b/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb @@ -19,7 +19,7 @@ <% end %> <% traces.each do |name, trace| %> -
;"> +
;">
<%=h trace.join "\n" %>
<% end %> -- cgit v1.2.3 From 540e87256df08d350e9eb572408e5f68fa59f42b Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 16:12:07 -0300 Subject: Remove remaining warnings on _trace by adding parenthesis to gsub arguments. --- .../lib/action_dispatch/middleware/templates/rescues/_trace.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb b/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb index c3fa4dba0a..8771b5fd6d 100644 --- a/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb +++ b/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb @@ -12,14 +12,14 @@
<% names.each do |name| %> <% - show = "document.getElementById('#{name.gsub /\s/, '-'}').style.display='block';" - hide = (names - [name]).collect {|hide_name| "document.getElementById('#{hide_name.gsub /\s/, '-'}').style.display='none';"} + show = "document.getElementById('#{name.gsub(/\s/, '-')}').style.display='block';" + hide = (names - [name]).collect {|hide_name| "document.getElementById('#{hide_name.gsub(/\s/, '-')}').style.display='none';"} %> <%= name %> <%= '|' unless names.last == name %> <% end %> <% traces.each do |name, trace| %> -
;"> +
;">
<%=h trace.join "\n" %>
<% end %> -- cgit v1.2.3 From 6286b63f27b6b36b9603c4c68600f8f352b84137 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 16:20:48 -0300 Subject: Remove warings from rescues: don't define more than once debug_hash method and ask if @response if defined. --- .../middleware/templates/rescues/_request_and_response.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb b/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb index e963b04524..97f7cf0bbe 100644 --- a/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb +++ b/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb @@ -14,7 +14,7 @@ def debug_hash(hash) hash.sort_by { |k, v| k.to_s }.map { |k, v| "#{k}: #{v.inspect rescue $!.message}" }.join("\n") - end + end unless self.class.method_defined?(:debug_hash) %>

Request

@@ -28,4 +28,4 @@

Response

-

Headers:

<%=h @response ? @response.headers.inspect.gsub(',', ",\n") : 'None' %>

+

Headers:

<%=h defined?(@response) ? @response.headers.inspect.gsub(',', ",\n") : 'None' %>

-- cgit v1.2.3 From eea61a030e96625c53c57b63f0a9449850cf78df Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 16:24:42 -0300 Subject: Initialize @compiled_at if it is not. --- actionpack/lib/action_dispatch/middleware/static.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb index 581cadbeb4..6d442b91f5 100644 --- a/actionpack/lib/action_dispatch/middleware/static.rb +++ b/actionpack/lib/action_dispatch/middleware/static.rb @@ -7,6 +7,7 @@ module ActionDispatch @compiled_at = Regexp.compile(/^#{Regexp.escape(at)}/) unless @at.blank? @compiled_root = Regexp.compile(/^#{Regexp.escape(root)}/) @file_server = ::Rack::File.new(root) + @compiled_at ||= nil end def match?(path) -- cgit v1.2.3 From da8f9ca4329499fc9cc9c3f999a9d6eecdc801d3 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 16:27:05 -0300 Subject: Remove more warnings on variables. --- actionpack/lib/action_dispatch/routing/url_for.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch/routing/url_for.rb b/actionpack/lib/action_dispatch/routing/url_for.rb index e836cf7c8e..7be0f2769a 100644 --- a/actionpack/lib/action_dispatch/routing/url_for.rb +++ b/actionpack/lib/action_dispatch/routing/url_for.rb @@ -136,6 +136,7 @@ module ActionDispatch protected def _with_routes(routes) + @_routes ||= nil old_routes, @_routes = @_routes, routes yield ensure -- cgit v1.2.3 From 4d6e178f888c8287eb59e14bd9ecb77b4d71455b Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 16:31:21 -0300 Subject: Remove method if exists, avoid calling Array#first so many times. --- actionpack/lib/action_dispatch/middleware/callbacks.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch/middleware/callbacks.rb b/actionpack/lib/action_dispatch/middleware/callbacks.rb index e4ae480bfb..0bb950d1cc 100644 --- a/actionpack/lib/action_dispatch/middleware/callbacks.rb +++ b/actionpack/lib/action_dispatch/middleware/callbacks.rb @@ -19,9 +19,11 @@ module ActionDispatch # replace the existing callback. Passing an identifier is a suggested # practice if the code adding a preparation block may be reloaded. def self.to_prepare(*args, &block) - if args.first.is_a?(Symbol) && block_given? - define_method :"__#{args.first}", &block - set_callback(:prepare, :"__#{args.first}") + first_arg = args.first + if first_arg.is_a?(Symbol) && block_given? + remove_method :"__#{first_arg}" if method_defined?(:"__#{first_arg}") + define_method :"__#{first_arg}", &block + set_callback(:prepare, :"__#{first_arg}") else set_callback(:prepare, *args, &block) end -- cgit v1.2.3 From 19d9fffb9b8350b03cf8b1e3a3249eba06d22c1a Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 17:08:10 -0300 Subject: Use redefine_method instead define_method, it may be already defined. --- actionpack/lib/action_dispatch/routing/route_set.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 66e6ecc74c..71a320ce9c 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -313,7 +313,7 @@ module ActionDispatch # Yes plz - JP included do routes.install_helpers(self) - singleton_class.send(:define_method, :_routes) { routes } + singleton_class.send(:redefine_method, :_routes) { routes } end define_method(:_routes) { @_routes ||= nil; @_routes || routes } -- cgit v1.2.3 From 3f94b45262577b70a1d9f3aea45e0e4f07a2bbaa Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 17:08:43 -0300 Subject: Remove more warnings: no need to define attr_accessor if already exists. Initialize ivar. --- actionpack/lib/action_controller/test_case.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index f1ff57f0cb..70a5de7f30 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -462,9 +462,11 @@ module ActionController # The exception is stored in the exception accessor for further inspection. module RaiseActionExceptions def self.included(base) - base.class_eval do - attr_accessor :exception - protected :exception, :exception= + unless base.method_defined?(:exception) && base.method_defined?(:exception=) + base.class_eval do + attr_accessor :exception + protected :exception, :exception= + end end end -- cgit v1.2.3 From 523f98099d331908db6ab4c45f7657e61a8a4d5f Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 18:01:48 -0300 Subject: Remove more warnings on AP. --- actionpack/lib/action_dispatch/middleware/session/abstract_store.rb | 4 ++-- actionpack/lib/action_dispatch/testing/assertions/selector.rb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb b/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb index 348a2d1eb2..ea49b30630 100644 --- a/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb +++ b/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb @@ -102,8 +102,8 @@ module ActionDispatch def destroy clear - @by.send(:destroy, @env) if @by - @env[ENV_SESSION_OPTIONS_KEY][:id] = nil if @env && @env[ENV_SESSION_OPTIONS_KEY] + @by.send(:destroy, @env) if defined?(@by) && @by + @env[ENV_SESSION_OPTIONS_KEY][:id] = nil if defined?(@env) && @env && @env[ENV_SESSION_OPTIONS_KEY] @loaded = false end diff --git a/actionpack/lib/action_dispatch/testing/assertions/selector.rb b/actionpack/lib/action_dispatch/testing/assertions/selector.rb index f5ecb9a199..2b862fb7d6 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/selector.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/selector.rb @@ -67,7 +67,7 @@ module ActionDispatch arg = args.shift elsif arg == nil raise ArgumentError, "First argument is either selector or element to select, but nil found. Perhaps you called assert_select with an element that does not exist?" - elsif @selected + elsif defined?(@selected) && @selected matches = [] @selected.each do |selected| @@ -443,6 +443,7 @@ module ActionDispatch assert_block("") { true } # to count the assertion if block_given? && !([:remove, :show, :hide, :toggle].include? rjs_type) begin + @selected ||= nil in_scope, @selected = @selected, matches yield matches ensure -- cgit v1.2.3 From 357f59447d79a09d7a84fa8c2bc7892b5fc02ca9 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 18:20:54 -0300 Subject: Initialize @path. --- actionpack/lib/action_view/template/resolver.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb index c9e20ca14e..a261e08dbc 100644 --- a/actionpack/lib/action_view/template/resolver.rb +++ b/actionpack/lib/action_view/template/resolver.rb @@ -6,6 +6,7 @@ module ActionView # = Action View Resolver class Resolver def initialize + @path = nil @cached = Hash.new { |h1,k1| h1[k1] = Hash.new { |h2,k2| h2[k2] = Hash.new { |h3, k3| h3[k3] = {} } } } end -- cgit v1.2.3 From 0fa9c5392ec24a7d1017d03aa00a2bac32f53158 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 18:25:24 -0300 Subject: Define @_layout if it is not defined. --- actionpack/lib/abstract_controller/layouts.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack/lib') diff --git a/actionpack/lib/abstract_controller/layouts.rb b/actionpack/lib/abstract_controller/layouts.rb index 958e7f7ec8..bbc9739f14 100644 --- a/actionpack/lib/abstract_controller/layouts.rb +++ b/actionpack/lib/abstract_controller/layouts.rb @@ -345,6 +345,7 @@ module AbstractController # * template - The template object for the default layout (or nil) def _default_layout(require_layout = false) begin + @_layout ||= nil layout_name = _layout if action_has_layout? rescue NameError => e raise NoMethodError, -- cgit v1.2.3