Convert status embed controller to request spec (#32448)
This commit is contained in:
		
					parent
					
						
							
								ad4be12473
							
						
					
				
			
			
				commit
				
					
						6d72c13a4d
					
				
			
		
					 2 changed files with 74 additions and 72 deletions
				
			
		|  | @ -736,76 +736,4 @@ RSpec.describe StatusesController do | |||
|       end | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   describe 'GET #embed' do | ||||
|     let(:account) { Fabricate(:account) } | ||||
|     let(:status)  { Fabricate(:status, account: account) } | ||||
| 
 | ||||
|     context 'when account is suspended' do | ||||
|       let(:account) { Fabricate(:account, suspended: true) } | ||||
| 
 | ||||
|       before do | ||||
|         get :embed, params: { account_username: account.username, id: status.id } | ||||
|       end | ||||
| 
 | ||||
|       it 'returns http gone' do | ||||
|         expect(response).to have_http_status(410) | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     context 'when status is a reblog' do | ||||
|       let(:original_account) { Fabricate(:account, domain: 'example.com') } | ||||
|       let(:original_status) { Fabricate(:status, account: original_account, url: 'https://example.com/123') } | ||||
|       let(:status) { Fabricate(:status, account: account, reblog: original_status) } | ||||
| 
 | ||||
|       before do | ||||
|         get :embed, params: { account_username: status.account.username, id: status.id } | ||||
|       end | ||||
| 
 | ||||
|       it 'returns http not found' do | ||||
|         expect(response).to have_http_status(404) | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     context 'when status is public' do | ||||
|       before do | ||||
|         get :embed, params: { account_username: status.account.username, id: status.id } | ||||
|       end | ||||
| 
 | ||||
|       it 'renders status successfully', :aggregate_failures do | ||||
|         expect(response) | ||||
|           .to have_http_status(200) | ||||
|           .and render_template(:embed) | ||||
|         expect(response.headers).to include( | ||||
|           'Vary' => 'Accept, Accept-Language, Cookie', | ||||
|           'Cache-Control' => include('public'), | ||||
|           'Link' => include('activity+json') | ||||
|         ) | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     context 'when status is private' do | ||||
|       let(:status) { Fabricate(:status, account: account, visibility: :private) } | ||||
| 
 | ||||
|       before do | ||||
|         get :embed, params: { account_username: status.account.username, id: status.id } | ||||
|       end | ||||
| 
 | ||||
|       it 'returns http not found' do | ||||
|         expect(response).to have_http_status(404) | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     context 'when status is direct' do | ||||
|       let(:status) { Fabricate(:status, account: account, visibility: :direct) } | ||||
| 
 | ||||
|       before do | ||||
|         get :embed, params: { account_username: status.account.username, id: status.id } | ||||
|       end | ||||
| 
 | ||||
|       it 'returns http not found' do | ||||
|         expect(response).to have_http_status(404) | ||||
|       end | ||||
|     end | ||||
|   end | ||||
| end | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue