logo

mastofe

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

passwords_controller_spec.rb (1057B)


  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe Auth::PasswordsController, type: :controller do
  4. include Devise::Test::ControllerHelpers
  5. describe 'GET #new' do
  6. it 'returns http success' do
  7. @request.env['devise.mapping'] = Devise.mappings[:user]
  8. get :new
  9. expect(response).to have_http_status(:success)
  10. end
  11. end
  12. describe 'GET #edit' do
  13. let(:user) { Fabricate(:user) }
  14. before do
  15. request.env['devise.mapping'] = Devise.mappings[:user]
  16. @token = user.send_reset_password_instructions
  17. end
  18. context 'with valid reset_password_token' do
  19. it 'returns http success' do
  20. get :edit, params: { reset_password_token: @token }
  21. expect(response).to have_http_status(:success)
  22. end
  23. end
  24. context 'with invalid reset_password_token' do
  25. it 'redirects to #new' do
  26. get :edit, params: { reset_password_token: 'some_invalid_value' }
  27. expect(response).to redirect_to subject.new_password_path(subject.send(:resource_name))
  28. end
  29. end
  30. end
  31. end