2017-04-24 5 views
0

의 "{***} 확장자가 있습니다."레일에 고정 클립지 문서 업로드시이 문제가 있습니다. (레일 버전 업그레이드 후)fixture_file_upload는 클립 레일 모델 레일에서 4.2.1

paperclip 4.0 이상에서 content_type의 유효성 검사가 필요하다는 점을 감안할 때 유효성 확인 후 또는 특별히 do_not_validate_attachment_file_type을 요청한 후에도 내 사양은 여전히 ​​File has an extension that does not match its contents 오류로 실패합니다.

모델 :

class SignatureFile < ActiveRecord::Base 
    ... 
    has_attached_file :file 
    VALID_CONTENT_TYPES = ["image/jpeg", "image/jpg", "image/png", "image/gif"] 

    validates_attachment :file, content_type: { content_type: VALID_CONTENT_TYPES }, 
           convert_options: { all: '-auto-orient' }, 
           processors: [:compression] 
    ... 
end 

사양 :

image = fixture_file_upload('spec/fixtures/mobile_api/sample.jpg', 'image/jpg') 
나는 여러에서이 시나리오 (나의) 클립 모델을 데

...

예는 다음과 같다

위의 image을 저장하려고하면 오류가 발생하고,210 준다 :

"File has an extension that does not match its contents"

충분 내가 이전에 업그레이드 전에 통과 된이 같은 시나리오의 무리가 있다고 할 수 있습니다.

아래는 관련 보석의 버전입니다 내가 가진 :

  • 보석 '레일', '4.2.7.1'
  • 보석 '클립', '4.2.1'
  • 보석 'paperclip- 압축 ','0.3.7 '
  • 보석'RSpec에 레일 ','3.4.2 '

내가 무슨 누락 될 수 있습니까?

답변

0

file이 누락되었을 수 있습니다. 슬프게도 그 경우에는 오류가 더 정확하지 않습니다. paperclip docs에서 읽으십시오.

+0

Windows에서는 fixture_file_upload에': binary '를 추가해야합니다. https://apidock.com/rails/ActionController/TestProcess/fixture_file_upload –