2017-05-29 16:10:50 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Auth::PasswordsController, type: :controller do
|
2017-08-03 15:45:45 +00:00
|
|
|
include Devise::Test::ControllerHelpers
|
|
|
|
|
2017-05-29 16:10:50 +00:00
|
|
|
describe 'GET #new' do
|
|
|
|
it 'returns http success' do
|
|
|
|
@request.env['devise.mapping'] = Devise.mappings[:user]
|
|
|
|
get :new
|
2018-04-21 19:35:07 +00:00
|
|
|
expect(response).to have_http_status(200)
|
2017-05-29 16:10:50 +00:00
|
|
|
end
|
|
|
|
end
|
2017-08-03 15:45:45 +00:00
|
|
|
|
|
|
|
describe 'GET #edit' do
|
|
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
request.env['devise.mapping'] = Devise.mappings[:user]
|
|
|
|
@token = user.send_reset_password_instructions
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with valid reset_password_token' do
|
|
|
|
it 'returns http success' do
|
|
|
|
get :edit, params: { reset_password_token: @token }
|
2018-04-21 19:35:07 +00:00
|
|
|
expect(response).to have_http_status(200)
|
2017-08-03 15:45:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with invalid reset_password_token' do
|
|
|
|
it 'redirects to #new' do
|
|
|
|
get :edit, params: { reset_password_token: 'some_invalid_value' }
|
|
|
|
expect(response).to redirect_to subject.new_password_path(subject.send(:resource_name))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-05-29 16:10:50 +00:00
|
|
|
end
|