logo

mastofe

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

change_email_controller_spec.rb (1281B)


  1. require 'rails_helper'
  2. RSpec.describe Admin::ChangeEmailsController, type: :controller do
  3. render_views
  4. let(:admin) { Fabricate(:user, admin: true) }
  5. before do
  6. sign_in admin
  7. end
  8. describe "GET #show" do
  9. it "returns http success" do
  10. account = Fabricate(:account)
  11. user = Fabricate(:user, account: account)
  12. get :show, params: { account_id: account.id }
  13. expect(response).to have_http_status(:success)
  14. end
  15. end
  16. describe "GET #update" do
  17. before do
  18. allow(UserMailer).to receive(:confirmation_instructions).and_return(double('email', deliver_later: nil))
  19. end
  20. it "returns http success" do
  21. account = Fabricate(:account)
  22. user = Fabricate(:user, account: account)
  23. previous_email = user.email
  24. post :update, params: { account_id: account.id, user: { unconfirmed_email: 'test@example.com' } }
  25. user.reload
  26. expect(user.email).to eq previous_email
  27. expect(user.unconfirmed_email).to eq 'test@example.com'
  28. expect(user.confirmation_token).not_to be_nil
  29. expect(UserMailer).to have_received(:confirmation_instructions).with(user, user.confirmation_token, { to: 'test@example.com' })
  30. expect(response).to redirect_to(admin_account_path(account.id))
  31. end
  32. end
  33. end