Begin adding edit functionality

This commit is contained in:
Andrew Tomaka 2013-08-05 01:07:11 -04:00
parent 89cfba504c
commit 71b047be48
5 changed files with 24 additions and 1 deletions

View file

@ -6,4 +6,8 @@ class WorkoutsController < ApplicationController
def show
@workout = Workout.find(params[:id])
end
def edit
@workout = Workout.find(params[:id])
end
end

View file

@ -0,0 +1,5 @@
<%= form_for @workout do |f| %>
<%= f.label :date %>
<%= f.text_field :date %>
<%= f.submit nil %>
<% end %>

View file

@ -0,0 +1 @@
<%= render :partial => 'form' %>

View file

@ -1,5 +1,9 @@
<ul>
<% @workouts.each do |workout| %>
<li><%= link_to workout.date, workout %></li>
<li id="workout_<%= workout.id %>">
<%= link_to workout.date, workout %> [
<%= link_to 'Edit', edit_workout_path(workout) %> |
]
</li>
<% end %>
</ul>

View file

@ -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