Sha256: e472c1ad9385f7b4544230d55d5833552f854468e155ea188e23b320a560fa6a

Contents?: true

Size: 1.08 KB

Versions: 48

Compression:

Stored size: 1.08 KB

Contents

require File.join(File.dirname(__FILE__),'api_helper')

describe "RhosyncApiUploadFile" do
  it_should_behave_like "ApiHelper"
  
  it "should upload and unzip file" do
    file = File.join(File.dirname(__FILE__),'..','testdata','compressed')    
    compress(file)
    zipfile = File.join(file,"compressed.zip")
    post "/api/upload_file", :api_token => @api_token,
      :upload_file => Rack::Test::UploadedFile.new(zipfile, "application/octet-stream")
    FileUtils.rm zipfile
    expected = File.join(Rhosync.app_directory,'compress-data.txt')
    File.exists?(expected).should == true
    File.read(expected).should == 'some compressed text'
    FileUtils.rm expected
  end
  
  it "should fail to upload a non-zip file" do
    file = File.join(File.dirname(__FILE__),'..','testdata','compressed','compress-data.txt')    
    post "/api/upload_file", :api_token => @api_token,
      :upload_file => Rack::Test::UploadedFile.new(file, "application/octet-stream")
    last_response.status.should == 500
    File.exists?(File.join(Rhosync.app_directory,'compress-data.txt')).should == false
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
rhosync-2.0.0.beta10 spec/api/upload_file_spec.rb
rhosync-2.0.0.beta9 spec/api/upload_file_spec.rb
rhosync-2.0.0.beta8 spec/api/upload_file_spec.rb
rhosync-2.0.0.beta7 spec/api/upload_file_spec.rb
rhosync-2.0.0.beta6 spec/api/upload_file_spec.rb
rhosync-2.0.0.beta4 spec/api/upload_file_spec.rb
rhosync-2.0.0.beta3 spec/api/upload_file_spec.rb
rhosync-2.0.0.beta2 spec/api/upload_file_spec.rb