Created
July 31, 2014 06:46
-
-
Save mmb/3cee36e6fd16bf33df0b to your computer and use it in GitHub Desktop.
Rack::Test::UploadedFile doesn't respond to encoding
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
def create | |
@src_image = SrcImage.new(src_image_params) | |
@src_image.user = current_user | |
read_image_data @src_image | |
respond_to do |format| | |
if @src_image.save | |
create_success(format) | |
else | |
create_fail(format) | |
end | |
end | |
end | |
--- | |
let(:image) { fixture_file_upload('/files/ti_duck.jpg', 'image/jpeg') } | |
it 'saves the new source image to the database' do | |
expect do | |
post :create, src_image: { image: image } | |
end.to change { SrcImage.count }.by(1) | |
end | |
--- | |
1) SrcImagesController POST 'create' with valid attributes saves the new source image to the database | |
Failure/Error: post :create, src_image: { image: image } | |
NoMethodError: | |
undefined method `encoding' for #<Tempfile:0x007fc2b5b97e48> | |
# ./app/controllers/src_images_controller.rb:18:in `create' | |
# ./spec/controllers/src_images_controller_spec.rb:135:in `block (5 levels) in <top (required)>' | |
# ./spec/controllers/src_images_controller_spec.rb:134:in `block (4 levels) in <top (required)>' | |
# -e:1:in `load' | |
# -e:1:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment