rescue HTTP::ConnectionError in RemoteFollowController#create (#4726)
This commit is contained in:
		
							parent
							
								
									8f527bd588
								
							
						
					
					
						commit
						ce9a5f358e
					
				
					 2 changed files with 9 additions and 1 deletions
				
			
		| 
						 | 
					@ -42,7 +42,7 @@ class RemoteFollow
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def acct_resource
 | 
					  def acct_resource
 | 
				
			||||||
    @_acct_resource ||= Goldfinger.finger("acct:#{acct}")
 | 
					    @_acct_resource ||= Goldfinger.finger("acct:#{acct}")
 | 
				
			||||||
  rescue Goldfinger::Error
 | 
					  rescue Goldfinger::Error, HTTP::ConnectionError
 | 
				
			||||||
    nil
 | 
					    nil
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -87,6 +87,14 @@ describe RemoteFollowController do
 | 
				
			||||||
        expect(response).to render_template(:new)
 | 
					        expect(response).to render_template(:new)
 | 
				
			||||||
        expect(response.body).to include(I18n.t('remote_follow.missing_resource'))
 | 
					        expect(response.body).to include(I18n.t('remote_follow.missing_resource'))
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      it 'renders new when occur HTTP::ConnectionError' do
 | 
				
			||||||
 | 
					        allow(Goldfinger).to receive(:finger).with('acct:user@unknown').and_raise(HTTP::ConnectionError)
 | 
				
			||||||
 | 
					        post :create, params: { account_username: @account.to_param, remote_follow: { acct: 'user@unknown' } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        expect(response).to render_template(:new)
 | 
				
			||||||
 | 
					        expect(response.body).to include(I18n.t('remote_follow.missing_resource'))
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue