File tree Expand file tree Collapse file tree 4 files changed +14
-1
lines changed
app/services/exercise_service
spec/services/exercise_service Expand file tree Collapse file tree 4 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,11 @@ def execute
1818 request . body = body
1919 end
2020
21- response . success? ? nil : response . body
21+ if response . success?
22+ nil
23+ else
24+ response . status == 401 ? I18n . t ( 'exercises.export_codeharbor.not_authorized' ) : response . body
25+ end
2226 rescue StandardError => e
2327 e . message
2428 end
Original file line number Diff line number Diff line change 103103 export_failed : ' Export ist fehlgeschlagen.<br>ID: %{id}<br>Title: %{title}<br><br>Error: %{error}'
104104 label : Zu CodeHarbor exportieren
105105 successfully_exported : ' Aufgabe wurde erfolgreich exportiert.<br>ID: %{id}<br>Title: %{title}'
106+ not_authorized : Die Autorisierung mit CodeHarbor konnte nicht hergestellt werden. Ist der API-Schlüssel korrekt?
106107 external_users :
107108 statistics :
108109 addendum : " * Differenzen von mehr als %{delta} Minuten werden ignoriert."
Original file line number Diff line number Diff line change 103103 export_failed : ' Export has failed.<br>ID: %{id}<br>Title: %{title}<br><br>Error: %{error}'
104104 label : Export to CodeHarbor
105105 successfully_exported : ' Exercise has been successfully exported.<br>ID: %{id}<br>Title: %{title}'
106+ not_authorized : Authorization with could not be established with CodeHarbor. Is the API Key correct?
106107 external_users :
107108 statistics :
108109 addendum : " * Deltas longer than %{delta} minutes are ignored."
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 ( 'exercises.export_codeharbor.not_authorized' ) }
60+
61+ it { is_expected . to eql 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