From 53d689cd9150127c1c1a75bfad523bdaffcf5bd6 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Sun, 4 Aug 2013 21:51:46 -0400 Subject: [PATCH] Add show functionality --- app/controllers/workouts_controller.rb | 4 ++++ app/views/workouts/show.html.erb | 1 + spec/features/workouts_spec.rb | 12 ++++++++++++ 3 files changed, 17 insertions(+) create mode 100644 app/views/workouts/show.html.erb diff --git a/app/controllers/workouts_controller.rb b/app/controllers/workouts_controller.rb index b02362a..0c2d8a2 100644 --- a/app/controllers/workouts_controller.rb +++ b/app/controllers/workouts_controller.rb @@ -2,4 +2,8 @@ class WorkoutsController < ApplicationController def index @workouts = Workout.all end + + def show + @workout = Workout.find(params[:id]) + end end diff --git a/app/views/workouts/show.html.erb b/app/views/workouts/show.html.erb new file mode 100644 index 0000000..07eed19 --- /dev/null +++ b/app/views/workouts/show.html.erb @@ -0,0 +1 @@ +<%= @workout.date %> diff --git a/spec/features/workouts_spec.rb b/spec/features/workouts_spec.rb index 9d7ac30..04321c9 100644 --- a/spec/features/workouts_spec.rb +++ b/spec/features/workouts_spec.rb @@ -16,4 +16,16 @@ describe "Workouts" do page.should have_content @workout.date end end + + describe "GET /workouts/(:id)" do + it "should return 200" do + visit "#{workouts_path}/#{@workout.id}" + page.status_code.should be 200 + end + + it "should return the correct workout" do + visit "#{workouts_path}/#{@workout.id}" + page.should have_content @workout.date + end + end end