resets_controller_spec.rb 944 B

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