Skip to content

Strip C:\fakepath from upload path #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/carrierwave_direct/test/capybara_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ def find_key
end

def find_upload_path
page.find("input[@name='file']").value
# Standards compliant browsers report C:\fakepath as part of
# their value. We should strip this for our test helpers as
# it is not submitted to the upload
# http://davidwalsh.name/fakepath
page.find("input[@name='file']").value.sub("C:\\fakepath\\", "")
end

def upload_directly(uploader, button_locator, options = {})
Expand Down
7 changes: 6 additions & 1 deletion spec/test/capybara_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,15 @@ def stub_common
describe "#find_upload_path" do
before do
stub_page
find_element_value("input[@name='file']", "upload path")
end

it "should try to find the upload path on the page" do
find_element_value("input[@name='file']", "upload path")
expect(subject.find_upload_path).to eq "upload path"
end

it "strips fakepath for standards compliant browsers" do
find_element_value("input[@name='file']", "C:\\fakepath\\upload path")
expect(subject.find_upload_path).to eq "upload path"
end
end
Expand Down