Skip to content

Instantly share code, notes, and snippets.

@bronson
Created January 11, 2016 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bronson/7cab10381759b1dbbb74 to your computer and use it in GitHub Desktop.
Save bronson/7cab10381759b1dbbb74 to your computer and use it in GitHub Desktop.
it "it redirects to default search and geocodes if user isn't in us" do
# make it look like request is coming from europe (don't bother overriding the default lat/lon, which is in the us)
property = create :property, continent: 'Europe', country: 'GF', country_name: 'Grand Fenwick', marketing_latitude: 40, marketing_longitude: -120
property = create :property, continent: 'Europe', country: 'LF', country_name: 'Little Fenwick', marketing_latitude: 60, marketing_longitude: -40
# this IP is in Brazil. TODO: add in_americas? to static geocoding!!
expect(request).to receive(:remote_ip).and_return("189.81.139.183")
get :index
# we call the geocoding service and look up the country from the nearest property
expect(response).to redirect_to search_url(tid: 'Americas', st: 'm')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment