diff options
Diffstat (limited to 'actionpack')
45 files changed, 465 insertions, 419 deletions
diff --git a/actionpack/lib/action_dispatch/http/mime_negotiation.rb b/actionpack/lib/action_dispatch/http/mime_negotiation.rb index 5c48a60469..e31f3b823d 100644 --- a/actionpack/lib/action_dispatch/http/mime_negotiation.rb +++ b/actionpack/lib/action_dispatch/http/mime_negotiation.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/module/attribute_accessors' +  module ActionDispatch    module Http      module MimeNegotiation diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index f9dae5dad7..4266ec042e 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -23,23 +23,6 @@ module ActionDispatch          end          def url_for(options = {}) -          if options[:host].blank? && options[:only_path].blank? -            raise ArgumentError, 'Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true' -          end - -          rewritten_url = "" - -          unless options[:only_path] -            unless options[:protocol] == false -              rewritten_url << (options[:protocol] || "http") -              rewritten_url << ":" unless rewritten_url.match(%r{:|//}) -            end -            rewritten_url << "//" unless rewritten_url.match("//") -            rewritten_url << rewrite_authentication(options) -            rewritten_url << host_or_subdomain_and_domain(options) -            rewritten_url << ":#{options.delete(:port)}" if options[:port] -          end -            path = ""            path << options.delete(:script_name).to_s.chomp("/")            path << options.delete(:path).to_s @@ -47,14 +30,36 @@ module ActionDispatch            params = options[:params] || {}            params.reject! {|k,v| v.to_param.nil? } -          rewritten_url << (options[:trailing_slash] ? path.sub(/\?|\z/) { "/" + $& } : path) -          rewritten_url << "?#{params.to_query}" unless params.empty? -          rewritten_url << "##{Journey::Router::Utils.escape_fragment(options[:anchor].to_param.to_s)}" if options[:anchor] -          rewritten_url +          result = build_host_url(options) + +          result << (options[:trailing_slash] ? path.sub(/\?|\z/) { "/" + $& } : path) +          result << "?#{params.to_query}" unless params.empty? +          result << "##{Journey::Router::Utils.escape_fragment(options[:anchor].to_param.to_s)}" if options[:anchor] +          result          end          private +        def build_host_url(options) +          if options[:host].blank? && options[:only_path].blank? +            raise ArgumentError, 'Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true' +          end + +          result = "" + +          unless options[:only_path] +            unless options[:protocol] == false +              result << (options[:protocol] || "http") +              result << ":" unless result.match(%r{:|//}) +            end +            result << "//" unless result.match("//") +            result << rewrite_authentication(options) +            result << host_or_subdomain_and_domain(options) +            result << ":#{options.delete(:port)}" if options[:port] +          end +          result +        end +          def named_host?(host)            host && IP_HOST_REGEXP !~ host          end diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index ba4cfb482d..fdc0bfb686 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -1,4 +1,5 @@  require 'active_support/core_ext/hash/except' +require 'active_support/core_ext/hash/reverse_merge'  require 'active_support/core_ext/object/blank'  require 'active_support/core_ext/enumerable'  require 'active_support/inflector' @@ -58,6 +59,16 @@ module ActionDispatch            @options = (@scope[:options] || {}).merge(options)            @path = normalize_path(path)            normalize_options! + +          via_all = @options.delete(:via) if @options[:via] == :all + +          if !via_all && request_method_condition.empty? +            msg = "You should not use the `match` method in your router without specifying an HTTP method.\n" \ +                  "If you want to expose your action to GET, use `get` in the router:\n\n" \ +                  "  Instead of: match \"controller#action\"\n" \ +                  "  Do: get \"controller#action\"" +            raise msg +          end          end          def to_route @@ -263,7 +274,7 @@ module ActionDispatch          # of most Rails applications, this is beneficial.          def root(options = {})            options = { :to => options } if options.is_a?(String) -          match '/', { :as => :root }.merge(options) +          match '/', { :as => :root, :via => :get }.merge(options)          end          # Matches a url pattern to one or more routes. Any symbols in a pattern @@ -416,7 +427,7 @@ module ActionDispatch            options[:as] ||= app_name(app) -          match(path, options.merge(:to => app, :anchor => false, :format => false)) +          match(path, options.merge(:to => app, :anchor => false, :format => false, :via => :all))            define_generate_prefix(app, options[:as])            self diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 45075050eb..f1aa131cbb 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -96,7 +96,25 @@ module ActionDispatch          def initialize            @routes  = {}            @helpers = [] -          @module  = Module.new +          @module  = Module.new do +            protected + +            def handle_positional_args(args, options, route) +              inner_options = args.extract_options! +              result = options.dup + +              if args.any? +                keys = route.segment_keys +                if args.size < keys.size - 1 # take format into account +                  keys -= self.url_options.keys if self.respond_to?(:url_options) +                  keys -= options.keys +                end +                result.merge!(Hash[keys.zip(args)]) +              end + +              result.merge!(inner_options) +            end +          end          end          def helper_names @@ -135,40 +153,37 @@ module ActionDispatch          end          private -          def url_helper_name(name, kind = :url) -            :"#{name}_#{kind}" +          def url_helper_name(name, only_path) +            if only_path +              :"#{name}_path" +            else +              :"#{name}_url" +            end            end -          def hash_access_name(name, kind = :url) -            :"hash_for_#{name}_#{kind}" +          def hash_access_name(name, only_path) +            if only_path +              :"hash_for_#{name}_path" +            else +              :"hash_for_#{name}_url" +            end            end            def define_named_route_methods(name, route) -            {:url => {:only_path => false}, :path => {:only_path => true}}.each do |kind, opts| -              hash = route.defaults.merge(:use_route => name).merge(opts) -              define_hash_access route, name, kind, hash -              define_url_helper route, name, kind, hash +            [true, false].each do |only_path| +              hash = route.defaults.merge(:use_route => name, :only_path => only_path) +              define_hash_access route, name, hash +              define_url_helper route, name, hash              end            end -          def define_hash_access(route, name, kind, options) -            selector = hash_access_name(name, kind) +          def define_hash_access(route, name, options) +            selector = hash_access_name(name, options[:only_path])              @module.module_eval do -              remove_possible_method selector - -              define_method(selector) do |*args| -                inner_options = args.extract_options! -                result = options.dup - -                if args.any? -                  result[:_positional_args] = args -                  result[:_positional_keys] = route.segment_keys -                end - -                result.merge(inner_options) +              redefine_method(selector) do |*args| +                self.handle_positional_args(args, options, route)                end -                protected selector              end              helpers << selector @@ -187,9 +202,9 @@ module ActionDispatch            #            #   foo_url(bar, baz, bang, :sort_by => 'baz')            # -          def define_url_helper(route, name, kind, options) -            selector = url_helper_name(name, kind) -            hash_access_method = hash_access_name(name, kind) +          def define_url_helper(route, name, options) +            selector = url_helper_name(name, options[:only_path]) +            hash_access_method = hash_access_name(name, options[:only_path])              if optimize_helper?(route)                @module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1 @@ -609,8 +624,6 @@ module ActionDispatch        def url_for(options)          options = default_url_options.merge(options || {}) -        handle_positional_args(options) -          user, password = extract_authentication(options)          path_segments  = options.delete(:_path_segments)          script_name    = options.delete(:script_name).presence || _generate_prefix(options) @@ -680,16 +693,6 @@ module ActionDispatch            end          end -        def handle_positional_args(options) -          return unless args = options.delete(:_positional_args) - -          keys = options.delete(:_positional_keys) -          keys -= options.keys if args.size < keys.size - 1 # take format into account - -          # Tell url_for to skip default_url_options -          options.merge!(Hash[args.zip(keys).map { |v, k| [k, v] }]) -        end -      end    end  end diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index 1f237cd013..ffb1afa089 100644 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -67,8 +67,9 @@ module ActionView        def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false, options = {})          from_time = from_time.to_time if from_time.respond_to?(:to_time)          to_time = to_time.to_time if to_time.respond_to?(:to_time) -        distance_in_minutes = (((to_time - from_time).abs)/60).round -        distance_in_seconds = ((to_time - from_time).abs).round +        from_time, to_time = to_time, from_time if from_time > to_time +        distance_in_minutes = ((to_time - from_time)/60.0).round +        distance_in_seconds = (to_time - from_time).round          I18n.with_options :locale => options[:locale], :scope => :'datetime.distance_in_words' do |locale|            case distance_in_minutes @@ -94,18 +95,22 @@ module ActionView              when 43200..86399    then locale.t :about_x_months, :count => 1              when 86400..525599   then locale.t :x_months,       :count => (distance_in_minutes.to_f / 43200.0).round              else -              fyear = from_time.year -              fyear += 1 if from_time.month >= 3 -              tyear = to_time.year -              tyear -= 1 if to_time.month < 3 -              leap_years = (fyear > tyear) ? 0 : (fyear..tyear).count{|x| Date.leap?(x)} -              minute_offset_for_leap_year = leap_years * 1440 -              # Discount the leap year days when calculating year distance. -              # e.g. if there are 20 leap year days between 2 dates having the same day -              # and month then the based on 365 days calculation -              # the distance in years will come out to over 80 years when in written -              # english it would read better as about 80 years. -              minutes_with_offset         = distance_in_minutes - minute_offset_for_leap_year +              if from_time.acts_like?(:time) && to_time.acts_like?(:time) +                fyear = from_time.year +                fyear += 1 if from_time.month >= 3 +                tyear = to_time.year +                tyear -= 1 if to_time.month < 3 +                leap_years = (fyear > tyear) ? 0 : (fyear..tyear).count{|x| Date.leap?(x)} +                minute_offset_for_leap_year = leap_years * 1440 +                # Discount the leap year days when calculating year distance. +                # e.g. if there are 20 leap year days between 2 dates having the same day +                # and month then the based on 365 days calculation +                # the distance in years will come out to over 80 years when in written +                # english it would read better as about 80 years. +                minutes_with_offset = distance_in_minutes - minute_offset_for_leap_year +              else +                minutes_with_offset = distance_in_minutes +              end                remainder                   = (minutes_with_offset % 525600)                distance_in_years           = (minutes_with_offset / 525600)                if remainder < 131400 diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index b1a5356ddd..22ba047328 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -125,11 +125,11 @@ module ActiveSupport      # have been loaded.      setup_once do        SharedTestRoutes.draw do -        match ':controller(/:action)' +        get ':controller(/:action)'        end        ActionDispatch::IntegrationTest.app.routes.draw do -        match ':controller(/:action)' +        get ':controller(/:action)'        end      end    end diff --git a/actionpack/test/activerecord/active_record_store_test.rb b/actionpack/test/activerecord/active_record_store_test.rb index 2fe7959f5a..fceebe1858 100644 --- a/actionpack/test/activerecord/active_record_store_test.rb +++ b/actionpack/test/activerecord/active_record_store_test.rb @@ -259,7 +259,7 @@ class ActiveRecordStoreTest < ActionDispatch::IntegrationTest      def with_test_route_set(options = {})        with_routing do |set|          set.draw do -          match ':action', :to => 'active_record_store_test/test' +          get ':action', :to => 'active_record_store_test/test'          end          @app = self.class.build_app(set) do |middleware| diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index 01cafe1aca..b121ca9481 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -162,7 +162,7 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase    def test_string_constraint      with_routing do |set|        set.draw do -        match "photos", :to => 'action_pack_assertions#nothing', :constraints => {:subdomain => "admin"} +        get "photos", :to => 'action_pack_assertions#nothing', :constraints => {:subdomain => "admin"}        end      end    end @@ -170,9 +170,9 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase    def test_assert_redirect_to_named_route_failure      with_routing do |set|        set.draw do -        match 'route_one', :to => 'action_pack_assertions#nothing', :as => :route_one -        match 'route_two', :to => 'action_pack_assertions#nothing', :id => 'two', :as => :route_two -        match ':controller/:action' +        get 'route_one', :to => 'action_pack_assertions#nothing', :as => :route_one +        get 'route_two', :to => 'action_pack_assertions#nothing', :id => 'two', :as => :route_two +        get ':controller/:action'        end        process :redirect_to_named_route        assert_raise(ActiveSupport::TestCase::Assertion) do @@ -192,8 +192,8 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase      with_routing do |set|        set.draw do -        match 'admin/inner_module', :to => 'admin/inner_module#index', :as => :admin_inner_module -        match ':controller/:action' +        get 'admin/inner_module', :to => 'admin/inner_module#index', :as => :admin_inner_module +        get ':controller/:action'        end        process :redirect_to_index        # redirection is <{"action"=>"index", "controller"=>"admin/admin/inner_module"}> @@ -206,8 +206,8 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase      with_routing do |set|        set.draw do -        match '/action_pack_assertions/:id', :to => 'action_pack_assertions#index', :as => :top_level -        match ':controller/:action' +        get '/action_pack_assertions/:id', :to => 'action_pack_assertions#index', :as => :top_level +        get ':controller/:action'        end        process :redirect_to_top_level_named_route        # assert_redirected_to "http://test.host/action_pack_assertions/foo" would pass because of exact match early return @@ -221,8 +221,8 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase      with_routing do |set|        set.draw do          # this controller exists in the admin namespace as well which is the only difference from previous test -        match '/user/:id', :to => 'user#index', :as => :top_level -        match ':controller/:action' +        get '/user/:id', :to => 'user#index', :as => :top_level +        get ':controller/:action'        end        process :redirect_to_top_level_named_route        # assert_redirected_to top_level_url('foo') would pass because of exact match early return diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index 2032aca52e..b9513ccff4 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -158,7 +158,7 @@ class UrlOptionsTest < ActionController::TestCase    def test_url_for_query_params_included      rs = ActionDispatch::Routing::RouteSet.new      rs.draw do -      match 'home' => 'pages#home' +      get 'home' => 'pages#home'      end      options = { @@ -174,8 +174,8 @@ class UrlOptionsTest < ActionController::TestCase    def test_url_options_override      with_routing do |set|        set.draw do -        match 'from_view', :to => 'url_options#from_view', :as => :from_view -        match ':controller/:action' +        get 'from_view', :to => 'url_options#from_view', :as => :from_view +        get ':controller/:action'        end        get :from_view, :route => "from_view_url" @@ -189,7 +189,7 @@ class UrlOptionsTest < ActionController::TestCase    def test_url_helpers_does_not_become_actions      with_routing do |set|        set.draw do -        match "account/overview" +        get "account/overview"        end        assert !@controller.class.action_methods.include?("account_overview_path") @@ -208,8 +208,8 @@ class DefaultUrlOptionsTest < ActionController::TestCase    def test_default_url_options_override      with_routing do |set|        set.draw do -        match 'from_view', :to => 'default_url_options#from_view', :as => :from_view -        match ':controller/:action' +        get 'from_view', :to => 'default_url_options#from_view', :as => :from_view +        get ':controller/:action'        end        get :from_view, :route => "from_view_url" @@ -226,7 +226,7 @@ class DefaultUrlOptionsTest < ActionController::TestCase          scope("/:locale") do            resources :descriptions          end -        match ':controller/:action' +        get ':controller/:action'        end        get :from_view, :route => "description_path(1)" diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index a42c68a628..e8546cb154 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -102,8 +102,8 @@ class PageCachingTest < ActionController::TestCase    def test_page_caching_resources_saves_to_correct_path_with_extension_even_if_default_route      with_routing do |set|        set.draw do -        match 'posts.:format', :to => 'posts#index', :as => :formatted_posts -        match '/', :to => 'posts#index', :as => :main +        get 'posts.:format', :to => 'posts#index', :as => :formatted_posts +        get '/', :to => 'posts#index', :as => :main        end        @params[:format] = 'rss'        assert_equal '/posts.rss', @routes.url_for(@params) @@ -560,7 +560,7 @@ class ActionCacheTest < ActionController::TestCase    def test_xml_version_of_resource_is_treated_as_different_cache      with_routing do |set|        set.draw do -        match ':controller(/:action(.:format))' +        get ':controller(/:action(.:format))'        end        get :index, :format => 'xml' diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb index 37ccc7a4a5..e4b34125ad 100644 --- a/actionpack/test/controller/flash_test.rb +++ b/actionpack/test/controller/flash_test.rb @@ -277,7 +277,7 @@ class FlashIntegrationTest < ActionDispatch::IntegrationTest      def with_test_route_set        with_routing do |set|          set.draw do -          match ':action', :to => FlashIntegrationTest::TestController +          get ':action', :to => FlashIntegrationTest::TestController          end          @app = self.class.build_app(set) do |middleware| diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 44f033119d..877b91b563 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -466,7 +466,7 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest          end          set.draw do -          match ':action', :to => controller +          match ':action', :to => controller, :via => [:get, :post]            get 'get/:action', :to => controller          end @@ -530,10 +530,10 @@ class ApplicationIntegrationTest < ActionDispatch::IntegrationTest    end    routes.draw do -    match '',    :to => 'application_integration_test/test#index', :as => :empty_string +    get '',    :to => 'application_integration_test/test#index', :as => :empty_string -    match 'foo', :to => 'application_integration_test/test#index', :as => :foo -    match 'bar', :to => 'application_integration_test/test#index', :as => :bar +    get 'foo', :to => 'application_integration_test/test#index', :as => :foo +    get 'bar', :to => 'application_integration_test/test#index', :as => :bar    end    def app diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index 0e4099ddc6..ac056319fc 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -1118,7 +1118,7 @@ class RespondWithControllerTest < ActionController::TestCase            resources :quiz_stores do              resources :customers            end -          match ":controller/:action" +          get ":controller/:action"          end          yield        end diff --git a/actionpack/test/controller/new_base/content_type_test.rb b/actionpack/test/controller/new_base/content_type_test.rb index 4b70031c90..9b57641e75 100644 --- a/actionpack/test/controller/new_base/content_type_test.rb +++ b/actionpack/test/controller/new_base/content_type_test.rb @@ -43,7 +43,7 @@ module ContentType      test "default response is HTML and UTF8" do        with_routing do |set|          set.draw do -          match ':controller', :action => 'index' +          get ':controller', :action => 'index'          end          get "/content_type/base" diff --git a/actionpack/test/controller/new_base/render_template_test.rb b/actionpack/test/controller/new_base/render_template_test.rb index ade204c387..00c7df2af8 100644 --- a/actionpack/test/controller/new_base/render_template_test.rb +++ b/actionpack/test/controller/new_base/render_template_test.rb @@ -164,7 +164,7 @@ module RenderTemplate      test "rendering with implicit layout" do        with_routing do |set| -        set.draw { match ':controller', :action => :index } +        set.draw { get ':controller', :action => :index }          get "/render_template/with_layout" diff --git a/actionpack/test/controller/new_base/render_test.rb b/actionpack/test/controller/new_base/render_test.rb index 60468bf5c7..cc7f12ac6d 100644 --- a/actionpack/test/controller/new_base/render_test.rb +++ b/actionpack/test/controller/new_base/render_test.rb @@ -57,7 +57,7 @@ module Render      test "render with blank" do        with_routing do |set|          set.draw do -          match ":controller", :action => 'index' +          get ":controller", :action => 'index'          end          get "/render/blank_render" @@ -70,7 +70,7 @@ module Render      test "rendering more than once raises an exception" do        with_routing do |set|          set.draw do -          match ":controller", :action => 'index' +          get ":controller", :action => 'index'          end          assert_raises(AbstractController::DoubleRenderError) do diff --git a/actionpack/test/controller/new_base/render_text_test.rb b/actionpack/test/controller/new_base/render_text_test.rb index 06d500cca7..e0b38b29fa 100644 --- a/actionpack/test/controller/new_base/render_text_test.rb +++ b/actionpack/test/controller/new_base/render_text_test.rb @@ -67,7 +67,7 @@ module RenderText      test "rendering text from a action with default options renders the text with the layout" do        with_routing do |set| -        set.draw { match ':controller', :action => 'index' } +        set.draw { get ':controller', :action => 'index' }          get "/render_text/simple"          assert_body "hello david" @@ -77,7 +77,7 @@ module RenderText      test "rendering text from a action with default options renders the text without the layout" do        with_routing do |set| -        set.draw { match ':controller', :action => 'index' } +        set.draw { get ':controller', :action => 'index' }          get "/render_text/with_layout" diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb index 6dab42d75d..4331333b98 100644 --- a/actionpack/test/controller/redirect_test.rb +++ b/actionpack/test/controller/redirect_test.rb @@ -262,7 +262,7 @@ class RedirectTest < ActionController::TestCase      with_routing do |set|        set.draw do          resources :workshops -        match ':controller/:action' +        get ':controller/:action'        end        get :redirect_to_existing_record @@ -296,7 +296,7 @@ class RedirectTest < ActionController::TestCase    def test_redirect_to_with_block_and_accepted_options      with_routing do |set|        set.draw do -        match ':controller/:action' +        get ':controller/:action'        end        get :redirect_to_with_block_and_options diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index fce13d096c..10f62dad65 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -1188,7 +1188,7 @@ class RenderTest < ActionController::TestCase      with_routing do |set|        set.draw do          resources :customers -        match ':controller/:action' +        get ':controller/:action'        end        get :head_with_location_object diff --git a/actionpack/test/controller/render_xml_test.rb b/actionpack/test/controller/render_xml_test.rb index 8b4f2f5349..4f280c4bec 100644 --- a/actionpack/test/controller/render_xml_test.rb +++ b/actionpack/test/controller/render_xml_test.rb @@ -72,7 +72,7 @@ class RenderXmlTest < ActionController::TestCase      with_routing do |set|        set.draw do          resources :customers -        match ':controller/:action' +        get ':controller/:action'        end        get :render_with_object_location diff --git a/actionpack/test/controller/rescue_test.rb b/actionpack/test/controller/rescue_test.rb index 76c3dfe0d4..48e2d6491e 100644 --- a/actionpack/test/controller/rescue_test.rb +++ b/actionpack/test/controller/rescue_test.rb @@ -338,9 +338,9 @@ class RescueTest < ActionDispatch::IntegrationTest      def with_test_routing        with_routing do |set|          set.draw do -          match 'foo', :to => ::RescueTest::TestController.action(:foo) -          match 'invalid', :to => ::RescueTest::TestController.action(:invalid) -          match 'b00m', :to => ::RescueTest::TestController.action(:b00m) +          get 'foo', :to => ::RescueTest::TestController.action(:foo) +          get 'invalid', :to => ::RescueTest::TestController.action(:invalid) +          get 'b00m', :to => ::RescueTest::TestController.action(:b00m)          end          yield        end diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index 3c0a5d36ca..9fc875014c 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -680,7 +680,7 @@ class ResourcesTest < ActionController::TestCase          scope '/threads/:thread_id' do            resources :messages, :as => 'thread_messages' do              get :search, :on => :collection -            match :preview, :on => :new +            get :preview, :on => :new            end          end        end @@ -698,7 +698,7 @@ class ResourcesTest < ActionController::TestCase          scope '/admin' do            resource :account, :as => :admin_account do              get :login, :on => :member -            match :preview, :on => :new +            get :preview, :on => :new            end          end        end diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 272a7da8c5..9441b46d47 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -17,7 +17,7 @@ class UriReservedCharactersRoutingTest < ActiveSupport::TestCase    def setup      @set = ActionDispatch::Routing::RouteSet.new      @set.draw do -      match ':controller/:action/:variable/*additional' +      get ':controller/:action/:variable/*additional'      end      safe, unsafe = %w(: @ & = + $ , ;), %w(^ ? # [ ]) @@ -85,7 +85,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_symbols_with_dashes      rs.draw do -      match '/:artist/:song-omg', :to => lambda { |env| +      get '/:artist/:song-omg', :to => lambda { |env|          resp = JSON.dump env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY]          [200, {}, [resp]]        } @@ -97,7 +97,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_id_with_dash      rs.draw do -      match '/journey/:id', :to => lambda { |env| +      get '/journey/:id', :to => lambda { |env|          resp = JSON.dump env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY]          [200, {}, [resp]]        } @@ -109,7 +109,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_dash_with_custom_regexp      rs.draw do -      match '/:artist/:song-omg', :constraints => { :song => /\d+/ }, :to => lambda { |env| +      get '/:artist/:song-omg', :constraints => { :song => /\d+/ }, :to => lambda { |env|          resp = JSON.dump env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY]          [200, {}, [resp]]        } @@ -122,7 +122,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_pre_dash      rs.draw do -      match '/:artist/omg-:song', :to => lambda { |env| +      get '/:artist/omg-:song', :to => lambda { |env|          resp = JSON.dump env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY]          [200, {}, [resp]]        } @@ -134,7 +134,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_pre_dash_with_custom_regexp      rs.draw do -      match '/:artist/omg-:song', :constraints => { :song => /\d+/ }, :to => lambda { |env| +      get '/:artist/omg-:song', :constraints => { :song => /\d+/ }, :to => lambda { |env|          resp = JSON.dump env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY]          [200, {}, [resp]]        } @@ -147,7 +147,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_star_paths_are_greedy      rs.draw do -      match "/*path", :to => lambda { |env| +      get "/*path", :to => lambda { |env|          x = env["action_dispatch.request.path_parameters"][:path]          [200, {}, [x]]        }, :format => false @@ -159,7 +159,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_star_paths_are_greedy_but_not_too_much      rs.draw do -      match "/*path", :to => lambda { |env| +      get "/*path", :to => lambda { |env|          x = JSON.dump env["action_dispatch.request.path_parameters"]          [200, {}, [x]]        } @@ -172,7 +172,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_optional_star_paths_are_greedy      rs.draw do -      match "/(*filters)", :to => lambda { |env| +      get "/(*filters)", :to => lambda { |env|          x = env["action_dispatch.request.path_parameters"][:filters]          [200, {}, [x]]        }, :format => false @@ -184,7 +184,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_optional_star_paths_are_greedy_but_not_too_much      rs.draw do -      match "/(*filters)", :to => lambda { |env| +      get "/(*filters)", :to => lambda { |env|          x = JSON.dump env["action_dispatch.request.path_parameters"]          [200, {}, [x]]        } @@ -198,11 +198,11 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_regexp_precidence      @rs.draw do -      match '/whois/:domain', :constraints => { +      get '/whois/:domain', :constraints => {          :domain => /\w+\.[\w\.]+/ },          :to     => lambda { |env| [200, {}, %w{regexp}] } -      match '/whois/:id', :to => lambda { |env| [200, {}, %w{id}] } +      get '/whois/:id', :to => lambda { |env| [200, {}, %w{id}] }      end      assert_equal 'regexp', get(URI('http://example.org/whois/example.org')) @@ -217,9 +217,9 @@ class LegacyRouteSetTests < ActiveSupport::TestCase      }      @rs.draw do -      match '/', :constraints => subdomain.new, +      get '/', :constraints => subdomain.new,                   :to          => lambda { |env| [200, {}, %w{default}] } -      match '/', :constraints => { :subdomain => 'clients' }, +      get '/', :constraints => { :subdomain => 'clients' },                   :to          => lambda { |env| [200, {}, %w{clients}] }      end @@ -229,11 +229,11 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_lambda_constraints      @rs.draw do -      match '/', :constraints => lambda { |req| +      get '/', :constraints => lambda { |req|          req.subdomain.present? and req.subdomain != "clients" },                   :to          => lambda { |env| [200, {}, %w{default}] } -      match '/', :constraints => lambda { |req| +      get '/', :constraints => lambda { |req|          req.subdomain.present? && req.subdomain == "clients" },                   :to          => lambda { |env| [200, {}, %w{clients}] }      end @@ -271,7 +271,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    end    def test_default_setup -    @rs.draw { match '/:controller(/:action(/:id))' } +    @rs.draw { get '/:controller(/:action(/:id))' }      assert_equal({:controller => "content", :action => 'index'}, rs.recognize_path("/content"))      assert_equal({:controller => "content", :action => 'list'},  rs.recognize_path("/content/list"))      assert_equal({:controller => "content", :action => 'show', :id => '10'}, rs.recognize_path("/content/show/10")) @@ -289,21 +289,21 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_ignores_leading_slash      @rs.clear! -    @rs.draw { match '/:controller(/:action(/:id))'} +    @rs.draw { get '/:controller(/:action(/:id))'}      test_default_setup    end    def test_route_with_colon_first      rs.draw do -      match '/:controller/:action/:id', :action => 'index', :id => nil -      match ':url', :controller => 'tiny_url', :action => 'translate' +      get '/:controller/:action/:id', :action => 'index', :id => nil +      get ':url', :controller => 'tiny_url', :action => 'translate'      end    end    def test_route_with_regexp_for_controller      rs.draw do -      match ':controller/:admintoken(/:action(/:id))', :controller => /admin\/.+/ -      match '/:controller(/:action(/:id))' +      get ':controller/:admintoken(/:action(/:id))', :controller => /admin\/.+/ +      get '/:controller(/:action(/:id))'      end      assert_equal({:controller => "admin/user", :admintoken => "foo", :action => "index"}, @@ -317,7 +317,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_route_with_regexp_and_captures_for_controller      rs.draw do -      match '/:controller(/:action(/:id))', :controller => /admin\/(accounts|users)/ +      get '/:controller(/:action(/:id))', :controller => /admin\/(accounts|users)/      end      assert_equal({:controller => "admin/accounts", :action => "index"}, rs.recognize_path("/admin/accounts"))      assert_equal({:controller => "admin/users", :action => "index"}, rs.recognize_path("/admin/users")) @@ -326,7 +326,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_route_with_regexp_and_dot      rs.draw do -      match ':controller/:action/:file', +      get ':controller/:action/:file',                  :controller => /admin|user/,                  :action => /upload|download/,                  :defaults => {:file => nil}, @@ -356,7 +356,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_named_route_with_option      rs.draw do -      match 'page/:title' => 'content#show_page', :as => 'page' +      get 'page/:title' => 'content#show_page', :as => 'page'      end      assert_equal("http://test.host/page/new%20stuff", @@ -365,7 +365,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_named_route_with_default      rs.draw do -      match 'page/:title' => 'content#show_page', :title => 'AboutPage', :as => 'page' +      get 'page/:title' => 'content#show_page', :title => 'AboutPage', :as => 'page'      end      assert_equal("http://test.host/page/AboutRails", @@ -375,7 +375,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_named_route_with_path_prefix      rs.draw do        scope "my" do -        match 'page' => 'content#show_page', :as => 'page' +        get 'page' => 'content#show_page', :as => 'page'        end      end @@ -386,7 +386,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_named_route_with_blank_path_prefix      rs.draw do        scope "" do -        match 'page' => 'content#show_page', :as => 'page' +        get 'page' => 'content#show_page', :as => 'page'        end      end @@ -396,7 +396,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_named_route_with_nested_controller      rs.draw do -      match 'admin/user' => 'admin/user#index', :as => "users" +      get 'admin/user' => 'admin/user#index', :as => "users"      end      assert_equal("http://test.host/admin/user", @@ -405,7 +405,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_optimised_named_route_with_host      rs.draw do -      match 'page' => 'content#show_page', :as => 'pages', :host => 'foo.com' +      get 'page' => 'content#show_page', :as => 'pages', :host => 'foo.com'      end      routes = setup_for_named_route      routes.expects(:url_for).with({ @@ -424,7 +424,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_named_route_without_hash      rs.draw do -      match ':controller/:action/:id', :as => 'normal' +      get ':controller/:action/:id', :as => 'normal'      end    end @@ -448,9 +448,9 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_named_route_with_regexps      rs.draw do -      match 'page/:year/:month/:day/:title' => 'page#show', :as => 'article', +      get 'page/:year/:month/:day/:title' => 'page#show', :as => 'article',          :year => /\d+/, :month => /\d+/, :day => /\d+/ -      match ':controller/:action/:id' +      get ':controller/:action/:id'      end      routes = setup_for_named_route @@ -460,7 +460,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    end    def test_changing_controller -    @rs.draw { match ':controller/:action/:id' } +    @rs.draw { get ':controller/:action/:id' }      assert_equal '/admin/stuff/show/10',          url_for(rs, {:controller => 'stuff', :action => 'show', :id => 10}, @@ -469,8 +469,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_paths_escaped      rs.draw do -      match 'file/*path' => 'content#show_file', :as => 'path' -      match ':controller/:action/:id' +      get 'file/*path' => 'content#show_file', :as => 'path' +      get ':controller/:action/:id'      end      # No + to space in URI escaping, only for query params. @@ -486,7 +486,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_paths_slashes_unescaped_with_ordered_parameters      rs.draw do -      match '/file/*path' => 'content#index', :as => 'path' +      get '/file/*path' => 'content#index', :as => 'path'      end      # No / to %2F in URI, only for query params. @@ -495,14 +495,14 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_non_controllers_cannot_be_matched      rs.draw do -      match ':controller/:action/:id' +      get ':controller/:action/:id'      end      assert_raise(ActionController::RoutingError) { rs.recognize_path("/not_a/show/10") }    end    def test_should_list_options_diff_when_routing_constraints_dont_match      rs.draw do -      match 'post/:id' => 'post#show', :constraints => { :id => /\d+/ }, :as => 'post' +      get 'post/:id' => 'post#show', :constraints => { :id => /\d+/ }, :as => 'post'      end      assert_raise(ActionController::RoutingError) do        url_for(rs, { :controller => 'post', :action => 'show', :bad_param => "foo", :use_route => "post" }) @@ -511,7 +511,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_dynamic_path_allowed      rs.draw do -      match '*path' => 'content#show_file' +      get '*path' => 'content#show_file'      end      assert_equal '/pages/boo', @@ -520,7 +520,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_dynamic_recall_paths_allowed      rs.draw do -      match '*path' => 'content#show_file' +      get '*path' => 'content#show_file'      end      assert_equal '/pages/boo', @@ -529,8 +529,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_backwards      rs.draw do -      match 'page/:id(/:action)' => 'pages#show' -      match ':controller(/:action(/:id))' +      get 'page/:id(/:action)' => 'pages#show' +      get ':controller(/:action(/:id))'      end      assert_equal '/page/20',   url_for(rs, { :id => 20 }, { :controller => 'pages', :action => 'show' }) @@ -540,8 +540,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_route_with_fixnum_default      rs.draw do -      match 'page(/:id)' => 'content#show_page', :id => 1 -      match ':controller/:action/:id' +      get 'page(/:id)' => 'content#show_page', :id => 1 +      get ':controller/:action/:id'      end      assert_equal '/page',    url_for(rs, { :controller => 'content', :action => 'show_page' }) @@ -557,8 +557,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    # For newer revision    def test_route_with_text_default      rs.draw do -      match 'page/:id' => 'content#show_page', :id => 1 -      match ':controller/:action/:id' +      get 'page/:id' => 'content#show_page', :id => 1 +      get ':controller/:action/:id'      end      assert_equal '/page/foo', url_for(rs, { :controller => 'content', :action => 'show_page', :id => 'foo' }) @@ -573,13 +573,13 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    end    def test_action_expiry -    @rs.draw { match ':controller(/:action(/:id))' } +    @rs.draw { get ':controller(/:action(/:id))' }      assert_equal '/content', url_for(rs, { :controller => 'content' }, { :controller => 'content', :action => 'show' })    end    def test_requirement_should_prevent_optional_id      rs.draw do -      match 'post/:id' => 'post#show', :constraints => {:id => /\d+/}, :as => 'post' +      get 'post/:id' => 'post#show', :constraints => {:id => /\d+/}, :as => 'post'      end      assert_equal '/post/10', url_for(rs, { :controller => 'post', :action => 'show', :id => 10 }) @@ -591,11 +591,11 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_both_requirement_and_optional      rs.draw do -      match('test(/:year)' => 'post#show', :as => 'blog', +      get('test(/:year)' => 'post#show', :as => 'blog',          :defaults => { :year => nil },          :constraints => { :year => /\d{4}/ }        ) -      match ':controller/:action/:id' +      get ':controller/:action/:id'      end      assert_equal '/test', url_for(rs, { :controller => 'post', :action => 'show' }) @@ -606,8 +606,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_set_to_nil_forgets      rs.draw do -      match 'pages(/:year(/:month(/:day)))' => 'content#list_pages', :month => nil, :day => nil -      match ':controller/:action/:id' +      get 'pages(/:year(/:month(/:day)))' => 'content#list_pages', :month => nil, :day => nil +      get ':controller/:action/:id'      end      assert_equal '/pages/2005', @@ -649,8 +649,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_named_route_method      rs.draw do -      match 'categories' => 'content#categories', :as => 'categories' -      match ':controller(/:action(/:id))' +      get 'categories' => 'content#categories', :as => 'categories' +      get ':controller(/:action(/:id))'      end      assert_equal '/categories', url_for(rs, { :controller => 'content', :action => 'categories' }) @@ -664,9 +664,9 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_nil_defaults      rs.draw do -      match 'journal' => 'content#list_journal', +      get 'journal' => 'content#list_journal',          :date => nil, :user_id => nil -      match ':controller/:action/:id' +      get ':controller/:action/:id'      end      assert_equal '/journal', url_for(rs, { @@ -698,7 +698,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_recognize_array_of_methods      rs.draw do        match '/match' => 'books#get_or_post', :via => [:get, :post] -      match '/match' => 'books#not_get_or_post' +      put '/match' => 'books#not_get_or_post'      end      params = rs.recognize_path("/match", :method => :post) @@ -710,10 +710,10 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_subpath_recognized      rs.draw do -      match '/books/:id/edit'    => 'subpath_books#edit' -      match '/items/:id/:action' => 'subpath_books' -      match '/posts/new/:action' => 'subpath_books' -      match '/posts/:id'         => 'subpath_books#show' +      get '/books/:id/edit'    => 'subpath_books#edit' +      get '/items/:id/:action' => 'subpath_books' +      get '/posts/new/:action' => 'subpath_books' +      get '/posts/:id'         => 'subpath_books#show'      end      hash = rs.recognize_path "/books/17/edit" @@ -735,9 +735,9 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_subpath_generated      rs.draw do -      match '/books/:id/edit'    => 'subpath_books#edit' -      match '/items/:id/:action' => 'subpath_books' -      match '/posts/new/:action' => 'subpath_books' +      get '/books/:id/edit'    => 'subpath_books#edit' +      get '/items/:id/:action' => 'subpath_books' +      get '/posts/new/:action' => 'subpath_books'      end      assert_equal "/books/7/edit",      url_for(rs, { :controller => "subpath_books", :id => 7, :action => "edit" }) @@ -747,7 +747,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_failed_constraints_raises_exception_with_violated_constraints      rs.draw do -      match 'foos/:id' => 'foos#show', :as => 'foo_with_requirement', :constraints => { :id => /\d+/ } +      get 'foos/:id' => 'foos#show', :as => 'foo_with_requirement', :constraints => { :id => /\d+/ }      end      assert_raise(ActionController::RoutingError) do @@ -758,11 +758,11 @@ class LegacyRouteSetTests < ActiveSupport::TestCase    def test_routes_changed_correctly_after_clear      rs = ::ActionDispatch::Routing::RouteSet.new      rs.draw do -      match 'ca' => 'ca#aa' -      match 'cb' => 'cb#ab' -      match 'cc' => 'cc#ac' -      match ':controller/:action/:id' -      match ':controller/:action/:id.:format' +      get 'ca' => 'ca#aa' +      get 'cb' => 'cb#ab' +      get 'cc' => 'cc#ac' +      get ':controller/:action/:id' +      get ':controller/:action/:id.:format'      end      hash = rs.recognize_path "/cc" @@ -771,10 +771,10 @@ class LegacyRouteSetTests < ActiveSupport::TestCase      assert_equal %w(cc ac), [hash[:controller], hash[:action]]      rs.draw do -      match 'cb' => 'cb#ab' -      match 'cc' => 'cc#ac' -      match ':controller/:action/:id' -      match ':controller/:action/:id.:format' +      get 'cb' => 'cb#ab' +      get 'cc' => 'cc#ac' +      get ':controller/:action/:id' +      get ':controller/:action/:id.:format'      end      hash = rs.recognize_path "/cc" @@ -799,29 +799,29 @@ class RouteSetTest < ActiveSupport::TestCase      @default_route_set ||= begin        set = ROUTING::RouteSet.new        set.draw do -        match '/:controller(/:action(/:id))' +        get '/:controller(/:action(/:id))'        end        set      end    end    def test_generate_extras -    set.draw { match ':controller/(:action(/:id))' } +    set.draw { get ':controller/(:action(/:id))' }      path, extras = set.generate_extras(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world")      assert_equal "/foo/bar/15", path      assert_equal %w(that this), extras.map { |e| e.to_s }.sort    end    def test_extra_keys -    set.draw { match ':controller/:action/:id' } +    set.draw { get ':controller/:action/:id' }      extras = set.extra_keys(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world")      assert_equal %w(that this), extras.map { |e| e.to_s }.sort    end    def test_generate_extras_not_first      set.draw do -      match ':controller/:action/:id.:format' -      match ':controller/:action/:id' +      get ':controller/:action/:id.:format' +      get ':controller/:action/:id'      end      path, extras = set.generate_extras(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world")      assert_equal "/foo/bar/15", path @@ -830,8 +830,8 @@ class RouteSetTest < ActiveSupport::TestCase    def test_generate_not_first      set.draw do -      match ':controller/:action/:id.:format' -      match ':controller/:action/:id' +      get ':controller/:action/:id.:format' +      get ':controller/:action/:id'      end      assert_equal "/foo/bar/15?this=hello",          url_for(set, { :controller => "foo", :action => "bar", :id => 15, :this => "hello" }) @@ -839,8 +839,8 @@ class RouteSetTest < ActiveSupport::TestCase    def test_extra_keys_not_first      set.draw do -      match ':controller/:action/:id.:format' -      match ':controller/:action/:id' +      get ':controller/:action/:id.:format' +      get ':controller/:action/:id'      end      extras = set.extra_keys(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world")      assert_equal %w(that this), extras.map { |e| e.to_s }.sort @@ -849,7 +849,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_draw      assert_equal 0, set.routes.size      set.draw do -      match '/hello/world' => 'a#b' +      get '/hello/world' => 'a#b'      end      assert_equal 1, set.routes.size    end @@ -857,7 +857,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_draw_symbol_controller_name      assert_equal 0, set.routes.size      set.draw do -      match '/users/index' => 'users#index' +      get '/users/index' => 'users#index'      end      set.recognize_path('/users/index', :method => :get)      assert_equal 1, set.routes.size @@ -866,7 +866,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_named_draw      assert_equal 0, set.routes.size      set.draw do -      match '/hello/world' => 'a#b', :as => 'hello' +      get '/hello/world' => 'a#b', :as => 'hello'      end      assert_equal 1, set.routes.size      assert_equal set.routes.first, set.named_routes[:hello] @@ -874,18 +874,18 @@ class RouteSetTest < ActiveSupport::TestCase    def test_earlier_named_routes_take_precedence      set.draw do -      match '/hello/world' => 'a#b', :as => 'hello' -      match '/hello'       => 'a#b', :as => 'hello' +      get '/hello/world' => 'a#b', :as => 'hello' +      get '/hello'       => 'a#b', :as => 'hello'      end      assert_equal set.routes.first, set.named_routes[:hello]    end    def setup_named_route_test      set.draw do -      match '/people(/:id)' => 'people#show', :as => 'show' -      match '/people' => 'people#index', :as => 'index' -      match '/people/go/:foo/:bar/joe(/:id)' => 'people#multi', :as => 'multi' -      match '/admin/users' => 'admin/users#index', :as => "users" +      get '/people(/:id)' => 'people#show', :as => 'show' +      get '/people' => 'people#index', :as => 'index' +      get '/people/go/:foo/:bar/joe(/:id)' => 'people#multi', :as => 'multi' +      get '/admin/users' => 'admin/users#index', :as => "users"      end      MockController.build(set.url_helpers).new @@ -985,7 +985,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_draw_default_route      set.draw do -      match '/:controller/:action/:id' +      get '/:controller/:action/:id'      end      assert_equal 1, set.routes.size @@ -999,8 +999,8 @@ class RouteSetTest < ActiveSupport::TestCase    def test_route_with_parameter_shell      set.draw do -      match 'page/:id' => 'pages#show', :id => /\d+/ -      match '/:controller(/:action(/:id))' +      get 'page/:id' => 'pages#show', :id => /\d+/ +      get '/:controller(/:action(/:id))'      end      assert_equal({:controller => 'pages', :action => 'index'}, set.recognize_path('/pages')) @@ -1014,7 +1014,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_route_constraints_on_request_object_with_anchors_are_valid      assert_nothing_raised do        set.draw do -        match 'page/:id' => 'pages#show', :constraints => { :host => /^foo$/ } +        get 'page/:id' => 'pages#show', :constraints => { :host => /^foo$/ }        end      end    end @@ -1022,27 +1022,27 @@ class RouteSetTest < ActiveSupport::TestCase    def test_route_constraints_with_anchor_chars_are_invalid      assert_raise ArgumentError do        set.draw do -        match 'page/:id' => 'pages#show', :id => /^\d+/ +        get 'page/:id' => 'pages#show', :id => /^\d+/        end      end      assert_raise ArgumentError do        set.draw do -        match 'page/:id' => 'pages#show', :id => /\A\d+/ +        get 'page/:id' => 'pages#show', :id => /\A\d+/        end      end      assert_raise ArgumentError do        set.draw do -        match 'page/:id' => 'pages#show', :id => /\d+$/ +        get 'page/:id' => 'pages#show', :id => /\d+$/        end      end      assert_raise ArgumentError do        set.draw do -        match 'page/:id' => 'pages#show', :id => /\d+\Z/ +        get 'page/:id' => 'pages#show', :id => /\d+\Z/        end      end      assert_raise ArgumentError do        set.draw do -        match 'page/:id' => 'pages#show', :id => /\d+\z/ +        get 'page/:id' => 'pages#show', :id => /\d+\z/        end      end    end @@ -1057,7 +1057,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_recognize_with_encoded_id_and_regex      set.draw do -      match 'page/:id' => 'pages#show', :id => /[a-zA-Z0-9\+]+/ +      get 'page/:id' => 'pages#show', :id => /[a-zA-Z0-9\+]+/      end      assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, set.recognize_path('/page/10')) @@ -1128,7 +1128,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_typo_recognition      set.draw do -      match 'articles/:year/:month/:day/:title' => 'articles#permalink', +      get 'articles/:year/:month/:day/:title' => 'articles#permalink',               :year => /\d{4}/, :day => /\d{1,2}/, :month => /\d{1,2}/      end @@ -1143,7 +1143,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_routing_traversal_does_not_load_extra_classes      assert !Object.const_defined?("Profiler__"), "Profiler should not be loaded"      set.draw do -      match '/profile' => 'profile#index' +      get '/profile' => 'profile#index'      end      set.recognize_path("/profile") rescue nil @@ -1177,8 +1177,8 @@ class RouteSetTest < ActiveSupport::TestCase    def test_generate_with_default_action      set.draw do -      match "/people", :controller => "people", :action => "index" -      match "/people/list", :controller => "people", :action => "list" +      get "/people", :controller => "people", :action => "index" +      get "/people/list", :controller => "people", :action => "list"      end      url = url_for(set, { :controller => "people", :action => "list" }) @@ -1197,7 +1197,7 @@ class RouteSetTest < ActiveSupport::TestCase      set.draw do        namespace 'api' do -        match 'inventory' => 'products#inventory' +        get 'inventory' => 'products#inventory'        end      end @@ -1222,7 +1222,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_namespace_with_path_prefix      set.draw do        scope :module => "api", :path => "prefix" do -        match 'inventory' => 'products#inventory' +        get 'inventory' => 'products#inventory'        end      end @@ -1234,7 +1234,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_namespace_with_blank_path_prefix      set.draw do        scope :module => "api", :path => "" do -        match 'inventory' => 'products#inventory' +        get 'inventory' => 'products#inventory'        end      end @@ -1244,7 +1244,7 @@ class RouteSetTest < ActiveSupport::TestCase    end    def test_generate_changes_controller_module -    set.draw { match ':controller/:action/:id' } +    set.draw { get ':controller/:action/:id' }      current = { :controller => "bling/bloop", :action => "bap", :id => 9 }      assert_equal "/foo/bar/baz/7", @@ -1253,7 +1253,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_id_is_sticky_when_it_ought_to_be      set.draw do -      match ':controller/:id/:action' +      get ':controller/:id/:action'      end      url = url_for(set, { :action => "destroy" }, { :controller => "people", :action => "show", :id => "7" }) @@ -1262,8 +1262,8 @@ class RouteSetTest < ActiveSupport::TestCase    def test_use_static_path_when_possible      set.draw do -      match 'about' => "welcome#about" -      match ':controller/:action/:id' +      get 'about' => "welcome#about" +      get ':controller/:action/:id'      end      url = url_for(set, { :controller => "welcome", :action => "about" }, @@ -1273,7 +1273,7 @@ class RouteSetTest < ActiveSupport::TestCase    end    def test_generate -    set.draw { match ':controller/:action/:id' } +    set.draw { get ':controller/:action/:id' }      args = { :controller => "foo", :action => "bar", :id => "7", :x => "y" }      assert_equal "/foo/bar/7?x=y",     url_for(set, args) @@ -1284,7 +1284,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_generate_with_path_prefix      set.draw do        scope "my" do -        match ':controller(/:action(/:id))' +        get ':controller(/:action(/:id))'        end      end @@ -1295,7 +1295,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_generate_with_blank_path_prefix      set.draw do        scope "" do -        match ':controller(/:action(/:id))' +        get ':controller(/:action(/:id))'        end      end @@ -1305,9 +1305,9 @@ class RouteSetTest < ActiveSupport::TestCase    def test_named_routes_are_never_relative_to_modules      set.draw do -      match "/connection/manage(/:action)" => 'connection/manage#index' -      match "/connection/connection" => "connection/connection#index" -      match '/connection' => 'connection#index', :as => 'family_connection' +      get "/connection/manage(/:action)" => 'connection/manage#index' +      get "/connection/connection" => "connection/connection#index" +      get '/connection' => 'connection#index', :as => 'family_connection'      end      url = url_for(set, { :controller => "connection" }, { :controller => 'connection/manage' }) @@ -1319,7 +1319,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_action_left_off_when_id_is_recalled      set.draw do -      match ':controller(/:action(/:id))' +      get ':controller(/:action(/:id))'      end      assert_equal '/books', url_for(set,        {:controller => 'books', :action => 'index'}, @@ -1329,8 +1329,8 @@ class RouteSetTest < ActiveSupport::TestCase    def test_query_params_will_be_shown_when_recalled      set.draw do -      match 'show_weblog/:parameter' => 'weblog#show' -      match ':controller(/:action(/:id))' +      get 'show_weblog/:parameter' => 'weblog#show' +      get ':controller(/:action(/:id))'      end      assert_equal '/weblog/edit?parameter=1', url_for(set,        {:action => 'edit', :parameter => 1}, @@ -1340,7 +1340,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_format_is_not_inherit      set.draw do -      match '/posts(.:format)' => 'posts#index' +      get '/posts(.:format)' => 'posts#index'      end      assert_equal '/posts', url_for(set, @@ -1355,7 +1355,7 @@ class RouteSetTest < ActiveSupport::TestCase    end    def test_expiry_determination_should_consider_values_with_to_param -    set.draw { match 'projects/:project_id/:controller/:action' } +    set.draw { get 'projects/:project_id/:controller/:action' }      assert_equal '/projects/1/weblog/show', url_for(set,        { :action => 'show', :project_id => 1 },        { :controller => 'weblog', :action => 'show', :project_id => '1' }) @@ -1365,7 +1365,7 @@ class RouteSetTest < ActiveSupport::TestCase      set.draw do        resources :projects do          member do -          match 'milestones' => 'milestones#index', :as => 'milestones' +          get 'milestones' => 'milestones#index', :as => 'milestones'          end        end      end @@ -1398,7 +1398,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_route_constraints_with_unsupported_regexp_options_must_error      assert_raise ArgumentError do        set.draw do -        match 'page/:name' => 'pages#show', +        get 'page/:name' => 'pages#show',            :constraints => { :name => /(david|jamis)/m }        end      end @@ -1407,13 +1407,13 @@ class RouteSetTest < ActiveSupport::TestCase    def test_route_constraints_with_supported_options_must_not_error      assert_nothing_raised do        set.draw do -        match 'page/:name' => 'pages#show', +        get 'page/:name' => 'pages#show',            :constraints => { :name => /(david|jamis)/i }        end      end      assert_nothing_raised do        set.draw do -        match 'page/:name' => 'pages#show', +        get 'page/:name' => 'pages#show',            :constraints => { :name => / # Desperately overcommented regexp                                        ( #Either                                         david #The Creator @@ -1427,7 +1427,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_route_with_subdomain_and_constraints_must_receive_params      name_param = nil      set.draw do -      match 'page/:name' => 'pages#show', :constraints => lambda {|request| +      get 'page/:name' => 'pages#show', :constraints => lambda {|request|          name_param = request.params[:name]          return true        } @@ -1439,7 +1439,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_route_requirement_recognize_with_ignore_case      set.draw do -      match 'page/:name' => 'pages#show', +      get 'page/:name' => 'pages#show',          :constraints => {:name => /(david|jamis)/i}      end      assert_equal({:controller => 'pages', :action => 'show', :name => 'jamis'}, set.recognize_path('/page/jamis')) @@ -1451,7 +1451,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_route_requirement_generate_with_ignore_case      set.draw do -      match 'page/:name' => 'pages#show', +      get 'page/:name' => 'pages#show',          :constraints => {:name => /(david|jamis)/i}      end @@ -1466,7 +1466,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_route_requirement_recognize_with_extended_syntax      set.draw do -      match 'page/:name' => 'pages#show', +      get 'page/:name' => 'pages#show',          :constraints => {:name => / # Desperately overcommented regexp                                      ( #Either                                       david #The Creator @@ -1486,7 +1486,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_route_requirement_with_xi_modifiers      set.draw do -      match 'page/:name' => 'pages#show', +      get 'page/:name' => 'pages#show',          :constraints => {:name => / # Desperately overcommented regexp                                      ( #Either                                       david #The Creator @@ -1504,8 +1504,8 @@ class RouteSetTest < ActiveSupport::TestCase    def test_routes_with_symbols      set.draw do -      match 'unnamed', :controller => :pages, :action => :show, :name => :as_symbol -      match 'named'  , :controller => :pages, :action => :show, :name => :as_symbol, :as => :named +      get 'unnamed', :controller => :pages, :action => :show, :name => :as_symbol +      get 'named'  , :controller => :pages, :action => :show, :name => :as_symbol, :as => :named      end      assert_equal({:controller => 'pages', :action => 'show', :name => :as_symbol}, set.recognize_path('/unnamed'))      assert_equal({:controller => 'pages', :action => 'show', :name => :as_symbol}, set.recognize_path('/named')) @@ -1513,8 +1513,8 @@ class RouteSetTest < ActiveSupport::TestCase    def test_regexp_chunk_should_add_question_mark_for_optionals      set.draw do -      match '/' => 'foo#index' -      match '/hello' => 'bar#index' +      get '/' => 'foo#index' +      get '/hello' => 'bar#index'      end      assert_equal '/',      url_for(set, { :controller => 'foo' }) @@ -1526,7 +1526,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_assign_route_options_with_anchor_chars      set.draw do -      match '/cars/:action/:person/:car/', :controller => 'cars' +      get '/cars/:action/:person/:car/', :controller => 'cars'      end      assert_equal '/cars/buy/1/2', url_for(set, { :controller => 'cars', :action => 'buy', :person => '1', :car => '2' }) @@ -1536,7 +1536,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_segmentation_of_dot_path      set.draw do -      match '/books/:action.rss', :controller => 'books' +      get '/books/:action.rss', :controller => 'books'      end      assert_equal '/books/list.rss', url_for(set, { :controller => 'books', :action => 'list' }) @@ -1546,7 +1546,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_segmentation_of_dynamic_dot_path      set.draw do -      match '/books(/:action(.:format))', :controller => 'books' +      get '/books(/:action(.:format))', :controller => 'books'      end      assert_equal '/books/list.rss', url_for(set, { :controller => 'books', :action => 'list', :format => 'rss' }) @@ -1562,7 +1562,7 @@ class RouteSetTest < ActiveSupport::TestCase    def test_slashes_are_implied      @set = nil -    set.draw { match("/:controller(/:action(/:id))") } +    set.draw { get("/:controller(/:action(/:id))") }      assert_equal '/content',        url_for(set, { :controller => 'content', :action => 'index' })      assert_equal '/content/list',   url_for(set, { :controller => 'content', :action => 'list' }) @@ -1647,13 +1647,13 @@ class RouteSetTest < ActiveSupport::TestCase    def test_generate_with_default_params      set.draw do -      match 'dummy/page/:page' => 'dummy#show' -      match 'dummy/dots/page.:page' => 'dummy#dots' -      match 'ibocorp(/:page)' => 'ibocorp#show', +      get 'dummy/page/:page' => 'dummy#show' +      get 'dummy/dots/page.:page' => 'dummy#dots' +      get 'ibocorp(/:page)' => 'ibocorp#show',                               :constraints => { :page => /\d+/ },                               :defaults => { :page => 1 } -      match ':controller/:action/:id' +      get ':controller/:action/:id'      end      assert_equal '/ibocorp', url_for(set, { :controller => 'ibocorp', :action => "show", :page => 1 }) @@ -1661,17 +1661,17 @@ class RouteSetTest < ActiveSupport::TestCase    def test_generate_with_optional_params_recalls_last_request      set.draw do -      match "blog/", :controller => "blog", :action => "index" +      get "blog/", :controller => "blog", :action => "index" -      match "blog(/:year(/:month(/:day)))", +      get "blog(/:year(/:month(/:day)))",              :controller => "blog",              :action => "show_date",              :constraints => { :year => /(19|20)\d\d/, :month => /[01]?\d/, :day => /[0-3]?\d/ },              :day => nil, :month => nil -      match "blog/show/:id", :controller => "blog", :action => "show", :id => /\d+/ -      match "blog/:controller/:action(/:id)" -      match "*anything", :controller => "blog", :action => "unknown_request" +      get "blog/show/:id", :controller => "blog", :action => "show", :id => /\d+/ +      get "blog/:controller/:action(/:id)" +      get "*anything", :controller => "blog", :action => "unknown_request"      end      assert_equal({:controller => "blog", :action => "index"}, set.recognize_path("/blog")) @@ -1719,7 +1719,7 @@ class RackMountIntegrationTests < ActiveSupport::TestCase        root :to => 'users#index'      end -    match '/blog(/:year(/:month(/:day)))' => 'posts#show_date', +    get '/blog(/:year(/:month(/:day)))' => 'posts#show_date',        :constraints => {          :year => /(19|20)\d\d/,          :month => /[01]?\d/, @@ -1728,37 +1728,37 @@ class RackMountIntegrationTests < ActiveSupport::TestCase        :day => nil,        :month => nil -    match 'archive/:year', :controller => 'archive', :action => 'index', +    get 'archive/:year', :controller => 'archive', :action => 'index',        :defaults => { :year => nil },        :constraints => { :year => /\d{4}/ },        :as => "blog"      resources :people -    match 'legacy/people' => "people#index", :legacy => "true" +    get 'legacy/people' => "people#index", :legacy => "true" -    match 'symbols', :controller => :symbols, :action => :show, :name => :as_symbol -    match 'id_default(/:id)' => "foo#id_default", :id => 1 +    get 'symbols', :controller => :symbols, :action => :show, :name => :as_symbol +    get 'id_default(/:id)' => "foo#id_default", :id => 1      match 'get_or_post' => "foo#get_or_post", :via => [:get, :post] -    match 'optional/:optional' => "posts#index" -    match 'projects/:project_id' => "project#index", :as => "project" -    match 'clients' => "projects#index" +    get 'optional/:optional' => "posts#index" +    get 'projects/:project_id' => "project#index", :as => "project" +    get 'clients' => "projects#index" -    match 'ignorecase/geocode/:postalcode' => 'geocode#show', :postalcode => /hx\d\d-\d[a-z]{2}/i -    match 'extended/geocode/:postalcode' => 'geocode#show',:constraints => { +    get 'ignorecase/geocode/:postalcode' => 'geocode#show', :postalcode => /hx\d\d-\d[a-z]{2}/i +    get 'extended/geocode/:postalcode' => 'geocode#show',:constraints => {                    :postalcode => /# Postcode format                                    \d{5} #Prefix                                    (-\d{4})? #Suffix                                    /x                    }, :as => "geocode" -    match 'news(.:format)' => "news#index" +    get 'news(.:format)' => "news#index" -    match 'comment/:id(/:action)' => "comments#show" -    match 'ws/:controller(/:action(/:id))', :ws => true -    match 'account(/:action)' => "account#subscription" -    match 'pages/:page_id/:controller(/:action(/:id))' -    match ':controller/ping', :action => 'ping' -    match ':controller(/:action(/:id))(.:format)' +    get 'comment/:id(/:action)' => "comments#show" +    get 'ws/:controller(/:action(/:id))', :ws => true +    get 'account(/:action)' => "account#subscription" +    get 'pages/:page_id/:controller(/:action(/:id))' +    get ':controller/ping', :action => 'ping' +    match ':controller(/:action(/:id))(.:format)', :via => :all      root :to => "news#index"    } diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index ecba9fed22..e8411bae0c 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -138,7 +138,7 @@ XML      @request.env['PATH_INFO'] = nil      @routes = ActionDispatch::Routing::RouteSet.new.tap do |r|        r.draw do -        match ':controller(/:action(/:id))' +        get ':controller(/:action(/:id))'        end      end    end @@ -524,7 +524,7 @@ XML      with_routing do |set|        set.draw do          namespace :admin do -          match 'user' => 'user#index' +          get 'user' => 'user#index'          end        end @@ -534,7 +534,7 @@ XML    def test_assert_routing_with_glob      with_routing do |set| -      set.draw { match('*path' => "pages#show") } +      set.draw { get('*path' => "pages#show") }        assert_routing('/company/about', { :controller => 'pages', :action => 'show', :path => 'company/about' })      end    end @@ -585,8 +585,8 @@ XML    def test_array_path_parameter_handled_properly      with_routing do |set|        set.draw do -        match 'file/*path', :to => 'test_case_test/test#test_params' -        match ':controller/:action' +        get 'file/*path', :to => 'test_case_test/test#test_params' +        get ':controller/:action'        end        get :test_params, :path => ['hello', 'world'] diff --git a/actionpack/test/controller/url_for_integration_test.rb b/actionpack/test/controller/url_for_integration_test.rb index 451ea6027d..6c2311e7a5 100644 --- a/actionpack/test/controller/url_for_integration_test.rb +++ b/actionpack/test/controller/url_for_integration_test.rb @@ -18,7 +18,7 @@ module ActionPack          root :to => 'users#index'        end -      match '/blog(/:year(/:month(/:day)))' => 'posts#show_date', +      get '/blog(/:year(/:month(/:day)))' => 'posts#show_date',          :constraints => {            :year => /(19|20)\d\d/,            :month => /[01]?\d/, @@ -27,7 +27,7 @@ module ActionPack          :day => nil,          :month => nil -      match 'archive/:year', :controller => 'archive', :action => 'index', +      get 'archive/:year', :controller => 'archive', :action => 'index',          :defaults => { :year => nil },          :constraints => { :year => /\d{4}/ },          :as => "blog" @@ -35,29 +35,29 @@ module ActionPack        resources :people        #match 'legacy/people' => "people#index", :legacy => "true" -      match 'symbols', :controller => :symbols, :action => :show, :name => :as_symbol -      match 'id_default(/:id)' => "foo#id_default", :id => 1 +      get 'symbols', :controller => :symbols, :action => :show, :name => :as_symbol +      get 'id_default(/:id)' => "foo#id_default", :id => 1        match 'get_or_post' => "foo#get_or_post", :via => [:get, :post] -      match 'optional/:optional' => "posts#index" -      match 'projects/:project_id' => "project#index", :as => "project" -      match 'clients' => "projects#index" +      get 'optional/:optional' => "posts#index" +      get 'projects/:project_id' => "project#index", :as => "project" +      get 'clients' => "projects#index" -      match 'ignorecase/geocode/:postalcode' => 'geocode#show', :postalcode => /hx\d\d-\d[a-z]{2}/i -      match 'extended/geocode/:postalcode' => 'geocode#show',:constraints => { +      get 'ignorecase/geocode/:postalcode' => 'geocode#show', :postalcode => /hx\d\d-\d[a-z]{2}/i +      get 'extended/geocode/:postalcode' => 'geocode#show',:constraints => {          :postalcode => /# Postcode format          \d{5} #Prefix          (-\d{4})? #Suffix          /x        }, :as => "geocode" -      match 'news(.:format)' => "news#index" +      get 'news(.:format)' => "news#index" -      match 'comment/:id(/:action)' => "comments#show" -      match 'ws/:controller(/:action(/:id))', :ws => true -      match 'account(/:action)' => "account#subscription" -      match 'pages/:page_id/:controller(/:action(/:id))' -      match ':controller/ping', :action => 'ping' -      match ':controller(/:action(/:id))(.:format)' +      get 'comment/:id(/:action)' => "comments#show" +      get 'ws/:controller(/:action(/:id))', :ws => true +      get 'account(/:action)' => "account#subscription" +      get 'pages/:page_id/:controller(/:action(/:id))' +      get ':controller/ping', :action => 'ping' +      get ':controller(/:action(/:id))(.:format)'        root :to => "news#index"      } diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb index aa233d6135..b2cb5f80d5 100644 --- a/actionpack/test/controller/url_for_test.rb +++ b/actionpack/test/controller/url_for_test.rb @@ -5,7 +5,7 @@ module AbstractController      class UrlForTests < ActionController::TestCase        class W -        include ActionDispatch::Routing::RouteSet.new.tap { |r| r.draw { match ':controller(/:action(/:id(.:format)))' } }.url_helpers +        include ActionDispatch::Routing::RouteSet.new.tap { |r| r.draw { get ':controller(/:action(/:id(.:format)))' } }.url_helpers        end        def teardown @@ -210,8 +210,8 @@ module AbstractController        def test_named_routes          with_routing do |set|            set.draw do -            match 'this/is/verbose', :to => 'home#index', :as => :no_args -            match 'home/sweet/home/:user', :to => 'home#index', :as => :home +            get 'this/is/verbose', :to => 'home#index', :as => :no_args +            get 'home/sweet/home/:user', :to => 'home#index', :as => :home            end            # We need to create a new class in order to install the new named route. @@ -231,7 +231,7 @@ module AbstractController        def test_relative_url_root_is_respected_for_named_routes          with_routing do |set|            set.draw do -            match '/home/sweet/home/:user', :to => 'home#index', :as => :home +            get '/home/sweet/home/:user', :to => 'home#index', :as => :home            end            kls = Class.new { include set.url_helpers } @@ -245,8 +245,8 @@ module AbstractController        def test_only_path          with_routing do |set|            set.draw do -            match 'home/sweet/home/:user', :to => 'home#index', :as => :home -            match ':controller/:action/:id' +            get 'home/sweet/home/:user', :to => 'home#index', :as => :home +            get ':controller/:action/:id'            end            # We need to create a new class in order to install the new named route. @@ -313,8 +313,8 @@ module AbstractController        def test_named_routes_with_nil_keys          with_routing do |set|            set.draw do -            match 'posts.:format', :to => 'posts#index', :as => :posts -            match '/', :to => 'posts#index', :as => :main +            get 'posts.:format', :to => 'posts#index', :as => :posts +            get '/', :to => 'posts#index', :as => :main            end            # We need to create a new class in order to install the new named route. diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb index f88903b10e..cc3706aeee 100644 --- a/actionpack/test/controller/url_rewriter_test.rb +++ b/actionpack/test/controller/url_rewriter_test.rb @@ -21,7 +21,7 @@ class UrlRewriterTests < ActionController::TestCase      @rewriter = Rewriter.new(@request) #.new(@request, @params)      @routes = ActionDispatch::Routing::RouteSet.new.tap do |r|        r.draw do -        match ':controller(/:action(/:id))' +        get ':controller(/:action(/:id))'        end      end    end diff --git a/actionpack/test/controller/webservice_test.rb b/actionpack/test/controller/webservice_test.rb index 351e61eeae..c0b9833603 100644 --- a/actionpack/test/controller/webservice_test.rb +++ b/actionpack/test/controller/webservice_test.rb @@ -254,7 +254,7 @@ class WebServiceTest < ActionDispatch::IntegrationTest      def with_test_route_set        with_routing do |set|          set.draw do -          match '/', :to => 'web_service_test/test#assign_parameters' +          match '/', :to => 'web_service_test/test#assign_parameters', :via => :all          end          yield        end diff --git a/actionpack/test/dispatch/mapper_test.rb b/actionpack/test/dispatch/mapper_test.rb index d3465589c1..8070bdec8a 100644 --- a/actionpack/test/dispatch/mapper_test.rb +++ b/actionpack/test/dispatch/mapper_test.rb @@ -37,7 +37,7 @@ module ActionDispatch        end        def test_mapping_requirements -        options = { :controller => 'foo', :action => 'bar' } +        options = { :controller => 'foo', :action => 'bar', :via => :get }          m = Mapper::Mapping.new FakeSet.new, {}, '/store/:name(*rest)', options          _, _, requirements, _ = m.to_route          assert_equal(/.+?/, requirements[:rest]) @@ -46,7 +46,7 @@ module ActionDispatch        def test_map_slash          fakeset = FakeSet.new          mapper = Mapper.new fakeset -        mapper.match '/', :to => 'posts#index', :as => :main +        mapper.get '/', :to => 'posts#index', :as => :main          assert_equal '/', fakeset.conditions.first[:path_info]        end @@ -55,14 +55,14 @@ module ActionDispatch          mapper = Mapper.new fakeset          # FIXME: is this a desired behavior? -        mapper.match '/one/two/', :to => 'posts#index', :as => :main +        mapper.get '/one/two/', :to => 'posts#index', :as => :main          assert_equal '/one/two(.:format)', fakeset.conditions.first[:path_info]        end        def test_map_wildcard          fakeset = FakeSet.new          mapper = Mapper.new fakeset -        mapper.match '/*path', :to => 'pages#show' +        mapper.get '/*path', :to => 'pages#show'          assert_equal '/*path(.:format)', fakeset.conditions.first[:path_info]          assert_equal(/.+?/, fakeset.requirements.first[:path])        end @@ -70,7 +70,7 @@ module ActionDispatch        def test_map_wildcard_with_other_element          fakeset = FakeSet.new          mapper = Mapper.new fakeset -        mapper.match '/*path/foo/:bar', :to => 'pages#show' +        mapper.get '/*path/foo/:bar', :to => 'pages#show'          assert_equal '/*path/foo/:bar(.:format)', fakeset.conditions.first[:path_info]          assert_nil fakeset.requirements.first[:path]        end @@ -78,7 +78,7 @@ module ActionDispatch        def test_map_wildcard_with_multiple_wildcard          fakeset = FakeSet.new          mapper = Mapper.new fakeset -        mapper.match '/*foo/*bar', :to => 'pages#show' +        mapper.get '/*foo/*bar', :to => 'pages#show'          assert_equal '/*foo/*bar(.:format)', fakeset.conditions.first[:path_info]          assert_nil fakeset.requirements.first[:foo]          assert_equal(/.+?/, fakeset.requirements.first[:bar]) @@ -87,7 +87,7 @@ module ActionDispatch        def test_map_wildcard_with_format_false          fakeset = FakeSet.new          mapper = Mapper.new fakeset -        mapper.match '/*path', :to => 'pages#show', :format => false +        mapper.get '/*path', :to => 'pages#show', :format => false          assert_equal '/*path', fakeset.conditions.first[:path_info]          assert_nil fakeset.requirements.first[:path]        end @@ -95,7 +95,7 @@ module ActionDispatch        def test_map_wildcard_with_format_true          fakeset = FakeSet.new          mapper = Mapper.new fakeset -        mapper.match '/*path', :to => 'pages#show', :format => true +        mapper.get '/*path', :to => 'pages#show', :format => true          assert_equal '/*path.:format', fakeset.conditions.first[:path_info]        end      end diff --git a/actionpack/test/dispatch/prefix_generation_test.rb b/actionpack/test/dispatch/prefix_generation_test.rb index bd5b5edab0..ab2f7612ce 100644 --- a/actionpack/test/dispatch/prefix_generation_test.rb +++ b/actionpack/test/dispatch/prefix_generation_test.rb @@ -25,12 +25,12 @@ module TestGenerationPrefix          @routes ||= begin            routes = ActionDispatch::Routing::RouteSet.new            routes.draw do -            match "/posts/:id", :to => "inside_engine_generating#show", :as => :post -            match "/posts", :to => "inside_engine_generating#index", :as => :posts -            match "/url_to_application", :to => "inside_engine_generating#url_to_application" -            match "/polymorphic_path_for_engine", :to => "inside_engine_generating#polymorphic_path_for_engine" -            match "/conflicting_url", :to => "inside_engine_generating#conflicting" -            match "/foo", :to => "never#invoked", :as => :named_helper_that_should_be_invoked_only_in_respond_to_test +            get "/posts/:id", :to => "inside_engine_generating#show", :as => :post +            get "/posts", :to => "inside_engine_generating#index", :as => :posts +            get "/url_to_application", :to => "inside_engine_generating#url_to_application" +            get "/polymorphic_path_for_engine", :to => "inside_engine_generating#polymorphic_path_for_engine" +            get "/conflicting_url", :to => "inside_engine_generating#conflicting" +            get "/foo", :to => "never#invoked", :as => :named_helper_that_should_be_invoked_only_in_respond_to_test            end            routes @@ -51,12 +51,12 @@ module TestGenerationPrefix              scope "/:omg", :omg => "awesome" do                mount BlogEngine => "/blog", :as => "blog_engine"              end -            match "/posts/:id", :to => "outside_engine_generating#post", :as => :post -            match "/generate", :to => "outside_engine_generating#index" -            match "/polymorphic_path_for_app", :to => "outside_engine_generating#polymorphic_path_for_app" -            match "/polymorphic_path_for_engine", :to => "outside_engine_generating#polymorphic_path_for_engine" -            match "/polymorphic_with_url_for", :to => "outside_engine_generating#polymorphic_with_url_for" -            match "/conflicting_url", :to => "outside_engine_generating#conflicting" +            get "/posts/:id", :to => "outside_engine_generating#post", :as => :post +            get "/generate", :to => "outside_engine_generating#index" +            get "/polymorphic_path_for_app", :to => "outside_engine_generating#polymorphic_path_for_app" +            get "/polymorphic_path_for_engine", :to => "outside_engine_generating#polymorphic_path_for_engine" +            get "/polymorphic_with_url_for", :to => "outside_engine_generating#polymorphic_with_url_for" +            get "/conflicting_url", :to => "outside_engine_generating#conflicting"              root :to => "outside_engine_generating#index"            end @@ -282,7 +282,7 @@ module TestGenerationPrefix          @routes ||= begin            routes = ActionDispatch::Routing::RouteSet.new            routes.draw do -            match "/posts/:id", :to => "posts#show", :as => :post +            get "/posts/:id", :to => "posts#show", :as => :post            end            routes diff --git a/actionpack/test/dispatch/request/json_params_parsing_test.rb b/actionpack/test/dispatch/request/json_params_parsing_test.rb index ae425dd406..302bff0696 100644 --- a/actionpack/test/dispatch/request/json_params_parsing_test.rb +++ b/actionpack/test/dispatch/request/json_params_parsing_test.rb @@ -65,7 +65,7 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest      def with_test_routing        with_routing do |set|          set.draw do -          match ':action', :to => ::JsonParamsParsingTest::TestController +          post ':action', :to => ::JsonParamsParsingTest::TestController          end          yield        end @@ -118,7 +118,7 @@ class RootLessJSONParamsParsingTest < ActionDispatch::IntegrationTest      def with_test_routing(controller)        with_routing do |set|          set.draw do -          match ':action', :to => controller +          post ':action', :to => controller          end          yield        end diff --git a/actionpack/test/dispatch/request/multipart_params_parsing_test.rb b/actionpack/test/dispatch/request/multipart_params_parsing_test.rb index d144f013f5..63c5ea26a6 100644 --- a/actionpack/test/dispatch/request/multipart_params_parsing_test.rb +++ b/actionpack/test/dispatch/request/multipart_params_parsing_test.rb @@ -144,7 +144,7 @@ class MultipartParamsParsingTest < ActionDispatch::IntegrationTest      def with_test_routing        with_routing do |set|          set.draw do -          match ':action', :to => 'multipart_params_parsing_test/test' +          post ':action', :to => 'multipart_params_parsing_test/test'          end          yield        end diff --git a/actionpack/test/dispatch/request/query_string_parsing_test.rb b/actionpack/test/dispatch/request/query_string_parsing_test.rb index f6a1475d04..d14f188e30 100644 --- a/actionpack/test/dispatch/request/query_string_parsing_test.rb +++ b/actionpack/test/dispatch/request/query_string_parsing_test.rb @@ -109,7 +109,7 @@ class QueryStringParsingTest < ActionDispatch::IntegrationTest      def assert_parses(expected, actual)        with_routing do |set|          set.draw do -          match ':action', :to => ::QueryStringParsingTest::TestController +          get ':action', :to => ::QueryStringParsingTest::TestController          end          get "/parse", actual diff --git a/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb b/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb index 05569561d2..568e220b15 100644 --- a/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb +++ b/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb @@ -130,7 +130,7 @@ class UrlEncodedParamsParsingTest < ActionDispatch::IntegrationTest      def with_test_routing        with_routing do |set|          set.draw do -          match ':action', :to => ::UrlEncodedParamsParsingTest::TestController +          post ':action', :to => ::UrlEncodedParamsParsingTest::TestController          end          yield        end diff --git a/actionpack/test/dispatch/request/xml_params_parsing_test.rb b/actionpack/test/dispatch/request/xml_params_parsing_test.rb index afd400c2a9..84823e2896 100644 --- a/actionpack/test/dispatch/request/xml_params_parsing_test.rb +++ b/actionpack/test/dispatch/request/xml_params_parsing_test.rb @@ -106,7 +106,7 @@ class XmlParamsParsingTest < ActionDispatch::IntegrationTest      def with_test_routing        with_routing do |set|          set.draw do -          match ':action', :to => ::XmlParamsParsingTest::TestController +          post ':action', :to => ::XmlParamsParsingTest::TestController          end          yield        end @@ -155,7 +155,7 @@ class RootLessXmlParamsParsingTest < ActionDispatch::IntegrationTest      def with_test_routing        with_routing do |set|          set.draw do -          match ':action', :to => ::RootLessXmlParamsParsingTest::TestController +          post ':action', :to => ::RootLessXmlParamsParsingTest::TestController          end          yield        end diff --git a/actionpack/test/dispatch/request_id_test.rb b/actionpack/test/dispatch/request_id_test.rb index 4b98cd32f2..a8050b4fab 100644 --- a/actionpack/test/dispatch/request_id_test.rb +++ b/actionpack/test/dispatch/request_id_test.rb @@ -52,7 +52,7 @@ class RequestIdResponseTest < ActionDispatch::IntegrationTest    def with_test_route_set      with_routing do |set|        set.draw do -        match '/', :to => ::RequestIdResponseTest::TestController.action(:index) +        get '/', :to => ::RequestIdResponseTest::TestController.action(:index)        end        @app = self.class.build_app(set) do |middleware| @@ -62,4 +62,4 @@ class RequestIdResponseTest < ActionDispatch::IntegrationTest        yield      end    end -end
\ No newline at end of file +end diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index cc4279d9dd..463dd6cb85 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -58,41 +58,41 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest          get  "remove", :action => :destroy, :as => :remove        end -      match 'account/logout' => redirect("/logout"), :as => :logout_redirect -      match 'account/login', :to => redirect("/login") -      match 'secure', :to => redirect("/secure/login") +      get 'account/logout' => redirect("/logout"), :as => :logout_redirect +      get 'account/login', :to => redirect("/login") +      get 'secure', :to => redirect("/secure/login") -      match 'mobile', :to => redirect(:subdomain => 'mobile') -      match 'super_new_documentation', :to => redirect(:host => 'super-docs.com') +      get 'mobile', :to => redirect(:subdomain => 'mobile') +      get 'super_new_documentation', :to => redirect(:host => 'super-docs.com') -      match 'youtube_favorites/:youtube_id/:name', :to => redirect(YoutubeFavoritesRedirector) +      get 'youtube_favorites/:youtube_id/:name', :to => redirect(YoutubeFavoritesRedirector)        constraints(lambda { |req| true }) do -        match 'account/overview' +        get 'account/overview'        end -      match '/account/nested/overview' -      match 'sign_in' => "sessions#new" +      get '/account/nested/overview' +      get 'sign_in' => "sessions#new" -      match 'account/modulo/:name', :to => redirect("/%{name}s") -      match 'account/proc/:name', :to => redirect {|params, req| "/#{params[:name].pluralize}" } -      match 'account/proc_req' => redirect {|params, req| "/#{req.method}" } +      get 'account/modulo/:name', :to => redirect("/%{name}s") +      get 'account/proc/:name', :to => redirect {|params, req| "/#{params[:name].pluralize}" } +      get 'account/proc_req' => redirect {|params, req| "/#{req.method}" } -      match 'account/google' => redirect('http://www.google.com/', :status => 302) +      get 'account/google' => redirect('http://www.google.com/', :status => 302)        match 'openid/login', :via => [:get, :post], :to => "openid#login"        controller(:global) do          get   'global/hide_notice' -        match 'global/export',      :to => :export, :as => :export_request -        match '/export/:id/:file',  :to => :export, :as => :export_download, :constraints => { :file => /.*/ } -        match 'global/:action' +        get 'global/export',      :to => :export, :as => :export_request +        get '/export/:id/:file',  :to => :export, :as => :export_download, :constraints => { :file => /.*/ } +        get 'global/:action'        end -      match "/local/:action", :controller => "local" +      get "/local/:action", :controller => "local" -      match "/projects/status(.:format)" -      match "/404", :to => lambda { |env| [404, {"Content-Type" => "text/plain"}, ["NOT FOUND"]] } +      get "/projects/status(.:format)" +      get "/404", :to => lambda { |env| [404, {"Content-Type" => "text/plain"}, ["NOT FOUND"]] }        constraints(:ip => /192\.168\.1\.\d\d\d/) do          get 'admin' => "queenbee#index" @@ -277,25 +277,25 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest          end        end -      match 'sprockets.js' => ::TestRoutingMapper::SprocketsApp +      get 'sprockets.js' => ::TestRoutingMapper::SprocketsApp -      match 'people/:id/update', :to => 'people#update', :as => :update_person -      match '/projects/:project_id/people/:id/update', :to => 'people#update', :as => :update_project_person +      get 'people/:id/update', :to => 'people#update', :as => :update_person +      get '/projects/:project_id/people/:id/update', :to => 'people#update', :as => :update_project_person        # misc -      match 'articles/:year/:month/:day/:title', :to => "articles#show", :as => :article +      get 'articles/:year/:month/:day/:title', :to => "articles#show", :as => :article        # default params -      match 'inline_pages/(:id)', :to => 'pages#show', :id => 'home' -      match 'default_pages/(:id)', :to => 'pages#show', :defaults => { :id => 'home' } +      get 'inline_pages/(:id)', :to => 'pages#show', :id => 'home' +      get 'default_pages/(:id)', :to => 'pages#show', :defaults => { :id => 'home' }        defaults :id => 'home' do -        match 'scoped_pages/(:id)', :to => 'pages#show' +        get 'scoped_pages/(:id)', :to => 'pages#show'        end        namespace :account do -        match 'shorthand' -        match 'description', :to => :description, :as => "description" -        match ':action/callback', :action => /twitter|github/, :to => "callbacks", :as => :callback +        get 'shorthand' +        get 'description', :to => :description, :as => "description" +        get ':action/callback', :action => /twitter|github/, :to => "callbacks", :as => :callback          resource :subscription, :credit, :credit_card          root :to => "account#index" @@ -318,7 +318,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest        controller :articles do          scope '/articles', :as => 'article' do            scope :path => '/:title', :title => /[a-z]+/, :as => :with_title do -            match '/:id', :to => :with_id, :as => "" +            get '/:id', :to => :with_id, :as => ""            end          end        end @@ -327,7 +327,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest          resources :rooms        end -      match '/info' => 'projects#info', :as => 'info' +      get '/info' => 'projects#info', :as => 'info'        namespace :admin do          scope '(:locale)', :locale => /en|pl/ do @@ -361,7 +361,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest        scope :path => 'api' do          resource :me -        match '/' => 'mes#index' +        get '/' => 'mes#index'        end        get "(/:username)/followers" => "followers#index" @@ -374,7 +374,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest          end        end -      match "whatever/:controller(/:action(/:id))", :id => /\d+/ +      get "whatever/:controller(/:action(/:id))", :id => /\d+/        resource :profile do          get :settings @@ -407,7 +407,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest        namespace :private do          root :to => redirect('/private/index') -        match "index", :to => 'private#index' +        get "index", :to => 'private#index'        end        scope :only => [:index, :show] do @@ -489,7 +489,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest          get "/forced_collision", :as => :forced_collision, :to => "forced_collision#show"        end -      match '/purchases/:token/:filename', +      get '/purchases/:token/:filename',          :to => 'purchases#fetch',          :token => /[[:alnum:]]{10}/,          :filename => /(.+)/, @@ -500,18 +500,18 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest        end        scope '/countries/:country', :constraints => lambda { |params, req| params[:country].in?(["all", "France"]) } do -        match '/',       :to => 'countries#index' -        match '/cities', :to => 'countries#cities' +        get '/',       :to => 'countries#index' +        get '/cities', :to => 'countries#cities'        end -      match '/countries/:country/(*other)', :to => redirect{ |params, req| params[:other] ? "/countries/all/#{params[:other]}" : '/countries/all' } +      get '/countries/:country/(*other)', :to => redirect{ |params, req| params[:other] ? "/countries/all/#{params[:other]}" : '/countries/all' } -      match '/:locale/*file.:format', :to => 'files#show', :file => /path\/to\/existing\/file/ +      get '/:locale/*file.:format', :to => 'files#show', :file => /path\/to\/existing\/file/        scope '/italians' do -        match '/writers', :to => 'italians#writers', :constraints => ::TestRoutingMapper::IpRestrictor -        match '/sculptors', :to => 'italians#sculptors' -        match '/painters/:painter', :to => 'italians#painters', :constraints => {:painter => /michelangelo/} +        get '/writers', :to => 'italians#writers', :constraints => ::TestRoutingMapper::IpRestrictor +        get '/sculptors', :to => 'italians#sculptors' +        get '/painters/:painter', :to => 'italians#painters', :constraints => {:painter => /michelangelo/}        end      end    end @@ -627,7 +627,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest        self.class.stub_controllers do |routes|          routes.draw do            namespace :admin do -            match '/:controller(/:action(/:id(.:format)))' +            get '/:controller(/:action(/:id(.:format)))'            end          end        end @@ -2231,12 +2231,12 @@ class TestAppendingRoutes < ActionDispatch::IntegrationTest      s = self      @app = ActionDispatch::Routing::RouteSet.new      @app.append do -      match '/hello'   => s.simple_app('fail') -      match '/goodbye' => s.simple_app('goodbye') +      get '/hello'   => s.simple_app('fail') +      get '/goodbye' => s.simple_app('goodbye')      end      @app.draw do -      match '/hello' => s.simple_app('hello') +      get '/hello' => s.simple_app('hello')      end    end @@ -2344,12 +2344,12 @@ end  class TestUriPathEscaping < ActionDispatch::IntegrationTest    Routes = ActionDispatch::Routing::RouteSet.new.tap do |app|      app.draw do -      match '/:segment' => lambda { |env| +      get '/:segment' => lambda { |env|          path_params = env['action_dispatch.request.path_parameters']          [200, { 'Content-Type' => 'text/plain' }, [path_params[:segment]]]        }, :as => :segment -      match '/*splat' => lambda { |env| +      get '/*splat' => lambda { |env|          path_params = env['action_dispatch.request.path_parameters']          [200, { 'Content-Type' => 'text/plain' }, [path_params[:splat]]]        }, :as => :splat @@ -2381,7 +2381,7 @@ end  class TestUnicodePaths < ActionDispatch::IntegrationTest    Routes = ActionDispatch::Routing::RouteSet.new.tap do |app|      app.draw do -      match "/#{Rack::Utils.escape("ほげ")}" => lambda { |env| +      get "/#{Rack::Utils.escape("ほげ")}" => lambda { |env|          [200, { 'Content-Type' => 'text/plain' }, []]        }, :as => :unicode_path      end @@ -2411,10 +2411,10 @@ class TestMultipleNestedController < ActionDispatch::IntegrationTest      app.draw do        namespace :foo do          namespace :bar do -          match "baz" => "baz#index" +          get "baz" => "baz#index"          end        end -      match "pooh" => "pooh#index" +      get "pooh" => "pooh#index"      end    end @@ -2433,8 +2433,8 @@ class TestTildeAndMinusPaths < ActionDispatch::IntegrationTest      app.draw do        ok = lambda { |env| [200, { 'Content-Type' => 'text/plain' }, []] } -      match "/~user" => ok -      match "/young-and-fine" => ok +      get "/~user" => ok +      get "/young-and-fine" => ok      end    end diff --git a/actionpack/test/dispatch/session/cache_store_test.rb b/actionpack/test/dispatch/session/cache_store_test.rb index 12405bf45d..a74e165826 100644 --- a/actionpack/test/dispatch/session/cache_store_test.rb +++ b/actionpack/test/dispatch/session/cache_store_test.rb @@ -164,7 +164,7 @@ class CacheStoreTest < ActionDispatch::IntegrationTest      def with_test_route_set        with_routing do |set|          set.draw do -          match ':action', :to => ::CacheStoreTest::TestController +          get ':action', :to => ::CacheStoreTest::TestController          end          @app = self.class.build_app(set) do |middleware| diff --git a/actionpack/test/dispatch/session/cookie_store_test.rb b/actionpack/test/dispatch/session/cookie_store_test.rb index 19969394cd..631974d6c4 100644 --- a/actionpack/test/dispatch/session/cookie_store_test.rb +++ b/actionpack/test/dispatch/session/cookie_store_test.rb @@ -317,7 +317,7 @@ class CookieStoreTest < ActionDispatch::IntegrationTest      def with_test_route_set(options = {})        with_routing do |set|          set.draw do -          match ':action', :to => ::CookieStoreTest::TestController +          get ':action', :to => ::CookieStoreTest::TestController          end          options = { :key => SessionKey }.merge!(options) diff --git a/actionpack/test/dispatch/session/mem_cache_store_test.rb b/actionpack/test/dispatch/session/mem_cache_store_test.rb index 5277c92b55..03234612ab 100644 --- a/actionpack/test/dispatch/session/mem_cache_store_test.rb +++ b/actionpack/test/dispatch/session/mem_cache_store_test.rb @@ -173,7 +173,7 @@ class MemCacheStoreTest < ActionDispatch::IntegrationTest      def with_test_route_set        with_routing do |set|          set.draw do -          match ':action', :to => ::MemCacheStoreTest::TestController +          get ':action', :to => ::MemCacheStoreTest::TestController          end          @app = self.class.build_app(set) do |middleware| diff --git a/actionpack/test/dispatch/url_generation_test.rb b/actionpack/test/dispatch/url_generation_test.rb index 2b54bc62b0..985ff2e81a 100644 --- a/actionpack/test/dispatch/url_generation_test.rb +++ b/actionpack/test/dispatch/url_generation_test.rb @@ -3,7 +3,7 @@ require 'abstract_unit'  module TestUrlGeneration    class WithMountPoint < ActionDispatch::IntegrationTest      Routes = ActionDispatch::Routing::RouteSet.new -    Routes.draw { match "/foo", :to => "my_route_generating#index", :as => :foo } +    Routes.draw { get "/foo", :to => "my_route_generating#index", :as => :foo }      class ::MyRouteGeneratingController < ActionController::Base        include Routes.url_helpers diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb index c9b8a5bb70..4835bc578f 100644 --- a/actionpack/test/template/date_helper_test.rb +++ b/actionpack/test/template/date_helper_test.rb @@ -125,13 +125,33 @@ class DateHelperTest < ActionView::TestCase      start_date = Date.new 1982, 12, 3      end_date = Date.new 2010, 11, 30      assert_equal("almost 28 years", distance_of_time_in_words(start_date, end_date)) +    assert_equal("almost 28 years", distance_of_time_in_words(end_date, start_date))    end    def test_distance_in_words_with_integers -    assert_equal "less than a minute", distance_of_time_in_words(59) +    assert_equal "1 minute", distance_of_time_in_words(59)      assert_equal "about 1 hour", distance_of_time_in_words(60*60) -    assert_equal "less than a minute", distance_of_time_in_words(0, 59) +    assert_equal "1 minute", distance_of_time_in_words(0, 59)      assert_equal "about 1 hour", distance_of_time_in_words(60*60, 0) +    assert_equal "about 3 years", distance_of_time_in_words(10**8) +    assert_equal "about 3 years", distance_of_time_in_words(0, 10**8) +  end + +  def test_distance_in_words_with_times +    assert_equal "1 minute", distance_of_time_in_words(30.seconds) +    assert_equal "1 minute", distance_of_time_in_words(59.seconds) +    assert_equal "2 minutes", distance_of_time_in_words(119.seconds) +    assert_equal "2 minutes", distance_of_time_in_words(1.minute + 59.seconds) +    assert_equal "3 minutes", distance_of_time_in_words(2.minute + 30.seconds) +    assert_equal "44 minutes", distance_of_time_in_words(44.minutes + 29.seconds) +    assert_equal "about 1 hour", distance_of_time_in_words(44.minutes + 30.seconds) +    assert_equal "about 1 hour", distance_of_time_in_words(60.minutes) + +    # include seconds +    assert_equal "half a minute", distance_of_time_in_words(39.seconds, 0, true) +    assert_equal "less than a minute", distance_of_time_in_words(40.seconds, 0, true) +    assert_equal "less than a minute", distance_of_time_in_words(59.seconds, 0, true) +    assert_equal "1 minute", distance_of_time_in_words(60.seconds, 0, true)    end    def test_time_ago_in_words diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 3fa3898ec8..a714264909 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -97,7 +97,7 @@ class FormHelperTest < ActionView::TestCase        end      end -    match "/foo", :to => "controller#action" +    get "/foo", :to => "controller#action"      root :to => "main#index"    end diff --git a/actionpack/test/template/test_test.rb b/actionpack/test/template/test_test.rb index adcbf1447f..108a674d95 100644 --- a/actionpack/test/template/test_test.rb +++ b/actionpack/test/template/test_test.rb @@ -48,7 +48,7 @@ class PeopleHelperTest < ActionView::TestCase      def with_test_route_set        with_routing do |set|          set.draw do -          match 'people', :to => 'people#index', :as => :people +          get 'people', :to => 'people#index', :as => :people          end          yield        end diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 88f506b217..eaa8bdbd26 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -15,9 +15,9 @@ class UrlHelperTest < ActiveSupport::TestCase    routes = ActionDispatch::Routing::RouteSet.new    routes.draw do -    match "/" => "foo#bar" -    match "/other" => "foo#other" -    match "/article/:id" => "foo#article", :as => :article +    get "/" => "foo#bar" +    get "/other" => "foo#other" +    get "/article/:id" => "foo#article", :as => :article    end    include routes.url_helpers @@ -471,25 +471,25 @@ end  class UrlHelperControllerTest < ActionController::TestCase    class UrlHelperController < ActionController::Base      test_routes do -      match 'url_helper_controller_test/url_helper/show/:id', +      get 'url_helper_controller_test/url_helper/show/:id',          :to => 'url_helper_controller_test/url_helper#show',          :as => :show -      match 'url_helper_controller_test/url_helper/profile/:name', +      get 'url_helper_controller_test/url_helper/profile/:name',          :to => 'url_helper_controller_test/url_helper#show',          :as => :profile -      match 'url_helper_controller_test/url_helper/show_named_route', +      get 'url_helper_controller_test/url_helper/show_named_route',          :to => 'url_helper_controller_test/url_helper#show_named_route',          :as => :show_named_route -      match "/:controller(/:action(/:id))" +      get "/:controller(/:action(/:id))" -      match 'url_helper_controller_test/url_helper/normalize_recall_params', +      get 'url_helper_controller_test/url_helper/normalize_recall_params',          :to => UrlHelperController.action(:normalize_recall),          :as => :normalize_recall_params -      match '/url_helper_controller_test/url_helper/override_url_helper/default', +      get '/url_helper_controller_test/url_helper/override_url_helper/default',          :to => 'url_helper_controller_test/url_helper#override_url_helper',          :as => :override_url_helper      end  | 
