Permalink
Browse files

Merge pull request #2321 from omjokine/master

JSONP should use mimetype application/javascript
  • Loading branch information...
josevalim committed Apr 29, 2012
2 parents e6ab0d5 + b4e1903 commit d4dd1af341dcc1908b594567991845324df0ee56
@@ -91,7 +91,10 @@ module All
add :json do |json, options|
json = json.to_json(options) unless json.kind_of?(String)
- json = "#{options[:callback]}(#{json})" unless options[:callback].blank?
+ unless options[:callback].blank?
+ json = "#{options[:callback]}(#{json})"
+ self.content_type ||= Mime::JS
+ end
self.content_type ||= Mime::JSON
json
end
@@ -102,7 +102,7 @@ def test_render_json_with_status
def test_render_json_with_callback
get :render_json_hello_world_with_callback
assert_equal 'alert({"hello":"world"})', @response.body
- assert_equal 'application/json', @response.content_type
+ assert_equal 'application/javascript', @response.content_type
end
def test_render_json_with_custom_content_type

3 comments on commit d4dd1af

@carlosantoniodasilva

This comment has been minimized.

Show comment Hide comment
@carlosantoniodasilva

carlosantoniodasilva Apr 29, 2012

Owner

Perhaps this is a valid entry for changelog?

Perhaps this is a valid entry for changelog?

@rafaelfranca

This comment has been minimized.

Show comment Hide comment
@rafaelfranca

rafaelfranca Apr 29, 2012

Owner

👍

Owner

rafaelfranca replied Apr 29, 2012

👍

@carlosantoniodasilva

This comment has been minimized.

Show comment Hide comment
@carlosantoniodasilva

carlosantoniodasilva Apr 29, 2012

Owner

PR: #6047

Please sign in to comment.