File tree Expand file tree Collapse file tree 4 files changed +14
-1
lines changed
app/services/task_service
spec/services/task_service Expand file tree Collapse file tree 4 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,11 @@ def execute
1212 body = @zip . string
1313 begin
1414 response = self . class . connection . post ( @account_link . push_url ) { |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
1620 rescue StandardError => e
1721 e
1822 end
Original file line number Diff line number Diff line change 88 error_alert : Die Aufgabe konnte nicht dupliziert werden.
99 export_external_confirm :
1010 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?
1112 success : Aufgabe (%{title}) erfolgreich exportiert.
1213 import :
1314 internal_error : Beim Import dieser Aufgabe ist auf CodeHarbor ein interner Fehler aufgetreten.
Original file line number Diff line number Diff line change 88 error_alert : Task could not be duplicated
99 export_external_confirm :
1010 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?
1112 success : Task (%{title}) successfully exported.
1213 import :
1314 internal_error : An internal error occurred on CodeHarbor while importing the exercise.
Original file line number Diff line number Diff line change 5353
5454 it { is_expected . to be response }
5555 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
5663 end
5764
5865 context 'when an error occurs' do
You can’t perform that action at this time.
0 commit comments