Permalink
Browse files

Allow setting ActiveResource::Base#format before #site. [rick]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8503 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
technoweenie committed Dec 28, 2007
1 parent c54b915 commit e8730713d2744ab0149ad03997ad05f336c31941
Showing with 10 additions and 1 deletion.
  1. +2 −0 activeresource/CHANGELOG
  2. +1 −1 activeresource/lib/active_resource/base.rb
  3. +7 −0 activeresource/test/format_test.rb
View
@@ -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]
@@ -192,7 +192,7 @@ def format=(mime_type_reference_or_format)
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
@@ -64,6 +64,13 @@ def test_formats_on_custom_element_method
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

0 comments on commit e873071

Please sign in to comment.