##// END OF EJS Templates
Adds a 'Create and continue' button on the spent time form (#9995)....
Jean-Philippe Lang -
r8567:1d07bb91a7d1
parent child
Show More
@@ -127,8 +127,12 class TimelogController < ApplicationController
127 if @time_entry.save
127 if @time_entry.save
128 respond_to do |format|
128 respond_to do |format|
129 format.html {
129 format.html {
130 flash[:notice] = l(:notice_successful_update)
130 flash[:notice] = l(:notice_successful_create)
131 redirect_back_or_default :action => 'index', :project_id => @time_entry.project
131 if params[:continue]
132 redirect_to :action => 'new', :project_id => @time_entry.project, :issue_id => @time_entry.issue
133 else
134 redirect_back_or_default :action => 'index', :project_id => @time_entry.project
135 end
132 }
136 }
133 format.api { render :action => 'show', :status => :created, :location => time_entry_url(@time_entry) }
137 format.api { render :action => 'show', :status => :created, :location => time_entry_url(@time_entry) }
134 end
138 end
@@ -2,5 +2,6
2
2
3 <% labelled_form_for @time_entry, :url => project_time_entries_path(@time_entry.project) do |f| %>
3 <% labelled_form_for @time_entry, :url => project_time_entries_path(@time_entry.project) do |f| %>
4 <%= render :partial => 'form', :locals => {:f => f} %>
4 <%= render :partial => 'form', :locals => {:f => f} %>
5 <%= submit_tag l(:button_save) %>
5 <%= submit_tag l(:button_create) %>
6 <%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
6 <% end %>
7 <% end %>
@@ -119,6 +119,28 class TimelogControllerTest < ActionController::TestCase
119 assert_equal 3, t.user_id
119 assert_equal 3, t.user_id
120 end
120 end
121
121
122 def test_create_and_continue
123 @request.session[:user_id] = 2
124 post :create, :project_id => 1,
125 :time_entry => {:activity_id => '11',
126 :issue_id => '',
127 :spent_on => '2008-03-14',
128 :hours => '7.3'},
129 :continue => '1'
130 assert_redirected_to '/projects/ecookbook/time_entries/new'
131 end
132
133 def test_create_and_continue_with_issue_id
134 @request.session[:user_id] = 2
135 post :create, :project_id => 1,
136 :time_entry => {:activity_id => '11',
137 :issue_id => '1',
138 :spent_on => '2008-03-14',
139 :hours => '7.3'},
140 :continue => '1'
141 assert_redirected_to '/projects/ecookbook/issues/1/time_entries/new'
142 end
143
122 def test_create_without_log_time_permission_should_be_denied
144 def test_create_without_log_time_permission_should_be_denied
123 @request.session[:user_id] = 2
145 @request.session[:user_id] = 2
124 Role.find_by_name('Manager').remove_permission! :log_time
146 Role.find_by_name('Manager').remove_permission! :log_time
General Comments 0
You need to be logged in to leave comments. Login now