class RenderOtherTest

Public Instance Methods

setup() click to toggle source
# File test/render_other_test.rb, line 155
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 = Logger.new(nil)

  @request.host = "www.nextangle.com"
end
test_enum_rjs_test() click to toggle source
# File test/render_other_test.rb, line 164
def test_enum_rjs_test
  SecureRandom.stubs(:base64).returns("asdf")
  get :enum_rjs_test
  body = %Q{
    $$(".product").each(function(value, index) {
    new Effect.Highlight(element,{});
    new Effect.Highlight(value,{});
    Sortable.create(value, {onUpdate:function(){new Ajax.Request('/render_other_test/test/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(value) + '&authenticity_token=' + encodeURIComponent('asdf')})}});
    new Draggable(value, {});
    });
  }.gsub(/^      /, '').strip
  assert_equal body, @response.body
end
test_explicitly_rendering_an_html_template_with_implicit_html_template_renders_should_be_possible_from_an_rjs_template() click to toggle source
# File test/render_other_test.rb, line 178
def test_explicitly_rendering_an_html_template_with_implicit_html_template_renders_should_be_possible_from_an_rjs_template
  [:js, "js"].each do |format|
    assert_nothing_raised do
      get :render_explicit_html_template, :format => format
      assert_equal %Q(document.write("Hello world\\n");), @response.body
    end
  end
end
test_render_custom_code_rjs() click to toggle source
# File test/render_other_test.rb, line 187
def test_render_custom_code_rjs
  get :render_custom_code_rjs
  assert_response 404
  assert_equal %Q(Element.replace("foo", "partial html");), @response.body
end
test_render_in_an_rjs_template_should_pick_html_templates_when_available() click to toggle source
# File test/render_other_test.rb, line 193
def test_render_in_an_rjs_template_should_pick_html_templates_when_available
  [:js, "js"].each do |format|
    assert_nothing_raised do
      get :render_implicit_html_template, :format => format
      assert_equal %Q(document.write("Hello world\\n");), @response.body
    end
  end
end
test_render_rjs_template_explicitly() click to toggle source
# File test/render_other_test.rb, line 202
def test_render_rjs_template_explicitly
  get :render_js_with_explicit_template
  assert_equal %QElement.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
end
test_render_rjs_with_default() click to toggle source
# File test/render_other_test.rb, line 212
def test_render_rjs_with_default
  get :delete_with_js
  assert_equal %QElement.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
end
test_rendering_rjs_action_explicitly() click to toggle source
# File test/render_other_test.rb, line 207
def test_rendering_rjs_action_explicitly
  get :render_js_with_explicit_action_template
  assert_equal %QElement.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
end
test_should_render_html_formatted_partial_with_rjs() click to toggle source
# File test/render_other_test.rb, line 239
def test_should_render_html_formatted_partial_with_rjs
  xhr :get, :partial_as_rjs
  assert_equal %Q(Element.replace("foo", "partial html");), @response.body
end
test_should_render_html_formatted_partial_with_rjs_and_js_format() click to toggle source
# File test/render_other_test.rb, line 244
def test_should_render_html_formatted_partial_with_rjs_and_js_format
  xhr :get, :respond_to_partial_as_rjs
  assert_equal %Q(Element.replace("foo", "partial html");), @response.body
end
test_should_render_with_alternate_default_render() click to toggle source
# File test/render_other_test.rb, line 249
def test_should_render_with_alternate_default_render
  xhr :get, :render_alternate_default
  assert_equal %Q(Element.replace("foo", "partial html");), @response.body
end
test_update_page() click to toggle source
# File test/render_other_test.rb, line 217
def test_update_page
  get :update_page
  assert_template nil
  assert_equal 'text/javascript; charset=utf-8', @response.headers['Content-Type']
  assert_equal 2, @response.body.split($/).length
end
test_update_page_with_instance_variables() click to toggle source
# File test/render_other_test.rb, line 224
def test_update_page_with_instance_variables
  get :update_page_with_instance_variables
  assert_template nil
  assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"]
  assert_match(/balance/, @response.body)
  assert_match(/\$37/, @response.body)
end
test_update_page_with_view_method() click to toggle source
# File test/render_other_test.rb, line 232
def test_update_page_with_view_method
  get :update_page_with_view_method
  assert_template nil
  assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"]
  assert_match(/2 people/, @response.body)
end
test_using_custom_render_option() click to toggle source
# File test/render_other_test.rb, line 254
def test_using_custom_render_option
  get :render_simon_says
  assert_equal "Simon says: foo", @response.body
end