aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-08-31 07:55:31 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-08-31 07:55:31 +0000
commitc1af2db14be7a5978ee57e6b46f02e1ec8bc14f9 (patch)
treea4bea79c139419583b9d6c77e55a31a5987dfb4a
parent12ff554cd476bd2c653d9fd331bbcabb71363f3a (diff)
downloadrails-c1af2db14be7a5978ee57e6b46f02e1ec8bc14f9.tar.gz
rails-c1af2db14be7a5978ee57e6b46f02e1ec8bc14f9.tar.bz2
rails-c1af2db14be7a5978ee57e6b46f02e1ec8bc14f9.zip
site= accepts URIs
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4886 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--activeresource/CHANGELOG2
-rw-r--r--activeresource/lib/active_resource/base.rb6
-rw-r--r--activeresource/test/base_test.rb14
3 files changed, 18 insertions, 4 deletions
diff --git a/activeresource/CHANGELOG b/activeresource/CHANGELOG
index cf7099b007..8ac17c24a1 100644
--- a/activeresource/CHANGELOG
+++ b/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]
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index 2d4025e5dd..11064454d7 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/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 @@ module ActiveResource
end
end
end
-end \ No newline at end of file
+end
diff --git a/activeresource/test/base_test.rb b/activeresource/test/base_test.rb
index 3c87ca532c..e4839613ee 100644
--- a/activeresource/test/base_test.rb
+++ b/activeresource/test/base_test.rb
@@ -17,6 +17,18 @@ class BaseTest < Test::Unit::TestCase
)
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 @@ class BaseTest < Test::Unit::TestCase
assert Person.find(1).destroy
assert_raises(ActiveResource::ClientError) { Person.find(2).destroy }
end
-end \ No newline at end of file
+end