Commit eac6dd3

mo khan <mo@mokhan.ca>
2016-04-30 03:56:50
start to build the gyms controller.
1 parent df10c5e
Changed files (5)
app/controllers/gyms_controller.rb
@@ -0,0 +1,6 @@
+class GymsController < PublicController
+  def index
+    @gyms = Gym.latest
+    render nothing: true
+  end
+end
app/models/gym.rb
@@ -0,0 +1,4 @@
+class Gym
+  def self.latest
+  end
+end
config/routes.rb
@@ -10,6 +10,7 @@ Rails.application.routes.draw do
   end
   resources :programs, only: [:show]
   resources :profiles, only: [:new, :create, :show, :edit, :update], constraints: { id: /[^\/]+/ }
+  resources :gyms, only: [:index]
   get "/u/:id" => "profiles#show", constraints: { id: /[^\/]+/ }
   get "/dashboard" => "training_sessions#index", as: :dashboard
   get "/terms" => "static_pages#terms"
spec/controllers/gyms_controller_spec.rb
@@ -0,0 +1,17 @@
+require 'rails_helper'
+
+describe GymsController do
+  describe "#index" do
+    let(:sait) { double }
+    let(:world_health) { double }
+
+    it 'returns a list of gyms' do
+      allow(Gym).to receive(:latest).and_return([sait, world_health])
+
+      get :index
+
+      expect(assigns(:gyms)).to match_array([sait, world_health])
+      expect(response).to be_ok
+    end
+  end
+end
spec/routing/gyms_routing_spec.rb
@@ -0,0 +1,7 @@
+require 'rails_helper'
+
+describe "/gyms" do
+  it 'routes to gyms#index' do
+    expect(get: "/gyms").to route_to(controller: 'gyms', action: 'index')
+  end
+end