@@ -47,20 +47,23 @@ class OrcidControllerTest < ActionController::TestCase
4747 assert_redirected_to user
4848 end
4949
50- test 'handle callback but do not assign orcid if already used' do
50+ test 'handle callback and assign orcid even if already used' do
5151 mock_images
5252 user = users ( :regular_user )
53+ existing_orcid_user = users ( :trainer_user )
54+ assert existing_orcid_user . profile . orcid_authenticated?
5355 sign_in user
5456
5557 VCR . use_cassette ( 'orcid/get_token_existing_orcid' ) do
5658 get :callback , params : { code : '123xyz' }
5759 end
5860
5961 profile = user . profile . reload
60- assert profile . orcid . blank?
61- refute profile . orcid_authenticated?
62+ assert_equal '0000-0002-1825-0097' , profile . orcid
63+ assert profile . orcid_authenticated?
64+ refute existing_orcid_user . reload . profile . orcid_authenticated?
6265 assert_redirected_to user
63- assert_includes flash [ :error ] , 'ORCID has already been'
66+ assert flash [ :error ] . blank?
6467 end
6568
6669 test 'do not handle callback if not logged-in' do
@@ -92,7 +95,7 @@ class OrcidControllerTest < ActionController::TestCase
9295 user = users ( :regular_user )
9396 sign_in user
9497
95- VCR . use_cassette ( 'orcid/get_token_orcid_missing ' ) do
98+ VCR . use_cassette ( 'orcid/error_500 ' ) do
9699 get :callback , params : { code : '123xyz' }
97100 end
98101
0 commit comments