mirror of
https://github.com/github/rails.git
synced 2026-01-09 14:48:01 -05:00
- check prefix options in collection_path
This commit is contained in:
@@ -665,6 +665,7 @@ module ActiveResource
|
||||
# # => /posts/5/comments.xml?active=1
|
||||
#
|
||||
def collection_path(prefix_options = {}, query_options = nil)
|
||||
check_prefix_options(prefix_options)
|
||||
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
||||
"#{prefix(prefix_options)}#{collection_name}.#{format.extension}#{query_string(query_options)}"
|
||||
end
|
||||
|
||||
@@ -477,7 +477,7 @@ class BaseTest < Test::Unit::TestCase
|
||||
|
||||
def test_custom_element_path_without_required_prefix_param
|
||||
assert_raise ActiveResource::MissingPrefixParam do
|
||||
assert_equal '/people/1/addresses/1.xml', StreetAddress.element_path(1)
|
||||
StreetAddress.element_path(1)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -519,6 +519,12 @@ class BaseTest < Test::Unit::TestCase
|
||||
assert_equal '/people/1/addresses/1.xml?type=work', StreetAddress.element_path(1, {:person_id => 1}, {:type => 'work'})
|
||||
end
|
||||
|
||||
def test_custom_collection_path_without_required_prefix_param
|
||||
assert_raise ActiveResource::MissingPrefixParam do
|
||||
StreetAddress.collection_path
|
||||
end
|
||||
end
|
||||
|
||||
def test_custom_collection_path
|
||||
assert_equal '/people/1/addresses.xml', StreetAddress.collection_path(:person_id => 1)
|
||||
assert_equal '/people/1/addresses.xml', StreetAddress.collection_path('person_id' => 1)
|
||||
|
||||
Reference in New Issue
Block a user