aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/test/base_test.rb
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-01-23 05:22:33 +0000
committerRick Olson <technoweenie@gmail.com>2007-01-23 05:22:33 +0000
commit1bdb14bdd3cad4ae8850040d6d82c3c3c624f224 (patch)
treec190143d622d9bc06c7cb350366bf12a288797a3 /activeresource/test/base_test.rb
parentf3f691eaf2ebf0452e634e68dfc3c0eac58d09f2 (diff)
downloadrails-1bdb14bdd3cad4ae8850040d6d82c3c3c624f224.tar.gz
rails-1bdb14bdd3cad4ae8850040d6d82c3c3c624f224.tar.bz2
rails-1bdb14bdd3cad4ae8850040d6d82c3c3c624f224.zip
Increase ActiveResource::Base test coverage. Closes #7173, #7174 [Rich Collins]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6020 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activeresource/test/base_test.rb')
-rw-r--r--activeresource/test/base_test.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/activeresource/test/base_test.rb b/activeresource/test/base_test.rb
index f9f2b24c72..040bd02b52 100644
--- a/activeresource/test/base_test.rb
+++ b/activeresource/test/base_test.rb
@@ -137,6 +137,27 @@ class BaseTest < Test::Unit::TestCase
assert_equal "/", Person.prefix
assert_equal Set.new, Person.send(:prefix_parameters)
end
+
+ def test_set_prefix
+ SetterTrap.rollback_sets(Person) do |person_class|
+ person_class.prefix = "the_prefix"
+ assert_equal "the_prefix", person_class.prefix
+ end
+ end
+
+ def test_set_prefix_with_inline_keys
+ SetterTrap.rollback_sets(Person) do |person_class|
+ person_class.prefix = "the_prefix:the_param"
+ assert_equal "the_prefixthe_param_value", person_class.prefix(:the_param => "the_param_value")
+ end
+ end
+
+ def test_set_prefix_with_default_value
+ SetterTrap.rollback_sets(Person) do |person_class|
+ person_class.set_prefix
+ assert_equal "/", person_class.prefix
+ end
+ end
def test_custom_prefix
assert_equal '/people//', StreetAddress.prefix
@@ -261,4 +282,9 @@ class BaseTest < Test::Unit::TestCase
assert !StreetAddress.new({:id => 1}, {:person_id => 2}).exists?
assert !StreetAddress.new({:id => 2}, {:person_id => 1}).exists?
end
+
+ def test_to_xml
+ matz = Person.find(1)
+ assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <name>Matz</name>\n <id type=\"integer\">1</id>\n</person>\n", matz.to_xml
+ end
end