aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/test/base_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-12-29 01:18:09 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-12-29 01:18:09 +0000
commit4e57ac35443759778bd6c1fcfd29e8bd85e9d15d (patch)
treed1414e69479fcc0807d4e57f3c86b624f1981ebe /activeresource/test/base_test.rb
parentf9f84d9f6dea72cae4fc8e31448df408caccbd59 (diff)
downloadrails-4e57ac35443759778bd6c1fcfd29e8bd85e9d15d.tar.gz
rails-4e57ac35443759778bd6c1fcfd29e8bd85e9d15d.tar.bz2
rails-4e57ac35443759778bd6c1fcfd29e8bd85e9d15d.zip
Query string support. Closes #6855.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5804 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activeresource/test/base_test.rb')
-rw-r--r--activeresource/test/base_test.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/activeresource/test/base_test.rb b/activeresource/test/base_test.rb
index b036e1d346..bfc8a9fb68 100644
--- a/activeresource/test/base_test.rb
+++ b/activeresource/test/base_test.rb
@@ -82,14 +82,34 @@ class BaseTest < Test::Unit::TestCase
assert_equal '/people.xml', Person.collection_path
end
+ def test_collection_path_with_parameters
+ assert_equal '/people.xml?gender=male', Person.collection_path(:gender => 'male')
+ assert_equal '/people.xml?gender=false', Person.collection_path(:gender => false)
+ assert_equal '/people.xml?gender=', Person.collection_path(:gender => nil)
+
+ assert_equal '/people.xml?gender=male', Person.collection_path('gender' => 'male')
+ assert_equal '/people.xml?student=true&gender=male', Person.collection_path(:gender => 'male', :student => true)
+
+ assert_equal '/people.xml?name[]=bob&name[]=your+uncle%2Bme&name[]=&name[]=false', Person.collection_path(:name => ['bob', 'your uncle+me', nil, false])
+ end
+
def test_custom_element_path
assert_equal '/people/1/addresses/1.xml', StreetAddress.element_path(1, :person_id => 1)
end
+ def test_custom_element_path_with_parameters
+ assert_equal '/people/1/addresses/1.xml?type=work', StreetAddress.element_path(1, :person_id => 1, :type => 'work')
+ assert_equal '/people/1/addresses/1.xml?type[]=work&type[]=play+time', StreetAddress.element_path(1, :person_id => 1, :type => ['work', 'play time'])
+ end
+
def test_custom_collection_path
assert_equal '/people/1/addresses.xml', StreetAddress.collection_path(:person_id => 1)
end
+ def test_custom_collection_path_with_parameters
+ assert_equal '/people/1/addresses.xml?type=work', StreetAddress.collection_path(:person_id => 1, :type => 'work')
+ end
+
def test_custom_element_name
assert_equal 'address', StreetAddress.element_name
end
@@ -108,11 +128,13 @@ class BaseTest < Test::Unit::TestCase
def test_prefix
assert_equal "/", Person.prefix
+ assert_equal Set.new, Person.instance_variable_get('@prefix_parameters')
end
def test_custom_prefix
assert_equal '/people//', StreetAddress.prefix
assert_equal '/people/1/', StreetAddress.prefix(:person_id => 1)
+ assert_equal [:person_id].to_set, StreetAddress.instance_variable_get('@prefix_parameters')
end
def test_find_by_id