Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/controllers/custom_fields_groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ def create
@custom_fields_group.safe_attributes = custom_fields_group_params
if @custom_fields_group.save
flash[:notice] = l(:notice_successful_create)
redirect_to custom_fields_groups_path
if params[:continue]
redirect_to new_custom_fields_group_path
else
redirect_to custom_fields_groups_path
end
else
render :action => 'new'
end
Expand Down
21 changes: 19 additions & 2 deletions test/functional/custom_fields_groups_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CustomFieldsGroupsControllerTest < ActionController::TestCase
assert_select 'input[type=checkbox][name=?][value=?]', 'custom_fields_group[custom_field_ids][]', '9'
end

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

test 'should not create custom fields gruop without name' do
test 'should create custom fields group with continue params' do
assert_difference 'CustomFieldsGroup.count' do
post :create, :params => {
:custom_fields_group => {
:name => 'Group 4',
:custom_field_ids => [9]
},
:continue => 'Create and add another'
}
end
assert_redirected_to '/custom_fields_groups/new'

assert custom_fields_group = CustomFieldsGroup.find_by_name('Group 4')
assert_equal [9], custom_fields_group.custom_field_ids
assert_equal 4, custom_fields_group.position
end

test 'should not create custom fields group without name' do
post :create, :params => {
:custom_fields_group => {
:name => '',
Expand Down