diff options
-rw-r--r-- | app/controllers/timelog_controller.rb | 8 | ||||
-rw-r--r-- | app/views/timelog/new.html.erb | 3 | ||||
-rw-r--r-- | test/functional/timelog_controller_test.rb | 22 |
3 files changed, 30 insertions, 3 deletions
diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index 220954735..e1895f5de 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -127,8 +127,12 @@ class TimelogController < ApplicationController if @time_entry.save respond_to do |format| format.html { - flash[:notice] = l(:notice_successful_update) - redirect_back_or_default :action => 'index', :project_id => @time_entry.project + flash[:notice] = l(:notice_successful_create) + if params[:continue] + redirect_to :action => 'new', :project_id => @time_entry.project, :issue_id => @time_entry.issue + else + redirect_back_or_default :action => 'index', :project_id => @time_entry.project + end } format.api { render :action => 'show', :status => :created, :location => time_entry_url(@time_entry) } end diff --git a/app/views/timelog/new.html.erb b/app/views/timelog/new.html.erb index fe6277738..6871c5f23 100644 --- a/app/views/timelog/new.html.erb +++ b/app/views/timelog/new.html.erb @@ -2,5 +2,6 @@ <% labelled_form_for @time_entry, :url => project_time_entries_path(@time_entry.project) do |f| %> <%= render :partial => 'form', :locals => {:f => f} %> - <%= submit_tag l(:button_save) %> + <%= submit_tag l(:button_create) %> + <%= submit_tag l(:button_create_and_continue), :name => 'continue' %> <% end %> diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index 09cf2b513..4dd8fe0c6 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -119,6 +119,28 @@ class TimelogControllerTest < ActionController::TestCase assert_equal 3, t.user_id end + def test_create_and_continue + @request.session[:user_id] = 2 + post :create, :project_id => 1, + :time_entry => {:activity_id => '11', + :issue_id => '', + :spent_on => '2008-03-14', + :hours => '7.3'}, + :continue => '1' + assert_redirected_to '/projects/ecookbook/time_entries/new' + end + + def test_create_and_continue_with_issue_id + @request.session[:user_id] = 2 + post :create, :project_id => 1, + :time_entry => {:activity_id => '11', + :issue_id => '1', + :spent_on => '2008-03-14', + :hours => '7.3'}, + :continue => '1' + assert_redirected_to '/projects/ecookbook/issues/1/time_entries/new' + end + def test_create_without_log_time_permission_should_be_denied @request.session[:user_id] = 2 Role.find_by_name('Manager').remove_permission! :log_time |