Skip to content

Instantly share code, notes, and snippets.

@elight
Created April 12, 2010 22:56
Show Gist options
  • Save elight/364103 to your computer and use it in GitHub Desktop.
Save elight/364103 to your computer and use it in GitHub Desktop.
require 'test/test_helper'
class FormController < ActionController::Base
def blech
render :text => <<-HTML
<html>
<head></head>
<body>
<form id="the_form" action="/barblech" method="POST">
<input type="hidden" id="the_answer" value="42"></input>
</form>
</body>
</html>
HTML
end
def barblech
render :text => <<-HTML
<html>
<head></head>
<body>
<p>OHAI</p>
<p>#{params[:the_answer]}</p>
</body>
</html>
HTML
end
end
class FormTest < ActionController::IntegrationTest
test "form submit works" do
get '/blech'
js("document.getElementById('the_form').submit()")
html = js("document.body.innerHTML")
assert html =~ /42/
end
end
require 'test/unit'
require 'action_controller'
require 'action_controller/integration'
begin require 'ruby-debug'; rescue LoadError; end
begin require 'redgreen'; rescue LoadError; end
begin require 'phocus'; rescue LoadError; end
require 'rails/init'
class Rails
def self.root
Pathname(__FILE__).dirname.parent.expand_path
end
end
ActionController::Routing::Routes.draw do |map|
map.connect '/foo', :controller => 'functionals', :action => 'foo'
map.connect '/bar', :controller => 'functionals', :action => 'bar'
map.connect '/baz', :controller => 'integration', :action => 'baz'
map.connect '/boo', :controller => 'integration', :action => 'boo'
map.connect '/moo', :controller => 'integration', :action => 'moo'
map.connect '/xhr', :controller => 'integration', :action => 'xhr'
map.connect '/blech', :controller => 'form', :action => 'blech'
map.connect '/barblech', :controller => 'form', :action => 'barblech'
end
ActionController::Base.session = {
:key => "_myapp_session",
:secret => "some secret phrase" * 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment