From 6732ab3a32240850d5ab4ded2c9cd77135d4bb03 Mon Sep 17 00:00:00 2001
From: Eric Davis <edavis@littlestreamsoftware.com>
Date: Tue, 10 Feb 2009 09:22:37 -0800
Subject: [PATCH] Fixed the TimeLog form, it was always posting to the new action so
 TimeEntries were always getting created and never updated.

  #2707
---
 app/views/timelog/edit.rhtml               |    2 +-
 config/routes.rb                           |    2 +-
 test/functional/timelog_controller_test.rb |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/views/timelog/edit.rhtml b/app/views/timelog/edit.rhtml
index 085f3d8..03ed107 100644
--- a/app/views/timelog/edit.rhtml
+++ b/app/views/timelog/edit.rhtml
@@ -1,6 +1,6 @@
 <h2><%= l(:label_spent_time) %></h2>
 
-<% labelled_tabular_form_for :time_entry, @time_entry, :url => {:action => 'edit', :id => @time_entry, :project_id => @time_entry.project} do |f| %>
+<% labelled_tabular_form_for :time_entry, @time_entry, :url => {:action => 'edit', :project_id => @time_entry.project}, :method => :post do |f| %>
 <%= error_messages_for 'time_entry' %>
 <%= back_url_hidden_field_tag %>
 
diff --git a/config/routes.rb b/config/routes.rb
index d8969e3..bc940b0 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -20,7 +20,7 @@ ActionController::Routing::Routes.draw do |map|
   map.connect 'help/:ctrl/:page', :controller => 'help'
   
   map.connect 'time_entries/:id/edit', :action => 'edit', :controller => 'timelog'
-  map.connect 'projects/:project_id/time_entries/new', :action => 'edit', :controller => 'timelog'
+  map.connect 'projects/:project_id/time_entries/new', :action => 'edit', :controller => 'timelog', :method => :get
   map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'edit', :controller => 'timelog'
   
   map.with_options :controller => 'timelog' do |timelog|
diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb
index 46c3f3e..c33fe16 100644
--- a/test/functional/timelog_controller_test.rb
+++ b/test/functional/timelog_controller_test.rb
@@ -37,7 +37,7 @@ class TimelogControllerTest < Test::Unit::TestCase
     )
     assert_routing(
       {:method => :get, :path => '/projects/ecookbook/time_entries/new'},
-      :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook'
+      :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook', :method => :get
     )
     assert_routing(
       {:method => :get, :path => '/projects/ecookbook/issues/567/time_entries/new'},
-- 
1.5.6.5

