我正在尝试通过水豚测试cloudinary直接上传,但水豚说它无法找到图片上传字段。你如何测试直接上传?
picture_spec.rb
require 'spec_helper'
feature "User Pictures" do
let(:user) { create(:user) }
describe "Uploading an image" do
describe "for profile photo" do
it "raises an error when clicked outside cropping image so image is not cropped" do
visit new_user_picture_path(user)
attach_file('#photo upload', "#{Rails.root}/spec/support/images/PRATIQUE_BIG.png")
click_on "Valider Photo"
expect(page).to have_content "SVP crop votre image et celle-ci doit mesurer au moins 100 x 100px"
end
end
end
end
新图片页
= form_for(@photo, :url => url, role: "form") do |f|
.form_line.form-group
.upload_button_holder
= link_to "Parcourir", "#", class: "btn btn-default upload_button form-control"
#photo-upload= f.cl_image_upload :image, class: "form-control"
%span.status
.form-group
.form_control
.preview
= f.hidden_field :crop_x
= f.hidden_field :crop_y
= f.hidden_field :crop_w
= f.hidden_field :crop_h
.form-group
= f.submit "Valider Photo", class: "btn btn-lg btn-success"
= hidden_field_tag :direct, params[:direct]
%p= link_to "Retour à Mon Profil", profile_path(current_user.user_code)
// Configure Cloudinary jQuery plugin
= cloudinary_js_config
Capybara然后回复Unable to find file field "photo-upload"
答案 0 :(得分:0)
cl_image_upload
的字段名称始终为file
。 photo-update
是周围div的id。您可以通过将html: {id: "my-id"}
传递给cl_image_upload
来为文件输入字段指定ID。 BTW。 class也属于html
哈希参数。