From 82f5831545512f254b7e3ba01803163e8b6d755a Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Thu, 21 Jul 2011 15:55:50 +0000 Subject: [PATCH] Adds 'Create and continue' button on the new group form. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6304 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/groups_controller.rb | 6 ++++-- app/views/groups/new.html.erb | 5 ++++- test/functional/groups_controller_test.rb | 7 +++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index db56eff96..76b891a44 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -67,8 +67,10 @@ class GroupsController < ApplicationController respond_to do |format| if @group.save - flash[:notice] = l(:notice_successful_create) - format.html { redirect_to(groups_path) } + format.html { + flash[:notice] = l(:notice_successful_create) + redirect_to(params[:continue] ? new_group_path : groups_path) + } format.xml { render :xml => @group, :status => :created, :location => @group } else format.html { render :action => "new" } diff --git a/app/views/groups/new.html.erb b/app/views/groups/new.html.erb index 469fc9b14..e983102af 100644 --- a/app/views/groups/new.html.erb +++ b/app/views/groups/new.html.erb @@ -2,5 +2,8 @@ <% form_for(@group, :builder => TabularFormBuilder, :lang => current_language) do |f| %> <%= render :partial => 'form', :locals => { :f => f } %> -

<%= f.submit l(:button_create) %>

+

+ <%= f.submit l(:button_create) %> + <%= f.submit l(:button_create_and_continue), :name => 'continue' %> +

<% end %> diff --git a/test/functional/groups_controller_test.rb b/test/functional/groups_controller_test.rb index f45dfc456..2d84f3e4b 100644 --- a/test/functional/groups_controller_test.rb +++ b/test/functional/groups_controller_test.rb @@ -57,6 +57,13 @@ class GroupsControllerTest < ActionController::TestCase assert_redirected_to '/groups' end + def test_create_and_continue + assert_difference 'Group.count' do + post :create, :group => {:lastname => 'New group'}, :continue => 'Create and continue' + end + assert_redirected_to '/groups/new' + end + def test_edit get :edit, :id => 10 assert_response :success