Fixes uploads specs

2.0
Fernando Espinosa 12 years ago
parent 0c85e76fdc
commit a37229848c

@ -1,3 +1,4 @@
web: bundle exec rails server -p $PORT
sql: node ../CartoDB-SQL-API/app.js development
tiler: node ../Windshaft-cartodb/app.js development
redis: redis-server

@ -3,34 +3,35 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe "Imports API uploads" do
before(:each) do
User.all.each(&:destroy)
@user = create_user(:username => 'test', :email => "client@example.com", :password => "clientex")
@user.set_map_key
end
it 'allow to upload using the request body' do
file = File.open(Rails.root.join('spec/support/whs_features.csv'), 'r+')
file = File.open(Rails.root.join('db/fake_data/clubbing.csv'), 'r+')
post v1_imports_uploads_url(:host => 'test.localhost.lan'), {:body => file.read, :qqfile => File.basename(file.path), :api_key => @user.get_map_key}
post v1_uploads_url(:host => 'test.localhost.lan'), {:body => file.read, :qqfile => File.basename(file.path), :api_key => @user.get_map_key}
response.code.should be == '200'
response_json = JSON.parse(response.body)
response_json.should_not be_nil
response_json['file_uri'].should match(/uploads\/.*\/whs_features.csv/)
response_json['file_uri'].should match(/uploads\/.*\/clubbing.csv/)
response_json['success'].should be_true
end
it 'allow to upload using a file param' do
file = Rack::Test::UploadedFile.new(Rails.root.join('spec/support/whs_features.csv'), 'text/plain')
file = Rack::Test::UploadedFile.new(Rails.root.join('db/fake_data/clubbing.csv'), 'text/plain')
post v1_imports_uploads_url(:host => 'test.localhost.lan'), {:file => file, :api_key => @user.get_map_key}
post v1_uploads_url(:host => 'test.localhost.lan'), {:file => file, :api_key => @user.get_map_key}
response.code.should be == '200'
response_json = JSON.parse(response.body)
response_json.should_not be_nil
response_json['file_uri'].should match(/uploads\/.*\/whs_features.csv/)
response_json['file_uri'].should match(/uploads\/.*\/clubbing.csv/)
response_json['success'].should be_true
end

Loading…
Cancel
Save