Sha256: 7d111856eb198ca62c3a62c6f802def54aa931a37e1212888dc6852877beff3f

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

class TestController < ActionController::Base
  prepend_view_path(File.dirname(__FILE__))

  layout nil
  def valid; render :file => TestController.test_file(:valid) end
  def untidy; render :file => TestController.test_file(:untidy) end
  def invalid; render :file => TestController.test_file(:invalid) end

  def url_no_route
    render :text => %Q{<a href="/norouteforthisurl">No route</a>}
  end

  def url_no_route_relative
    render :text => %Q{<a href="norouteforthisurl">No route</a>}    
  end

  def url_no_action
    render :text => %Q{<a href="/test/thisactiondoesnotexist">no action</a>}
  end

  def action_no_template
    render :text => %Q{<a href="/test/valid">valid</a>}
  end

  def redirect_no_action
    redirect_to :action => 'thisactiondoesnotexist'
  end

  def redirect_valid_action
    redirect_to :action => 'valid'
  end

  def redirect_external
    redirect_to "http://google.com/foobar"
  end

  def redirect_valid_with_host
    redirect_to "http://test.host/test/valid"
  end

  def image_file_exists
    render :text => %Q{<img src="/image.jpg?23049829034"/>}
  end

  def image_file_does_not_exist
    render :text => %Q{<img src="/image2.jpg?23049829034"/>}
  end

  def self.test_file(action)
    File.join(File.dirname(__FILE__), "#{action}.html")
  end

  def self.test_file_string(action)
    IO.read(test_file(action))
  end
  
  # Re-raise errors caught by the controller.
  def rescue_action(e)
    raise e
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jakewendt-html_test-0.2.3 test/test_helper.rb