Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

site= accepts URIs

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4886 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit c1af2db14be7a5978ee57e6b46f02e1ec8bc14f9 1 parent 12ff554
@jeremy jeremy authored
View
2  activeresource/CHANGELOG
@@ -1,3 +1,5 @@
*SVN*
+* site= accepts URIs. [Jeremy Kemper]
+
* Initial checkin: object-oriented client for restful HTTP resources which follow the Rails convention. [DHH]
View
6 activeresource/lib/active_resource/base.rb
@@ -4,9 +4,9 @@ module ActiveResource
class Base
class << self
def site=(site)
- @@site = URI.parse(site)
+ @@site = site.is_a?(URI) ? site : URI.parse(site)
end
-
+
def site
@@site
end
@@ -96,4 +96,4 @@ def method_missing(method_symbol, *arguments)
end
end
end
-end
+end
View
14 activeresource/test/base_test.rb
@@ -17,6 +17,18 @@ def setup
)
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
assert_equal "people", Person.collection_name
end
@@ -57,4 +69,4 @@ def test_destroy
assert Person.find(1).destroy
assert_raises(ActiveResource::ClientError) { Person.find(2).destroy }
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.