Commit ea021e7fc850d1b1a4c4bbd8f743c927b759093f
1 parent
1ea73489
Exists in
master
and in
29 other branches
curriculum_lattes_plugin: fixed functionals tests
Showing
2 changed files
with
11 additions
and
7 deletions
Show diff stats
app/controllers/my_profile/profile_editor_controller.rb
@@ -15,16 +15,16 @@ class ProfileEditorController < MyProfileController | @@ -15,16 +15,16 @@ class ProfileEditorController < MyProfileController | ||
15 | @possible_domains = profile.possible_domains | 15 | @possible_domains = profile.possible_domains |
16 | if request.post? | 16 | if request.post? |
17 | params[:profile_data][:fields_privacy] ||= {} if profile.person? && params[:profile_data].is_a?(Hash) | 17 | params[:profile_data][:fields_privacy] ||= {} if profile.person? && params[:profile_data].is_a?(Hash) |
18 | - begin | ||
19 | - Profile.transaction do | ||
20 | - Image.transaction do | 18 | + Profile.transaction do |
19 | + Image.transaction do | ||
20 | + begin | ||
21 | @plugins.dispatch(:profile_editor_transaction_extras) | 21 | @plugins.dispatch(:profile_editor_transaction_extras) |
22 | @profile_data.update_attributes!(params[:profile_data]) | 22 | @profile_data.update_attributes!(params[:profile_data]) |
23 | redirect_to :action => 'index', :profile => profile.identifier | 23 | redirect_to :action => 'index', :profile => profile.identifier |
24 | + rescue Exception => ex | ||
25 | + profile.identifier = params[:profile] if profile.identifier.blank? | ||
24 | end | 26 | end |
25 | end | 27 | end |
26 | - rescue Exception => ex | ||
27 | - profile.identifier = params[:profile] if profile.identifier.blank? | ||
28 | end | 28 | end |
29 | end | 29 | end |
30 | end | 30 | end |
test/functional/profile_editor_controller_test.rb
@@ -230,16 +230,20 @@ class ProfileEditorControllerTest < ActionController::TestCase | @@ -230,16 +230,20 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
230 | 230 | ||
231 | should 'back when update community info fail' do | 231 | should 'back when update community info fail' do |
232 | org = fast_create(Community) | 232 | org = fast_create(Community) |
233 | - Community.any_instance.stubs(:update_attributes).returns(false) | 233 | + Community.any_instance.expects(:update_attributes!).raises(ActiveRecord::RecordInvalid) |
234 | post :edit, :profile => org.identifier | 234 | post :edit, :profile => org.identifier |
235 | + | ||
235 | assert_template 'edit' | 236 | assert_template 'edit' |
237 | + assert_response :success | ||
236 | end | 238 | end |
237 | 239 | ||
238 | should 'back when update enterprise info fail' do | 240 | should 'back when update enterprise info fail' do |
239 | org = fast_create(Enterprise) | 241 | org = fast_create(Enterprise) |
240 | - Enterprise.any_instance.stubs(:update_attributes).returns(false) | 242 | + |
243 | + Enterprise.any_instance.expects(:update_attributes!).raises(ActiveRecord::RecordInvalid) | ||
241 | post :edit, :profile => org.identifier | 244 | post :edit, :profile => org.identifier |
242 | assert_template 'edit' | 245 | assert_template 'edit' |
246 | + assert_response :success | ||
243 | end | 247 | end |
244 | 248 | ||
245 | should 'show edit profile button' do | 249 | should 'show edit profile button' do |