Sha256: 5d6c9ce9c550a303be03409f8fcc3d5c40008da1c9a0d3b69b82924ab717419f
Contents?: true
Size: 1.28 KB
Versions: 4
Compression:
Stored size: 1.28 KB
Contents
require 'rails_helper' RSpec.describe 'Send Password Reset Requests' do include_context 'with graphql query request' let(:user) { create(:user, :confirmed) } let(:email) { user.email } let(:redirect_url) { Faker::Internet.url } let(:query) do <<-GRAPHQL mutation { userSendResetPassword( email: "#{email}", redirectUrl: "#{redirect_url}" ) { authenticable { email } } } GRAPHQL end context 'when params are correct' do it 'sends password reset email' do expect { post_request }.to change(ActionMailer::Base.deliveries, :count).by(1) email = Nokogiri::HTML(ActionMailer::Base.deliveries.last.body.encoded) link = email.css('a').first # TODO: Move to feature spec expect do get link['href'] user.reload end.to change(user, :allow_password_change).from(false).to(true) end end context 'when user email is not found' do let(:email) { 'nothere@gmail.com' } before { post_request } it 'returns an error' do expect(json_response[:errors]).to contain_exactly( hash_including(message: 'User was not found or was not logged in.', extensions: { code: 'USER_ERROR' }) ) end end end
Version data entries
4 entries across 4 versions & 1 rubygems