After creating a table, if it has a longitude and latitude attributes, geolocalize them

1.0
Fernando Blat 14 years ago
parent ff1dbf72e2
commit 40927e3c42

@ -125,6 +125,7 @@ class Table < Sequel::Model(:user_tables)
def after_create
super
User.filter(:id => user_id).update(:tables_count => :tables_count + 1)
set_lan_lon_columns!(:latitude, :longitude) if schema.flatten.include?(:latitude) && schema.flatten.include?(:longitude)
end
def after_destroy

@ -517,4 +517,16 @@ describe Table do
query_result[:rows][1][:name].should == "Hawai"
end
it "should set latitude and longitude if the default schema is loaded" do
table = create_table
table.lat_column.should == :latitude
table.lon_column.should == :longitude
table = new_table
table.import_from_file = Rack::Test::UploadedFile.new("#{Rails.root}/db/fake_data/import_csv_4.csv", "text/csv")
table.save
table.lat_column.should be_nil
table.lon_column.should be_nil
end
end

Loading…
Cancel
Save