logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

recovery_codes_controller_spec.rb (919B)


  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
  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(:success)
  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