File tree 4 files changed +14
-1
lines changed
app/services/task_service
spec/services/task_service
4 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,11 @@ def execute
12
12
body = @zip . string
13
13
begin
14
14
response = connection . post { |request | request_parameters ( request , body ) }
15
- response . success? ? nil : response . body
15
+ if response . success?
16
+ nil
17
+ else
18
+ response . status == 401 ? I18n . t ( 'tasks.export_external_confirm.not_authorized' , account_link : @account_link . name ) : response . body
19
+ end
16
20
rescue StandardError => e
17
21
e
18
22
end
Original file line number Diff line number Diff line change 8
8
error_alert : Die Aufgabe konnte nicht dupliziert werden.
9
9
export_external_confirm :
10
10
error : ' Der Export der Aufgabe (%{title}) ist fehlgeschlagen. <br> Fehler: %{error}'
11
+ not_authorized : Die Autorisierung mit "%{account_link}" konnte nicht hergestellt werden. Ist der API-Schlüssel korrekt?
11
12
success : Aufgabe (%{title}) erfolgreich exportiert.
12
13
import :
13
14
internal_error : Beim Import dieser Aufgabe ist auf CodeHarbor ein interner Fehler aufgetreten.
Original file line number Diff line number Diff line change 8
8
error_alert : Task could not be duplicated
9
9
export_external_confirm :
10
10
error : ' Export of task (%{title}) failed. <br> Error: %{error}'
11
+ not_authorized : Authorization with could not be established with "%{account_link}". Is the API Key correct?
11
12
success : Task (%{title}) successfully exported.
12
13
import :
13
14
internal_error : An internal error occurred on CodeHarbor while importing the exercise.
Original file line number Diff line number Diff line change 53
53
54
54
it { is_expected . to be response }
55
55
end
56
+
57
+ context 'when response status is 401' do
58
+ let ( :status ) { 401 }
59
+ let ( :response ) { I18n . t ( 'tasks.export_external_confirm.not_authorized' , account_link : account_link . name ) }
60
+
61
+ it { is_expected . to eq response }
62
+ end
56
63
end
57
64
58
65
context 'when an error occurs' do
You can’t perform that action at this time.
0 commit comments