Benjamin Fleischer 2015-12-14 21:36:52 -06:00
parent b05d9dbd36
commit d03b8179f5
3 changed files with 9 additions and 6 deletions

View File

@ -242,9 +242,13 @@ class RenderJsonTest < ActionController::TestCase
def test_render_json_with_callback
get :render_json_hello_world_with_callback
assert_equal '/**/alert({"hello":"world"})', @response.body
# For JSONP, Rails 3 uses application/json, but Rails 4 uses text/javascript
assert_match %r(application/json|text/javascript), @response.content_type.to_s
if Rails::VERSION::MAJOR == 3
assert_equal 'alert({"hello":"world"})', @response.body
assert_match %r(application/json), @response.content_type.to_s
else
assert_equal '/**/alert({"hello":"world"})', @response.body
assert_match %r(text/javascript), @response.content_type.to_s
end
end
def test_render_json_with_custom_content_type

View File

@ -1363,7 +1363,6 @@ class SerializerTest < ActiveModel::TestCase
def test_inheritance_does_not_used_cached_attributes
parent = Class.new(ActiveModel::Serializer) do
attributes :title
alias :read_attribute_for_serialization :send
end
child = Class.new(parent) do
@ -1371,8 +1370,8 @@ class SerializerTest < ActiveModel::TestCase
end
data_class = Class.new do
include ActiveModel::Serializers::JSON
attr_accessor :title, :body
alias :read_attribute_for_serialization :send
end
item = data_class.new

View File

@ -199,7 +199,7 @@ class SomeSerializer < ActiveModel::Serializer
end
class SomeObject < Struct.new(:some)
alias :read_attribute_for_serialization :send
include ActiveModel::Serializers::JSON
end
# Set up some classes for polymorphic testing