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