From 2c81d81aff63a10e6e5e06307c2822f4412099e2 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Thu, 23 Jul 2009 14:57:02 -0300 Subject: [PATCH] ActionItem1126: resist an empty identifier --- app/controllers/my_profile/profile_editor_controller.rb | 3 +++ test/functional/profile_editor_controller_test.rb | 8 ++++++++ 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb index 4512674..472112c 100644 --- a/app/controllers/my_profile/profile_editor_controller.rb +++ b/app/controllers/my_profile/profile_editor_controller.rb @@ -22,6 +22,9 @@ class ProfileEditorController < MyProfileController end end rescue + if profile.identifier.blank? + profile.identifier = params[:profile] + end flash[:notice] = _('Cannot update profile') end end diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index 8531470..a68f0e0 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -757,4 +757,12 @@ class ProfileEditorControllerTest < Test::Unit::TestCase assert_redirected_to :action => 'index', :profile => 'new_address' end + should 'not crash if identifier is left blank' do + c = Community.create!(:name => 'test community', :identifier => 'test_comm') + assert_nothing_raised do + post :edit, :profile => c.identifier, :profile_data => c.attributes.merge('identifier' => '') + end + assert_response :success + end + end -- libgit2 0.21.2