Skip to content

Commit d414043

Browse files
committed
Fix 'Create and add another' button redirect path issue
1 parent 83219cc commit d414043

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

app/controllers/custom_fields_groups_controller.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ def create
1717
@custom_fields_group.safe_attributes = custom_fields_group_params
1818
if @custom_fields_group.save
1919
flash[:notice] = l(:notice_successful_create)
20-
redirect_to custom_fields_groups_path
20+
if params[:continue]
21+
redirect_to new_custom_fields_group_path
22+
else
23+
redirect_to custom_fields_groups_path
24+
end
2125
else
2226
render :action => 'new'
2327
end

test/functional/custom_fields_groups_controller_test.rb

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CustomFieldsGroupsControllerTest < ActionController::TestCase
3939
assert_select 'input[type=checkbox][name=?][value=?]', 'custom_fields_group[custom_field_ids][]', '9'
4040
end
4141

42-
test 'should create custom fields gruop' do
42+
test 'should create custom fields group' do
4343
assert_difference 'CustomFieldsGroup.count' do
4444
post :create, :params => {
4545
:custom_fields_group => {
@@ -55,7 +55,24 @@ class CustomFieldsGroupsControllerTest < ActionController::TestCase
5555
assert_equal 4, custom_fields_group.position
5656
end
5757

58-
test 'should not create custom fields gruop without name' do
58+
test 'should create custom fields group with continue params' do
59+
assert_difference 'CustomFieldsGroup.count' do
60+
post :create, :params => {
61+
:custom_fields_group => {
62+
:name => 'Group 4',
63+
:custom_field_ids => [9]
64+
},
65+
:continue => 'Create and add another'
66+
}
67+
end
68+
assert_redirected_to '/custom_fields_groups/new'
69+
70+
assert custom_fields_group = CustomFieldsGroup.find_by_name('Group 4')
71+
assert_equal [9], custom_fields_group.custom_field_ids
72+
assert_equal 4, custom_fields_group.position
73+
end
74+
75+
test 'should not create custom fields group without name' do
5976
post :create, :params => {
6077
:custom_fields_group => {
6178
:name => '',

0 commit comments

Comments
 (0)