From 66a4585f8830d8f37e62a63df3d095b6284b2a35 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Tue, 1 Sep 2009 15:54:29 -0700 Subject: Fix the */* with Net::HTTP bug [#3100 state:resolved] --- actionpack/test/lib/fixture_template.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'actionpack/test/lib') diff --git a/actionpack/test/lib/fixture_template.rb b/actionpack/test/lib/fixture_template.rb index 8da92180d1..9a9abb691d 100644 --- a/actionpack/test/lib/fixture_template.rb +++ b/actionpack/test/lib/fixture_template.rb @@ -38,10 +38,13 @@ module ActionView #:nodoc: extensions = "" [:locales, :formats].each do |k| - extensions << if exts = details[k] - '(?:' + exts.map {|e| "\\.#{Regexp.escape(e.to_s)}"}.join('|') + ')?' + # TODO: OMG NO + if details[k] == [:"*/*"] + extensions << formats_regexp if k == :formats + elsif exts = details[k] + extensions << '(?:' + exts.map {|e| "\\.#{Regexp.escape(e.to_s)}"}.join('|') + ')?' else - k == :formats ? formats_regexp : '' + extensions << formats_regexp if k == :formats end end -- cgit v1.2.3 From f3fc5c4b5f36db37edc8ab553a35b06b48226c0a Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 2 Sep 2009 15:00:22 -0700 Subject: Refactor ActionView::Resolver --- actionpack/test/lib/fixture_template.rb | 66 ++++++--------------------------- 1 file changed, 12 insertions(+), 54 deletions(-) (limited to 'actionpack/test/lib') diff --git a/actionpack/test/lib/fixture_template.rb b/actionpack/test/lib/fixture_template.rb index 9a9abb691d..0a365b3a7e 100644 --- a/actionpack/test/lib/fixture_template.rb +++ b/actionpack/test/lib/fixture_template.rb @@ -1,70 +1,28 @@ module ActionView #:nodoc: - class FixtureResolver < Resolver + class FixtureResolver < PathResolver def initialize(hash = {}, options = {}) super(options) @hash = hash end - def find_templates(name, details, prefix, partial) - if regexp = details_to_regexp(name, details, prefix, partial) - cached(regexp) do - templates = [] - @hash.select { |k,v| k =~ regexp }.each do |path, source| - templates << Template.new(source, path, *path_to_details(path)) - end - templates.sort_by {|t| -t.details.values.compact.size } - end - end - end - private - def formats_regexp - @formats_regexp ||= begin - formats = Mime::SET.symbols - '(?:' + formats.map { |l| "\\.#{Regexp.escape(l.to_s)}" }.join('|') + ')?' - end - end - - def handler_regexp - e = TemplateHandlers.extensions.map{|h| "\\.#{Regexp.escape(h.to_s)}"}.join("|") - "(?:#{e})" + def or_extensions(array) + "(?:" << array.map {|e| e && Regexp.escape(".#{e}")}.join("|") << ")" end - def details_to_regexp(name, details, prefix, partial) - path = "" - path << "#{prefix}/" unless prefix.empty? - path << (partial ? "_#{name}" : name) - - extensions = "" - [:locales, :formats].each do |k| - # TODO: OMG NO - if details[k] == [:"*/*"] - extensions << formats_regexp if k == :formats - elsif exts = details[k] - extensions << '(?:' + exts.map {|e| "\\.#{Regexp.escape(e.to_s)}"}.join('|') + ')?' - else - extensions << formats_regexp if k == :formats - end + def query(path, exts) + query = Regexp.escape(path) + exts.each do |ext| + query << '(?:' << ext.map {|e| e && Regexp.escape(".#{e}") }.join('|') << ')' end - %r'^#{Regexp.escape(path)}#{extensions}#{handler_regexp}$' - end - - # TODO: fix me - # :api: plugin - def path_to_details(path) - # [:erb, :format => :html, :locale => :en, :partial => true/false] - if m = path.match(%r'(_)?[\w-]+((?:\.[\w-]+)*)\.(\w+)$') - partial = m[1] == '_' - details = (m[2]||"").split('.').reject { |e| e.empty? } - handler = Template.handler_class_for_extension(m[3]) - - format = Mime[details.last] && details.pop.to_sym - locale = details.last && details.pop.to_sym - - return handler, :format => format, :locale => locale, :partial => partial + templates = [] + @hash.select { |k,v| k =~ /^#{query}$/ }.each do |path, source| + templates << Template.new(source, path, *path_to_details(path)) end + templates.sort_by {|t| -t.details.values.compact.size } end + end end \ No newline at end of file -- cgit v1.2.3 From f61dc0ef6511e585f0b6a8d02b00c17b2388b04a Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Thu, 3 Sep 2009 11:40:03 -0700 Subject: Remove a useless method in the fixture template class --- actionpack/test/lib/fixture_template.rb | 4 ---- 1 file changed, 4 deletions(-) (limited to 'actionpack/test/lib') diff --git a/actionpack/test/lib/fixture_template.rb b/actionpack/test/lib/fixture_template.rb index 0a365b3a7e..6b9e7c5270 100644 --- a/actionpack/test/lib/fixture_template.rb +++ b/actionpack/test/lib/fixture_template.rb @@ -7,10 +7,6 @@ module ActionView #:nodoc: private - def or_extensions(array) - "(?:" << array.map {|e| e && Regexp.escape(".#{e}")}.join("|") << ")" - end - def query(path, exts) query = Regexp.escape(path) exts.each do |ext| -- cgit v1.2.3 From 1c02fc295dc8281b8c3352bdd95869d5421aff08 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 6 Sep 2009 21:19:29 -0500 Subject: Fix isolated running of ActionPackAssertionTest --- actionpack/test/lib/controller/fake_controllers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/test/lib') diff --git a/actionpack/test/lib/controller/fake_controllers.rb b/actionpack/test/lib/controller/fake_controllers.rb index 6e02e2d21b..d41547b902 100644 --- a/actionpack/test/lib/controller/fake_controllers.rb +++ b/actionpack/test/lib/controller/fake_controllers.rb @@ -9,7 +9,7 @@ module Admin class UserController < ActionController::Base; end class NewsFeedController < ActionController::Base; end end - +class ElsewhereController < ActionController::Base; end # For speed test class SpeedController < ActionController::Base; end -- cgit v1.2.3 From 9f47f8d892ee35a08b5556acc4ddbe93b0461cfd Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 6 Sep 2009 21:42:05 -0500 Subject: Fix isolated running of AddressesTest --- actionpack/test/lib/controller/fake_controllers.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack/test/lib') diff --git a/actionpack/test/lib/controller/fake_controllers.rb b/actionpack/test/lib/controller/fake_controllers.rb index d41547b902..e7589e29ca 100644 --- a/actionpack/test/lib/controller/fake_controllers.rb +++ b/actionpack/test/lib/controller/fake_controllers.rb @@ -10,6 +10,7 @@ module Admin class NewsFeedController < ActionController::Base; end end class ElsewhereController < ActionController::Base; end +class AddressesController < ActionController::Base; end # For speed test class SpeedController < ActionController::Base; end -- cgit v1.2.3 From c531bd66651639c25cc8d1b90dd6b56e5db3581b Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 6 Sep 2009 22:29:29 -0500 Subject: Cleanup hacky routing with controller_path in url helper tests. This doesn't work in real life anyway. --- actionpack/test/lib/controller/fake_controllers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/test/lib') diff --git a/actionpack/test/lib/controller/fake_controllers.rb b/actionpack/test/lib/controller/fake_controllers.rb index e7589e29ca..b96e91f4f7 100644 --- a/actionpack/test/lib/controller/fake_controllers.rb +++ b/actionpack/test/lib/controller/fake_controllers.rb @@ -11,6 +11,7 @@ module Admin end class ElsewhereController < ActionController::Base; end class AddressesController < ActionController::Base; end +class SessionsController < ActionController::Base; end # For speed test class SpeedController < ActionController::Base; end @@ -25,7 +26,6 @@ class UsersController < SpeedController; end class SettingsController < SpeedController; end class ChannelsController < SpeedController; end class ChannelVideosController < SpeedController; end -class SessionsController < SpeedController; end class LostPasswordsController < SpeedController; end class PagesController < SpeedController; end -- cgit v1.2.3 From 2ae84e04aa18f6b35c628349c8c816fe1538cd70 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 6 Sep 2009 23:02:55 -0500 Subject: Add fake controllers for url rewriter tests --- actionpack/test/lib/controller/fake_controllers.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'actionpack/test/lib') diff --git a/actionpack/test/lib/controller/fake_controllers.rb b/actionpack/test/lib/controller/fake_controllers.rb index b96e91f4f7..22729188a2 100644 --- a/actionpack/test/lib/controller/fake_controllers.rb +++ b/actionpack/test/lib/controller/fake_controllers.rb @@ -12,6 +12,11 @@ end class ElsewhereController < ActionController::Base; end class AddressesController < ActionController::Base; end class SessionsController < ActionController::Base; end +class FooController < ActionController::Base; end +class CController < ActionController::Base; end +class HiController < ActionController::Base; end +class BraveController < ActionController::Base; end +class ImageController < ActionController::Base; end # For speed test class SpeedController < ActionController::Base; end -- cgit v1.2.3