From ea021e7fc850d1b1a4c4bbd8f743c927b759093f Mon Sep 17 00:00:00 2001 From: Daniela Feitosa Date: Mon, 8 Dec 2014 19:44:15 -0300 Subject: [PATCH] curriculum_lattes_plugin: fixed functionals tests --- app/controllers/my_profile/profile_editor_controller.rb | 10 +++++----- test/functional/profile_editor_controller_test.rb | 8 ++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb index 18cb602..cf1055f 100644 --- a/app/controllers/my_profile/profile_editor_controller.rb +++ b/app/controllers/my_profile/profile_editor_controller.rb @@ -15,16 +15,16 @@ class ProfileEditorController < MyProfileController @possible_domains = profile.possible_domains if request.post? params[:profile_data][:fields_privacy] ||= {} if profile.person? && params[:profile_data].is_a?(Hash) - begin - Profile.transaction do - Image.transaction do + Profile.transaction do + Image.transaction do + begin @plugins.dispatch(:profile_editor_transaction_extras) @profile_data.update_attributes!(params[:profile_data]) redirect_to :action => 'index', :profile => profile.identifier + rescue Exception => ex + profile.identifier = params[:profile] if profile.identifier.blank? end end - rescue Exception => ex - profile.identifier = params[:profile] if profile.identifier.blank? end end end diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index a4cd978..7bde51f 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -230,16 +230,20 @@ class ProfileEditorControllerTest < ActionController::TestCase should 'back when update community info fail' do org = fast_create(Community) - Community.any_instance.stubs(:update_attributes).returns(false) + Community.any_instance.expects(:update_attributes!).raises(ActiveRecord::RecordInvalid) post :edit, :profile => org.identifier + assert_template 'edit' + assert_response :success end should 'back when update enterprise info fail' do org = fast_create(Enterprise) - Enterprise.any_instance.stubs(:update_attributes).returns(false) + + Enterprise.any_instance.expects(:update_attributes!).raises(ActiveRecord::RecordInvalid) post :edit, :profile => org.identifier assert_template 'edit' + assert_response :success end should 'show edit profile button' do -- libgit2 0.21.2