Commit 19762f8

mo khan <mo@mokhan.ca>
2016-04-30 04:17:17
load the closest gyms.
1 parent 7e23e0c
Changed files (3)
app
spec
app/controllers/gyms_controller.rb
@@ -1,5 +1,5 @@
 class GymsController < ApplicationController
   def index
-    @gyms = Gym.latest
+    @gyms = Gym.closest_to(current_user)
   end
 end
app/models/gym.rb
@@ -1,4 +1,5 @@
 class Gym
-  def self.latest
+  # name, address, latitude, longitude
+  def self.closest_to(user)
   end
 end
spec/controllers/gyms_controller_spec.rb
@@ -12,7 +12,9 @@ describe GymsController do
     let(:world_health) { double }
 
     it 'returns a list of gyms' do
-      allow(Gym).to receive(:latest).and_return([sait, world_health])
+      allow(Gym).to receive(:closest_to).
+        with(user).
+        and_return([sait, world_health])
 
       get :index