@@ -81,7 +81,7 @@ class OrcidControllerTest < ActionController::TestCase
8181 end
8282
8383 assert_response :unprocessable_entity
84- assert_select '#error-message' , text : /ORCID/
84+ assert_select '#error-message' , text : /error occurred.+ ORCID/
8585 profile = user . profile . reload
8686 assert profile . orcid . blank?
8787 refute profile . orcid_authenticated?
@@ -92,12 +92,28 @@ class OrcidControllerTest < ActionController::TestCase
9292 user = users ( :regular_user )
9393 sign_in user
9494
95- VCR . use_cassette ( 'orcid/error_500 ' ) do
95+ VCR . use_cassette ( 'orcid/get_token_orcid_missing ' ) do
9696 get :callback , params : { code : '123xyz' }
9797 end
9898
9999 assert_response :unprocessable_entity
100- assert_select '#error-message' , text : /ORCID/
100+ assert_select '#error-message' , text : /error occurred.+ORCID/
101+ profile = user . profile . reload
102+ assert profile . orcid . blank?
103+ refute profile . orcid_authenticated?
104+ end
105+
106+ test 'handle missing orcid during callback' do
107+ mock_images
108+ user = users ( :regular_user )
109+ sign_in user
110+
111+ VCR . use_cassette ( 'orcid/get_token_orcid_missing' ) do
112+ get :callback , params : { code : '123xyz' }
113+ end
114+
115+ assert_redirected_to user
116+ assert_includes flash [ :error ] , 'Failed to authenticat'
101117 profile = user . profile . reload
102118 assert profile . orcid . blank?
103119 refute profile . orcid_authenticated?
0 commit comments