specs for services

This commit is contained in:
Karol
2019-12-09 20:35:49 +01:00
parent c89ee6c102
commit 46e7853465
16 changed files with 1029 additions and 13 deletions

View File

@@ -16,8 +16,8 @@ module ExerciseService
response_hash = JSON.parse(response.body, symbolize_names: true)
{error: false}.merge(response_hash.slice(:message, :exercise_found, :update_right))
rescue Faraday::Error => e
{error: true, message: I18n.t('exercises.export_codeharbor.error', message: e.message)}
rescue Faraday::Error, JSON::ParserError
{error: true, message: I18n.t('exercises.export_codeharbor.error')}
end
private

View File

@@ -17,9 +17,9 @@ module ExerciseService
request.body = body
end
return response.success? ? nil : response.body
response.success? ? nil : response.body
rescue StandardError => e
return e.message
e.message
end
end