Sha256: 42e8ee60fcd98eccac3d5e022a4661878265990fd92e7f59396411698be093b7

Contents?: true

Size: 1.48 KB

Versions: 6

Compression:

Stored size: 1.48 KB

Contents

require "refile/test_app"

feature "Direct HTTP post file uploads", :js do
  scenario "Successfully upload a file" do
    visit "/direct/posts/new"
    fill_in "Title", with: "A cool post"
    attach_file "Document", path("hello.txt")

    expect(page).to have_content("Upload started")
    expect(page).to have_content("Upload success")
    expect(page).to have_content("Upload complete")

    click_button "Create"

    expect(page).to have_selector("h1", text: "A cool post")
    expect(page).to have_selector(".content-type", text: "text/plain")
    expect(page).to have_selector(".size", text: "6")
    expect(page).to have_selector(".filename", text: "hello.txt")
    expect(download_link("Document")).to eq("hello")
  end

  scenario "Fail to upload a file that is too large" do
    visit "/direct/posts/new"
    fill_in "Title", with: "A cool post"
    attach_file "Document", path("large.txt")

    expect(page).to have_content("Upload started")
    expect(page).to have_content("Upload failure error")
  end

  scenario "Fail to upload a file that has wrong format" do
    visit "/direct/posts/new"
    fill_in "Title", with: "A cool post"
    attach_file "Image", path("large.txt")

    expect(page).to have_content("Upload started")
    expect(page).to have_content("Upload success")
    expect(page).to have_content("Upload complete")

    click_button "Create"

    expect(page).to have_selector(".field_with_errors")
    expect(page).to have_content("Image has an invalid file format")
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
refile-0.5.5 spec/refile/features/direct_upload_spec.rb
refile-0.5.4 spec/refile/features/direct_upload_spec.rb
refile-0.5.3 spec/refile/features/direct_upload_spec.rb
refile-0.5.2 spec/refile/features/direct_upload_spec.rb
refile-0.5.1 spec/refile/features/direct_upload_spec.rb
refile-0.5.0 spec/refile/features/direct_upload_spec.rb