Commit 19762f8
Changed files (3)
app
controllers
models
spec
controllers
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