Integration tests for Merb file uploads
This commit is contained in:
parent
09509025c3
commit
26edfbc7cb
|
@ -4,6 +4,15 @@ class Testing < Application
|
|||
render
|
||||
end
|
||||
|
||||
def upload
|
||||
case request.method
|
||||
when :get then render
|
||||
when :post then
|
||||
uploaded_file = params[:uploaded_file]
|
||||
render [uploaded_file[:filename], uploaded_file[:tempfile].class.name].inspect
|
||||
end
|
||||
end
|
||||
|
||||
def submit_form
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<h1>Webrat Form</h1>
|
||||
|
||||
<form action="/upload" method="post">
|
||||
<label>
|
||||
File
|
||||
<input type="file" name="uploaded_file" />
|
||||
</label>
|
||||
<input type="submit" value="Upload">
|
||||
</form>
|
|
@ -28,6 +28,7 @@
|
|||
Merb.logger.info("Compiling routes...")
|
||||
Merb::Router.prepare do
|
||||
match("/").to(:controller => "testing", :action => "show_form")
|
||||
match("/upload").to(:controller => "testing", :action => "upload")
|
||||
match("/internal_redirect").to(:controller => "testing", :action => "internal_redirect")
|
||||
match("/external_redirect").to(:controller => "testing", :action => "external_redirect")
|
||||
end
|
||||
|
|
|
@ -29,4 +29,11 @@ describe "Webrat" do
|
|||
response = visit "/external_redirect"
|
||||
response.status.should == 302
|
||||
end
|
||||
|
||||
it "should upload files" do
|
||||
visit "/upload"
|
||||
attach_file "File", __FILE__
|
||||
response = click_button "Upload"
|
||||
response.should contain(%(["webrat_spec.rb", "Tempfile"]))
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue