提交 7ffe7604 编写于 作者: S Santiago Pastorino 提交者: José Valim

ActiveResource shouldn't consider modules in the path

[#4529 state:committed]
Signed-off-by: NJosé Valim <jose.valim@gmail.com>
上级 d18a2742
......@@ -551,22 +551,8 @@ def headers
@headers ||= {}
end
def element_name
@element_name ||= model_name.element
end
def element_name=(element_name)
@element_name = element_name
@collection_name ||= model_name.collection.sub(/[^\/]*$/, @element_name.pluralize)
end
def collection_name
@collection_name ||= model_name.collection
end
def collection_name=(collection_name)
@collection_name = collection_name
end
attr_accessor_with_default(:element_name) { model_name.element } #:nodoc:
attr_accessor_with_default(:collection_name) { ActiveSupport::Inflector.pluralize(element_name) } #:nodoc:
attr_accessor_with_default(:primary_key, 'id') #:nodoc:
......
......@@ -2,6 +2,7 @@
require "fixtures/person"
require "fixtures/customer"
require "fixtures/street_address"
require "fixtures/sound"
require "fixtures/beast"
require "fixtures/proxy"
require 'active_support/json'
......@@ -563,6 +564,10 @@ def test_custom_element_path
assert_equal '/people/Greg/addresses/1.xml', StreetAddress.element_path(1, 'person_id' => 'Greg')
end
def test_module_element_path
assert_equal '/sounds/1.xml', Asset::Sound.element_path(1)
end
def test_custom_element_path_with_redefined_to_param
Person.module_eval do
alias_method :original_to_param_element_path, :to_param
......
module Asset
class Sound < ActiveResource::Base
self.site = "http://37s.sunrise.i:3000"
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册