Redirect to custom field after create or update.

git-svn-id: http://svn.redmine.org/redmine/trunk@14746 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2015-10-25 08:37:54 +00:00
parent 2f51dc11cf
commit a3efaceb8f
2 changed files with 6 additions and 7 deletions

View File

@@ -43,7 +43,7 @@ class CustomFieldsController < ApplicationController
if @custom_field.save if @custom_field.save
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
call_hook(:controller_custom_fields_new_after_save, :params => params, :custom_field => @custom_field) call_hook(:controller_custom_fields_new_after_save, :params => params, :custom_field => @custom_field)
redirect_to custom_fields_path(:tab => @custom_field.class.name) redirect_to edit_custom_field_path(@custom_field)
else else
render :action => 'new' render :action => 'new'
end end
@@ -56,7 +56,7 @@ class CustomFieldsController < ApplicationController
if @custom_field.update_attributes(params[:custom_field]) if @custom_field.update_attributes(params[:custom_field])
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
call_hook(:controller_custom_fields_edit_after_save, :params => params, :custom_field => @custom_field) call_hook(:controller_custom_fields_edit_after_save, :params => params, :custom_field => @custom_field)
redirect_to custom_fields_path(:tab => @custom_field.class.name) redirect_to edit_custom_field_path(@custom_field)
else else
render :action => 'edit' render :action => 'edit'
end end

View File

@@ -139,7 +139,7 @@ class CustomFieldsControllerTest < ActionController::TestCase
end end
def test_create_list_custom_field def test_create_list_custom_field
assert_difference 'CustomField.count' do field = new_record(IssueCustomField) do
post :create, :type => "IssueCustomField", post :create, :type => "IssueCustomField",
:custom_field => {:name => "test_post_new_list", :custom_field => {:name => "test_post_new_list",
:default_value => "", :default_value => "",
@@ -154,9 +154,8 @@ class CustomFieldsControllerTest < ActionController::TestCase
:field_format => "list", :field_format => "list",
:tracker_ids => ["1", ""]} :tracker_ids => ["1", ""]}
end end
assert_redirected_to '/custom_fields?tab=IssueCustomField' assert_redirected_to "/custom_fields/#{field.id}/edit"
field = IssueCustomField.find_by_name('test_post_new_list') assert_equal "test_post_new_list", field.name
assert_not_nil field
assert_equal ["0.1", "0.2"], field.possible_values assert_equal ["0.1", "0.2"], field.possible_values
assert_equal 1, field.trackers.size assert_equal 1, field.trackers.size
end end
@@ -202,7 +201,7 @@ class CustomFieldsControllerTest < ActionController::TestCase
def test_update def test_update
put :update, :id => 1, :custom_field => {:name => 'New name'} put :update, :id => 1, :custom_field => {:name => 'New name'}
assert_redirected_to '/custom_fields?tab=IssueCustomField' assert_redirected_to '/custom_fields/1/edit'
field = CustomField.find(1) field = CustomField.find(1)
assert_equal 'New name', field.name assert_equal 'New name', field.name