sync with central and raise save errors in change_password

pull/14388/head
Gonzalo Riestra 6 years ago
parent 74b3b8077d
commit b773e6f509

@ -88,8 +88,8 @@ module CartoGearsApi
user.password_confirmation = new_password
raise CartoGearsApi::Errors::ValidationFailed.new(user.errors) unless user.errors.empty?
user.save
user.save(raise_on_failure: true)
user.update_in_central
end
private

@ -89,6 +89,22 @@ describe CartoGearsApi::Users::UsersService do
service.change_password(@user.id, 'my_pass')
}.to raise_error(CartoGearsApi::Errors::ValidationFailed, /the same/)
end
it 'raises an exception if the save operation fails' do
User.any_instance.stubs(:save).raises(Sequel::ValidationFailed, 'Saving error')
expect {
service.change_password(@user.id, 'new_password')
}.to raise_error(Sequel::ValidationFailed, 'Saving error')
end
it 'raises an exception if update_in_central operation fails' do
User.any_instance.stubs(:update_in_central).raises(CartoDB::CentralCommunicationFailure, 'Updating error')
expect {
service.change_password(@user.id, 'new_password')
}.to raise_error(CartoDB::CentralCommunicationFailure)
end
end
end
end

Loading…
Cancel
Save