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 | 15 | @possible_domains = profile.possible_domains |
16 | 16 | if request.post? |
17 | 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 | 21 | @plugins.dispatch(:profile_editor_transaction_extras) |
22 | 22 | @profile_data.update_attributes!(params[:profile_data]) |
23 | 23 | redirect_to :action => 'index', :profile => profile.identifier |
24 | + rescue Exception => ex | |
25 | + profile.identifier = params[:profile] if profile.identifier.blank? | |
24 | 26 | end |
25 | 27 | end |
26 | - rescue Exception => ex | |
27 | - profile.identifier = params[:profile] if profile.identifier.blank? | |
28 | 28 | end |
29 | 29 | end |
30 | 30 | end | ... | ... |
test/functional/profile_editor_controller_test.rb
... | ... | @@ -230,16 +230,20 @@ class ProfileEditorControllerTest < ActionController::TestCase |
230 | 230 | |
231 | 231 | should 'back when update community info fail' do |
232 | 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 | 234 | post :edit, :profile => org.identifier |
235 | + | |
235 | 236 | assert_template 'edit' |
237 | + assert_response :success | |
236 | 238 | end |
237 | 239 | |
238 | 240 | should 'back when update enterprise info fail' do |
239 | 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 | 244 | post :edit, :profile => org.identifier |
242 | 245 | assert_template 'edit' |
246 | + assert_response :success | |
243 | 247 | end |
244 | 248 | |
245 | 249 | should 'show edit profile button' do | ... | ... |