提交 b295ea13 编写于 作者: J José Valim

Merge pull request #2330 from thedarkone/resources-router-fix

Inline resources router fix
......@@ -872,9 +872,9 @@ class Resource #:nodoc:
def initialize(entities, options = {})
@name = entities.to_s
@path = (options.delete(:path) || @name).to_s
@controller = (options.delete(:controller) || @name).to_s
@as = options.delete(:as)
@path = (options[:path] || @name).to_s
@controller = (options[:controller] || @name).to_s
@as = options[:as]
@options = options
end
......@@ -936,12 +936,11 @@ class SingletonResource < Resource #:nodoc:
DEFAULT_ACTIONS = [:show, :create, :update, :destroy, :new, :edit]
def initialize(entities, options)
super
@as = nil
@name = entities.to_s
@path = (options.delete(:path) || @name).to_s
@controller = (options.delete(:controller) || plural).to_s
@as = options.delete(:as)
@options = options
@controller = (options[:controller] || plural).to_s
@as = options[:as]
end
def plural
......
......@@ -91,6 +91,15 @@ def test_multiple_default_restful_routes
end
end
def test_multiple_resources_with_options
expected_options = {:controller => 'threads', :action => 'index'}
with_restful_routing :messages, :comments, expected_options.slice(:controller) do
assert_recognizes(expected_options, :path => 'comments')
assert_recognizes(expected_options, :path => 'messages')
end
end
def test_with_custom_conditions
with_restful_routing :messages, :conditions => { :subdomain => 'app' } do
assert @routes.recognize_path("/messages", :method => :get, :subdomain => 'app')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册