aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-12-28 17:12:35 +0000
committerRick Olson <technoweenie@gmail.com>2007-12-28 17:12:35 +0000
commite8730713d2744ab0149ad03997ad05f336c31941 (patch)
treec7be2a44a573aee844b8691b4ec8af5f11e46b29
parentc54b915825b034b431b4b0cdb28f8ca00fca808d (diff)
downloadrails-e8730713d2744ab0149ad03997ad05f336c31941.tar.gz
rails-e8730713d2744ab0149ad03997ad05f336c31941.tar.bz2
rails-e8730713d2744ab0149ad03997ad05f336c31941.zip
Allow setting ActiveResource::Base#format before #site. [rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8503 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--activeresource/CHANGELOG2
-rw-r--r--activeresource/lib/active_resource/base.rb2
-rw-r--r--activeresource/test/format_test.rb7
3 files changed, 10 insertions, 1 deletions
diff --git a/activeresource/CHANGELOG b/activeresource/CHANGELOG
index ebabbf59c0..ee246042fd 100644
--- a/activeresource/CHANGELOG
+++ b/activeresource/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Allow setting ActiveResource::Base#format before #site. [rick]
+
* Support agnostic formats when calling custom methods. Closes #10635 [joerichsen]
* Document custom methods. #10589 [Cheah Chu Yeow]
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index 3383f542f9..76f4ca03db 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -192,7 +192,7 @@ module ActiveResource
ActiveResource::Formats[mime_type_reference_or_format] : mime_type_reference_or_format
write_inheritable_attribute("format", format)
- connection.format = format
+ connection.format = format if site
end
# Returns the current format, default is ActiveResource::Formats::XmlFormat
diff --git a/activeresource/test/format_test.rb b/activeresource/test/format_test.rb
index c2d3a08682..51e1bbe32a 100644
--- a/activeresource/test/format_test.rb
+++ b/activeresource/test/format_test.rb
@@ -64,6 +64,13 @@ class FormatTest < Test::Unit::TestCase
end
end
+ def test_setting_format_before_site
+ resource = Class.new(ActiveResource::Base)
+ resource.format = :json
+ resource.site = 'http://37s.sunrise.i:3000'
+ assert_equal ActiveResource::Formats[:json], resource.connection.format
+ end
+
private
def using_format(klass, mime_type_reference)
previous_format = klass.format