Convert measurement api/v1/admin/* controller specs to request specs (#28005)
		
	This commit is contained in:
		
					parent
					
						
							
								f91e751383
							
						
					
				
			
			
				commit
				
					
						30ee4aaff4
					
				
			
		
					 6 changed files with 105 additions and 69 deletions
				
			
		
							
								
								
									
										35
									
								
								spec/requests/api/v1/admin/dimensions_spec.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								spec/requests/api/v1/admin/dimensions_spec.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,35 @@ | |||
| # frozen_string_literal: true | ||||
| 
 | ||||
| require 'rails_helper' | ||||
| 
 | ||||
| describe 'Admin Dimensions' do | ||||
|   let(:user)    { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) } | ||||
|   let(:token)   { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) } | ||||
|   let(:headers) { { 'Authorization' => "Bearer #{token.token}" } } | ||||
|   let(:account) { Fabricate(:account) } | ||||
| 
 | ||||
|   describe 'GET /api/v1/admin/dimensions' do | ||||
|     context 'when not authorized' do | ||||
|       it 'returns http forbidden' do | ||||
|         post '/api/v1/admin/dimensions', params: { account_id: account.id, limit: 2 } | ||||
| 
 | ||||
|         expect(response) | ||||
|           .to have_http_status(403) | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     context 'with correct scope' do | ||||
|       let(:scopes) { 'admin:read' } | ||||
| 
 | ||||
|       it 'returns http success and status json' do | ||||
|         post '/api/v1/admin/dimensions', params: { account_id: account.id, limit: 2 }, headers: headers | ||||
| 
 | ||||
|         expect(response) | ||||
|           .to have_http_status(200) | ||||
| 
 | ||||
|         expect(body_as_json) | ||||
|           .to be_an(Array) | ||||
|       end | ||||
|     end | ||||
|   end | ||||
| end | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue