Sha256: 9bdb1307ee1a462d7799f8861c4af0a134594004edea300b862759b1903815b2

Contents?: true

Size: 978 Bytes

Versions: 16

Compression:

Stored size: 978 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

describe LHC do
  include ActionDispatch::TestProcess

  context 'multipart' do
    let(:file) { fixture_file_upload(Tempfile.new, 'image/jpeg') }
    let(:body) { { size: 2231 }.to_json }
    let(:location) { 'http://local.ch/uploads/image.jpg' }

    it 'formats requests to be multipart/form-data' do
      stub_request(:post, 'http://local.ch/') do |request|
        raise 'Content-Type header wrong' unless request.headers['Content-Type'] == 'multipart/form-data'
        raise 'Body wrongly formatted' unless request.body.match(/file=%23%3CActionDispatch%3A%3AHttp%3A%3AUploadedFile%3A.*%3E&type=Image/)
      end.to_return(status: 200, body: body, headers: { 'Location' => location })
      response = LHC.multipart.post(
        'http://local.ch',
        body: { file: file, type: 'Image' }
      )
      expect(response.body).to eq body
      expect(response.headers['Location']).to eq location
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
lhc-13.1.0 spec/formats/multipart_spec.rb
lhc-13.0.0 spec/formats/multipart_spec.rb
lhc-12.3.0 spec/formats/multipart_spec.rb
lhc-12.2.1 spec/formats/multipart_spec.rb
lhc-12.2.0 spec/formats/multipart_spec.rb
lhc-12.1.3 spec/formats/multipart_spec.rb
lhc-12.1.2 spec/formats/multipart_spec.rb
lhc-12.1.1 spec/formats/multipart_spec.rb
lhc-12.1.0 spec/formats/multipart_spec.rb
lhc-12.0.3 spec/formats/multipart_spec.rb
lhc-12.0.2 spec/formats/multipart_spec.rb
lhc-12.0.1 spec/formats/multipart_spec.rb
lhc-12.0.0 spec/formats/multipart_spec.rb
lhc-11.2.0 spec/formats/multipart_spec.rb
lhc-11.1.1 spec/formats/multipart_spec.rb
lhc-11.1.0 spec/formats/multipart_spec.rb