Commit 2c81d81aff63a10e6e5e06307c2822f4412099e2
1 parent
68934890
Exists in
master
and in
28 other branches
ActionItem1126: resist an empty identifier
Showing
2 changed files
with
11 additions
and
0 deletions
Show diff stats
app/controllers/my_profile/profile_editor_controller.rb
@@ -22,6 +22,9 @@ class ProfileEditorController < MyProfileController | @@ -22,6 +22,9 @@ class ProfileEditorController < MyProfileController | ||
22 | end | 22 | end |
23 | end | 23 | end |
24 | rescue | 24 | rescue |
25 | + if profile.identifier.blank? | ||
26 | + profile.identifier = params[:profile] | ||
27 | + end | ||
25 | flash[:notice] = _('Cannot update profile') | 28 | flash[:notice] = _('Cannot update profile') |
26 | end | 29 | end |
27 | end | 30 | end |
test/functional/profile_editor_controller_test.rb
@@ -757,4 +757,12 @@ class ProfileEditorControllerTest < Test::Unit::TestCase | @@ -757,4 +757,12 @@ class ProfileEditorControllerTest < Test::Unit::TestCase | ||
757 | assert_redirected_to :action => 'index', :profile => 'new_address' | 757 | assert_redirected_to :action => 'index', :profile => 'new_address' |
758 | end | 758 | end |
759 | 759 | ||
760 | + should 'not crash if identifier is left blank' do | ||
761 | + c = Community.create!(:name => 'test community', :identifier => 'test_comm') | ||
762 | + assert_nothing_raised do | ||
763 | + post :edit, :profile => c.identifier, :profile_data => c.attributes.merge('identifier' => '') | ||
764 | + end | ||
765 | + assert_response :success | ||
766 | + end | ||
767 | + | ||
760 | end | 768 | end |