require 'spec_helper'

describe Band do

  before do
    #@geocode2 = FactoryGirl.create(:geocoder)
    @band = FactoryGirl.create(:band)
  end

  describe "with profile location data" do

    it "should have lat/lng values" do
      pending 'distance search changes'
      geo = MaxMindGeo.find_by_city(@band.city)
      @band.lat.should == geo.lat
      @band.lng.should == geo.lng
    end

    it "should have updated lat/lng values" do
      pending 'distance search changes'
      @band.update_attributes({ :city => @geocode2.city, 
                                :state => @geocode2.region,
                                :country => @geocode2.country,
                              })
      geo = MaxMindGeo.find_by_city(@band.city)
      @band.lat.should == geo.lat
      @band.lng.should == geo.lng
    end
  end

  describe "without location data" do
    pending 'distance search changes'
    it "should have nil lat/lng values without address" do
      @band.skip_location_validation = true
      @band.update_attributes({ :city => nil,
                                :state => nil,
                                :country => nil,
                              })
      @band.lat.should == nil
      @band.lng.should == nil
    end
  end

end
