Work around mime-types broken sorting on MIME::Types.type_for('xxx.csv')
This commit is contained in:
parent
2c910e7f9a
commit
e0e187cbea
|
@ -42,7 +42,8 @@ class Capybara::RackTest::Form < Capybara::RackTest::Node
|
||||||
if (value = field['value']).to_s.empty?
|
if (value = field['value']).to_s.empty?
|
||||||
NilUploadedFile.new
|
NilUploadedFile.new
|
||||||
else
|
else
|
||||||
content_type = MIME::Types.type_for(value).first.to_s
|
types = MIME::Types.type_for(value)
|
||||||
|
content_type = types.sort_by.with_index { |type, idx| [type.obsolete? ? 1 : 0, idx] }.first.to_s
|
||||||
Rack::Test::UploadedFile.new(value, content_type)
|
Rack::Test::UploadedFile.new(value, content_type)
|
||||||
end
|
end
|
||||||
merge_param!(params, field['name'].to_s, file)
|
merge_param!(params, field['name'].to_s, file)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
test, mime-type, file
|
|
|
@ -79,6 +79,14 @@ RSpec.describe Capybara::Session do
|
||||||
expect(@session.html).to include('Successfully ignored empty file field.')
|
expect(@session.html).to include('Successfully ignored empty file field.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should not submit an obsolete mime type" do
|
||||||
|
@test_jpg_file_path = File.expand_path('fixtures/capybara.csv', File.dirname(__FILE__))
|
||||||
|
@session.visit("/form")
|
||||||
|
@session.attach_file "form_document", @test_jpg_file_path
|
||||||
|
@session.click_button('Upload Single')
|
||||||
|
expect(@session).to have_content("Content-type: text/csv")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#click" do
|
describe "#click" do
|
||||||
|
|
Loading…
Reference in New Issue