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