class RenderJsonTest

Public Instance Methods

setup() click to toggle source
Calls superclass method
# File actionpack/test/controller/render_json_test.rb, line 71
def setup
  # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get
  # a more accurate simulation of what happens in "real life".
  super
  @controller.logger = ActiveSupport::Logger.new(nil)

  @request.host = "www.nextangle.com"
end
test_render_json() click to toggle source
# File actionpack/test/controller/render_json_test.rb, line 91
def test_render_json
  get :render_json_hello_world
  assert_equal '{"hello":"world"}', @response.body
  assert_equal "application/json", @response.content_type
end
test_render_json_calls_to_json_from_object() click to toggle source
# File actionpack/test/controller/render_json_test.rb, line 133
def test_render_json_calls_to_json_from_object
  get :render_json_without_options
  assert_equal '{"a":"b"}', @response.body
end
test_render_json_forwards_extra_options() click to toggle source
# File actionpack/test/controller/render_json_test.rb, line 127
def test_render_json_forwards_extra_options
  get :render_json_with_extra_options
  assert_equal '{"a":"b"}', @response.body
  assert_equal "application/json", @response.content_type
end
test_render_json_nil() click to toggle source
# File actionpack/test/controller/render_json_test.rb, line 80
def test_render_json_nil
  get :render_json_nil
  assert_equal "null", @response.body
  assert_equal "application/json", @response.content_type
end
test_render_json_render_to_string() click to toggle source
# File actionpack/test/controller/render_json_test.rb, line 86
def test_render_json_render_to_string
  get :render_json_render_to_string
  assert_equal "[]", @response.body
end
test_render_json_with_callback() click to toggle source
# File actionpack/test/controller/render_json_test.rb, line 103
def test_render_json_with_callback
  get :render_json_hello_world_with_callback, xhr: true
  assert_equal '/**/alert({"hello":"world"})', @response.body
  assert_equal "text/javascript", @response.content_type
end
test_render_json_with_custom_content_type() click to toggle source
# File actionpack/test/controller/render_json_test.rb, line 109
def test_render_json_with_custom_content_type
  get :render_json_with_custom_content_type, xhr: true
  assert_equal '{"hello":"world"}', @response.body
  assert_equal "text/javascript", @response.content_type
end
test_render_json_with_render_to_string() click to toggle source
# File actionpack/test/controller/render_json_test.rb, line 121
def test_render_json_with_render_to_string
  get :render_json_with_render_to_string
  assert_equal '{"hello":"partial html"}', @response.body
  assert_equal "application/json", @response.content_type
end
test_render_json_with_status() click to toggle source
# File actionpack/test/controller/render_json_test.rb, line 97
def test_render_json_with_status
  get :render_json_hello_world_with_status
  assert_equal '{"hello":"world"}', @response.body
  assert_equal 401, @response.status
end
test_render_symbol_json() click to toggle source
# File actionpack/test/controller/render_json_test.rb, line 115
def test_render_symbol_json
  get :render_symbol_json
  assert_equal '{"hello":"world"}', @response.body
  assert_equal "application/json", @response.content_type
end