aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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