From 71b047be4877ae924240ed15dc7ee55b51996b48 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Mon, 5 Aug 2013 01:07:11 -0400 Subject: [PATCH] Begin adding edit functionality --- app/controllers/workouts_controller.rb | 4 ++++ app/views/workouts/_form.html.erb | 5 +++++ app/views/workouts/edit.html.erb | 1 + app/views/workouts/index.html.erb | 6 +++++- spec/features/workouts_spec.rb | 9 +++++++++ 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 app/views/workouts/_form.html.erb create mode 100644 app/views/workouts/edit.html.erb diff --git a/app/controllers/workouts_controller.rb b/app/controllers/workouts_controller.rb index 0c2d8a2..0ffd9c9 100644 --- a/app/controllers/workouts_controller.rb +++ b/app/controllers/workouts_controller.rb @@ -6,4 +6,8 @@ class WorkoutsController < ApplicationController def show @workout = Workout.find(params[:id]) end + + def edit + @workout = Workout.find(params[:id]) + end end diff --git a/app/views/workouts/_form.html.erb b/app/views/workouts/_form.html.erb new file mode 100644 index 0000000..9c00b8d --- /dev/null +++ b/app/views/workouts/_form.html.erb @@ -0,0 +1,5 @@ +<%= form_for @workout do |f| %> + <%= f.label :date %> + <%= f.text_field :date %> + <%= f.submit nil %> +<% end %> diff --git a/app/views/workouts/edit.html.erb b/app/views/workouts/edit.html.erb new file mode 100644 index 0000000..786950e --- /dev/null +++ b/app/views/workouts/edit.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'form' %> diff --git a/app/views/workouts/index.html.erb b/app/views/workouts/index.html.erb index 5ec41c6..a6be907 100644 --- a/app/views/workouts/index.html.erb +++ b/app/views/workouts/index.html.erb @@ -1,5 +1,9 @@ diff --git a/spec/features/workouts_spec.rb b/spec/features/workouts_spec.rb index f249aee..a3b7aba 100644 --- a/spec/features/workouts_spec.rb +++ b/spec/features/workouts_spec.rb @@ -36,4 +36,13 @@ describe "Workouts" do page.should have_content @workout.date end end + + describe "PUT /workouts/(:id)" do + it "should edit the workout" do + visit workouts_path + find("#workout_#{@workout.id}").click_link 'Edit' + + current_path.should == edit_workout_path(@workout) + end + end end