diff --git a/.gitignore b/.gitignore index 0fe8c6587f..162da8c185 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,6 @@ lib/build/grunt-aws.json lib/build/app_config.js rubygems lib/build/_SpecRunner.html +vendor/bundle/* +.vagrant +Vagrantfile \ No newline at end of file diff --git a/Gemfile b/Gemfile index 480e66d1ba..77987c3cad 100644 --- a/Gemfile +++ b/Gemfile @@ -18,8 +18,8 @@ gem 'nokogiri', '1.6.0' gem 'statsd-client', '0.0.7', require: 'statsd' gem 'aws-sdk', '1.8.5' -# It's used in the dataimport and arcgis. Just two calls. -# It's a replacement for the ruby uri that it's supposed to +# It's used in the dataimport and arcgis. Just two calls. +# It's a replacement for the ruby uri that it's supposed to # perform better parsing of a URI gem 'addressable', '2.3.2', require: 'addressable/uri' @@ -81,7 +81,7 @@ group :development, :test do gem 'mocha', '0.10.5' gem 'ci_reporter', '1.8.4' - gem 'debugger', '1.6.5' + gem 'debugger', '1.6.8' gem 'rspec-rails', '2.10.1' gem 'capybara', '1.1.2' diff --git a/Gemfile.lock b/Gemfile.lock index e74c366291..47a8fdd614 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -78,12 +78,12 @@ GEM daemons (1.1.9) dbf (2.0.6) fastercsv (~> 1.5.4) - debugger (1.6.5) + debugger (1.6.8) columnize (>= 0.3.1) debugger-linecache (~> 1.2.0) - debugger-ruby_core_source (~> 1.3.1) + debugger-ruby_core_source (~> 1.3.5) debugger-linecache (1.2.0) - debugger-ruby_core_source (1.3.5) + debugger-ruby_core_source (1.3.7) delorean (2.1.0) chronic descendants_tracker (0.0.4) @@ -312,7 +312,7 @@ DEPENDENCIES ci_reporter (= 1.8.4) compass (= 0.12.3) dbf (= 2.0.6) - debugger (= 1.6.5) + debugger (= 1.6.8) delorean dropbox-sdk (= 1.6.3) ejs (~> 1.1.1) diff --git a/app/models/asset.rb b/app/models/asset.rb index 4e125b04b8..0f4667f9c6 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb @@ -81,7 +81,8 @@ class Asset < Sequel::Model local_path = Rails.root.join 'public', 'uploads', target_asset_path FileUtils.mkdir_p local_path FileUtils.cp @file.path, local_path.join(filename) - File.join('/', 'uploads', target_asset_path, filename) + p = File.join('/', 'uploads', target_asset_path, filename) + "http://#{Cartodb.config[:account_host]}#{p}" end def use_s3? @@ -91,7 +92,8 @@ class Asset < Sequel::Model def remove unless use_s3? - FileUtils.rm("#{Rails.root}/public#{public_url}") rescue '' + local_url = public_url.gsub(/http:\/\/#{Cartodb.config[:account_host]}/,'') + FileUtils.rm("#{Rails.root}/public#{local_url}") rescue '' return end basename = File.basename(public_url) diff --git a/spec/models/asset_spec.rb b/spec/models/asset_spec.rb index 2f72df0672..2ccf9633a9 100644 --- a/spec/models/asset_spec.rb +++ b/spec/models/asset_spec.rb @@ -52,13 +52,15 @@ describe Asset do it 'should save the file when passing a full path as an argument' do asset = Asset.create user_id: @user.id, asset_file: (Rails.root + 'db/fake_data/simple.json').to_s - File.exists?("#{Rails.root}/public#{asset.public_url}").should be_true + local_url = asset.public_url.gsub(/http:\/\/#{Cartodb.config[:account_host]}/,'') + File.exists?("#{Rails.root}/public#{local_url}").should be_true asset.public_url.should =~ /.*test\/#{@user.username}\/assets\/\d+simple\.json.*/ end it 'should save the file when passing an UploadedFile as an argument' do asset = Asset.create user_id: @user.id, asset_file: Rack::Test::UploadedFile.new(Rails.root.join('db/fake_data/column_number_to_boolean.csv'), 'text/csv') - File.exists?("#{Rails.root}/public#{asset.public_url}").should be_true + local_url = asset.public_url.gsub(/http:\/\/#{Cartodb.config[:account_host]}/,'') + File.exists?("#{Rails.root}/public#{local_url}").should be_true asset.public_url.should =~ /.*test\/#{@user.username}\/assets\/\d+column_number_to_boolean.csv.*/ end @@ -74,7 +76,8 @@ describe Asset do file = Rails.root.join('spec/support/data/cartofante_blue.png') serve_file file do |url| asset = Asset.create(user_id: @user.id, url: url) - File.exists?("#{Rails.root}/public#{asset.public_url}").should be_true + local_url = asset.public_url.gsub(/http:\/\/#{Cartodb.config[:account_host]}/,'') + File.exists?("#{Rails.root}/public#{local_url}").should be_true asset.public_url.should =~ /\/test\/test\/assets\/\d+cartofante_blue\.png/ end end @@ -86,7 +89,8 @@ describe Asset do it 'removes the file from storage if needed' do Asset.any_instance.stubs("use_s3?").returns(false) asset = Asset.create user_id: @user.id, asset_file: (Rails.root + 'db/fake_data/simple.json').to_s - path = "#{Rails.root}/public#{asset.public_url}" + local_url = asset.public_url.gsub(/http:\/\/#{Cartodb.config[:account_host]}/,'') + path = "#{Rails.root}/public#{local_url}" File.exists?(path).should be_true asset.destroy File.exists?(path).should be_false