Remove usage of assigns in controller specs (#30195)
		
	This commit is contained in:
		
					parent
					
						
							
								ae363f0555
							
						
					
				
			
			
				commit
				
					
						5b595b8a5a
					
				
			
		
					 13 changed files with 66 additions and 51 deletions
				
			
		|  | @ -9,11 +9,16 @@ describe Settings::TwoFactorAuthentication::ConfirmationsController do | |||
|     it 'renders the new view' do | ||||
|       subject | ||||
| 
 | ||||
|       expect(assigns(:confirmation)).to be_instance_of Form::TwoFactorConfirmation | ||||
|       expect(assigns(:provision_url)).to eq 'otpauth://totp/cb6e6126.ngrok.io:local-part%40domain?secret=thisisasecretforthespecofnewview&issuer=cb6e6126.ngrok.io' | ||||
|       expect(assigns(:qrcode)).to be_instance_of RQRCode::QRCode | ||||
|       expect(response).to have_http_status(200) | ||||
|       expect(response).to render_template(:new) | ||||
|       expect(response.body) | ||||
|         .to include(qr_code_markup) | ||||
|     end | ||||
| 
 | ||||
|     def qr_code_markup | ||||
|       RQRCode::QRCode.new( | ||||
|         'otpauth://totp/cb6e6126.ngrok.io:local-part%40domain?secret=thisisasecretforthespecofnewview&issuer=cb6e6126.ngrok.io' | ||||
|       ).as_svg(padding: 0, module_size: 4) | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|  | @ -61,10 +66,10 @@ describe Settings::TwoFactorAuthentication::ConfirmationsController do | |||
|             expect { post_create_with_options } | ||||
|               .to change { user.reload.otp_secret }.to 'thisisasecretforthespecofnewview' | ||||
| 
 | ||||
|             expect(assigns(:recovery_codes)).to eq otp_backup_codes | ||||
|             expect(flash[:notice]).to eq 'Two-factor authentication successfully enabled' | ||||
|             expect(response).to have_http_status(200) | ||||
|             expect(response).to render_template('settings/two_factor_authentication/recovery_codes/index') | ||||
|             expect(response.body).to include(*otp_backup_codes) | ||||
|           end | ||||
|         end | ||||
| 
 | ||||
|  |  | |||
|  | @ -15,10 +15,11 @@ describe Settings::TwoFactorAuthentication::RecoveryCodesController do | |||
|       sign_in user, scope: :user | ||||
|       post :create, session: { challenge_passed_at: Time.now.utc } | ||||
| 
 | ||||
|       expect(assigns(:recovery_codes)).to eq otp_backup_codes | ||||
|       expect(flash[:notice]).to eq 'Recovery codes successfully regenerated' | ||||
|       expect(response).to have_http_status(200) | ||||
|       expect(response).to render_template(:index) | ||||
|       expect(response.body) | ||||
|         .to include(*otp_backup_codes) | ||||
|     end | ||||
| 
 | ||||
|     it 'redirects when not signed in' do | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue