The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

32 lines
962 B

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe Settings::TwoFactorAuthentication::RecoveryCodesController do
  4. render_views
  5. describe 'POST #create' do
  6. it 'updates the codes and shows them on a view when signed in' do
  7. user = Fabricate(:user)
  8. otp_backup_codes = user.generate_otp_backup_codes!
  9. expect_any_instance_of(User).to receive(:generate_otp_backup_codes!) do |value|
  10. expect(value).to eq user
  11. otp_backup_codes
  12. end
  13. sign_in user, scope: :user
  14. post :create, session: { challenge_passed_at: Time.now.utc }
  15. expect(assigns(:recovery_codes)).to eq otp_backup_codes
  16. expect(flash[:notice]).to eq 'Recovery codes successfully regenerated'
  17. expect(response).to have_http_status(200)
  18. expect(response).to render_template(:index)
  19. end
  20. it 'redirects when not signed in' do
  21. post :create
  22. expect(response).to redirect_to '/auth/sign_in'
  23. end
  24. end
  25. end