File tree 4 files changed +14
-1
lines changed
app/services/exercise_service
spec/services/exercise_service
4 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,11 @@ def execute
18
18
request . body = body
19
19
end
20
20
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
22
26
rescue StandardError => e
23
27
e . message
24
28
end
Original file line number Diff line number Diff line change 102
102
error : Es ist ein Fehler bei der Kommunikation mit CodeHarbor aufgetreten.
103
103
export_failed : ' Export ist fehlgeschlagen.<br>ID: %{id}<br>Title: %{title}<br><br>Error: %{error}'
104
104
label : Zu CodeHarbor exportieren
105
+ not_authorized : Die Autorisierung mit CodeHarbor konnte nicht hergestellt werden. Ist der API-Schlüssel korrekt?
105
106
successfully_exported : ' Aufgabe wurde erfolgreich exportiert.<br>ID: %{id}<br>Title: %{title}'
106
107
external_users :
107
108
statistics :
Original file line number Diff line number Diff line change 102
102
error : An error occurred while contacting CodeHarbor
103
103
export_failed : ' Export has failed.<br>ID: %{id}<br>Title: %{title}<br><br>Error: %{error}'
104
104
label : Export to CodeHarbor
105
+ not_authorized : Authorization with could not be established with CodeHarbor. Is the API Key correct?
105
106
successfully_exported : ' Exercise has been successfully exported.<br>ID: %{id}<br>Title: %{title}'
106
107
external_users :
107
108
statistics :
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 ( 'exercises.export_codeharbor.not_authorized' ) }
60
+
61
+ it { is_expected . to eql 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