提交 c1af2db1 编写于 作者: J Jeremy Kemper

site= accepts URIs

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4886 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 12ff554c
*SVN* *SVN*
* site= accepts URIs. [Jeremy Kemper]
* Initial checkin: object-oriented client for restful HTTP resources which follow the Rails convention. [DHH] * Initial checkin: object-oriented client for restful HTTP resources which follow the Rails convention. [DHH]
...@@ -4,9 +4,9 @@ module ActiveResource ...@@ -4,9 +4,9 @@ module ActiveResource
class Base class Base
class << self class << self
def site=(site) def site=(site)
@@site = URI.parse(site) @@site = site.is_a?(URI) ? site : URI.parse(site)
end end
def site def site
@@site @@site
end end
...@@ -96,4 +96,4 @@ def method_missing(method_symbol, *arguments) ...@@ -96,4 +96,4 @@ def method_missing(method_symbol, *arguments)
end end
end end
end end
end end
\ No newline at end of file
...@@ -17,6 +17,18 @@ def setup ...@@ -17,6 +17,18 @@ def setup
) )
end end
def test_site_accessor_accepts_uri_or_string_argument
site = URI.parse('http://localhost')
assert_nothing_raised { Person.site = 'http://localhost' }
assert_equal site, Person.site
assert_nothing_raised { Person.site = site }
assert_equal site, Person.site
end
def test_collection_name def test_collection_name
assert_equal "people", Person.collection_name assert_equal "people", Person.collection_name
end end
...@@ -57,4 +69,4 @@ def test_destroy ...@@ -57,4 +69,4 @@ def test_destroy
assert Person.find(1).destroy assert Person.find(1).destroy
assert_raises(ActiveResource::ClientError) { Person.find(2).destroy } assert_raises(ActiveResource::ClientError) { Person.find(2).destroy }
end end
end end
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册