resets_controller_spec.rb 944 B

123456789101112131415161718192021222324252627282930313233
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe Admin::ResetsController do
  4. render_views
  5. let(:account) { Fabricate(:account) }
  6. before do
  7. sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')), scope: :user
  8. end
  9. describe 'POST #create', :sidekiq_inline do
  10. it 'redirects to admin accounts page' do
  11. expect do
  12. post :create, params: { account_id: account.id }
  13. end.to change(Devise.mailer.deliveries, :size).by(2)
  14. expect(Devise.mailer.deliveries).to have_attributes(
  15. first: have_attributes(
  16. to: include(account.user.email),
  17. subject: I18n.t('devise.mailer.password_change.subject')
  18. ),
  19. last: have_attributes(
  20. to: include(account.user.email),
  21. subject: I18n.t('devise.mailer.reset_password_instructions.subject')
  22. )
  23. )
  24. expect(response).to redirect_to(admin_account_path(account.id))
  25. end
  26. end
  27. end