1

我正在使用 capybara 2.1.0 并有一个表格multiple: true(允许我上传多个文件)。该网站在浏览器中运行良好,但 capybara 的问题在于该字段与内容一起提交,""而不是nil当我将该字段留空时。然后,我从 Paperclip 收到关于""文件名无效的错误(有道理,没有名为 的文件"")。

这是表格:

= simple_form_for([@site, @zone], mulitpart: true) do |f|
  = f.error_notification

  .form-inputs
    = f.input :site_id
    = f.input :default_state

    = file_field_tag "zone_shapefiles_asset", multiple: true, name: "zone[shapefiles_attributes][][asset]"
    = label_tag "X"
    = text_field_tag 'x_coords[]', nil, id: "x_coords_1"

    = label_tag "Y"
    = text_field_tag 'y_coords[]', nil, id: "y_coords_1"

    = label_tag "X"
    = text_field_tag 'x_coords[]', nil, id: "x_coords_2"

    = label_tag "Y"
    = text_field_tag 'y_coords[]', nil, id: "y_coords_2"

    = label_tag "X"
    = text_field_tag 'x_coords[]', nil, id: "x_coords_3"

    = label_tag "Y"
    = text_field_tag 'y_coords[]', nil, id: "y_coords_3"

    = label_tag "X"
    = text_field_tag 'x_coords[]', nil, id: "x_coords_4"

    = label_tag "Y"
    = text_field_tag 'y_coords[]', nil, id: "y_coords_4"

    = link_to "Add Point", "#", id: "add_point", data: { fields: label_tags.gsub("\"", "'") }

  .form-actions
    = f.button :submit

和错误:

Paperclip::AdapterRegistry::NoHandlerError: No handler found for ""
./spec/features/zones_spec.rb:50:in `block (6 levels) in <top (required)>'

从这个规范:

it "can create region for zone" do
    fill_in "x_coords_1", with: 0
    fill_in "y_coords_1", with: 0
    fill_in "x_coords_2", with: 10
    fill_in "y_coords_2", with: 0
    fill_in "x_coords_3", with: 10
    fill_in "y_coords_3", with: 10
    fill_in "x_coords_4", with: 0
    fill_in "y_coords_4", with: 10
    click_button "Create Zone"
    page.should have_content "Zone was successfully created
end

运行轨道 3.2.13

水豚 2.1.0

默认 rack_test 驱动程序

4

1 回答 1

0

我的表格中的错字。

我有mulitpart: true而不是multipart: true. 注意 multipart 的拼写错误。

于 2013-07-02T20:46:08.317 回答