Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic cache support for multiple file uploads
- Loading branch information
Showing
5 changed files
with
65 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require "refile/test_app" | ||
|
||
feature "Multiple file uploads", :js do | ||
scenario "Upload multiple files" do | ||
visit "/multiple/posts/new" | ||
fill_in "Title", with: "A cool post" | ||
attach_file "Documents", [path("hello.txt"), path("world.txt")] | ||
click_button "Create" | ||
|
||
expect(download_link("Document: hello.txt")).to eq("hello") | ||
expect(download_link("Document: world.txt")).to eq("world") | ||
end | ||
|
||
scenario "Fail to upload a file that is too large" do | ||
visit "/multiple/posts/new" | ||
fill_in "Title", with: "A cool post" | ||
attach_file "Documents", [path("hello.txt"), path("large.txt")] | ||
click_button "Create" | ||
|
||
expect(page).to have_content("Documents is invalid") | ||
end | ||
|
||
scenario "Fail to upload a file that has the wrong format then submit" do | ||
visit "/multiple/posts/new" | ||
fill_in "Title", with: "A cool post" | ||
attach_file "Documents", [path("hello.txt"), path("image.jpg")] | ||
click_button "Create" | ||
|
||
expect(page).to have_content("Documents is invalid") | ||
click_button "Create" | ||
expect(page).to have_selector("h1", text: "A cool post") | ||
expect(page).not_to have_link("Document") | ||
end | ||
|
||
scenario "Upload files via form redisplay", js: true do | ||
visit "/multiple/posts/new" | ||
attach_file "Documents", [path("hello.txt"), path("world.txt")] | ||
click_button "Create" | ||
fill_in "Title", with: "A cool post" | ||
click_button "Create" | ||
|
||
expect(download_link("Document: hello.txt")).to eq("hello") | ||
expect(download_link("Document: world.txt")).to eq("world") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
class Document < ActiveRecord::Base | ||
belongs_to :post | ||
attachment :file | ||
attachment :file, cache: :limited_cache | ||
end |