Sha256: 7f3515f5a54d56bc871a1f6d91fc5728b904da8e81a53401b1342573ee4cbaf7
Contents?: true
Size: 1.83 KB
Versions: 6
Compression:
Stored size: 1.83 KB
Contents
# frozen_string_literal: true require 'rails_helper' RSpec.describe 'Additional Mutations' do include_context 'with graphql query request' let(:name) { Faker::Name.name } let(:password) { Faker::Internet.password } let(:password_confirmation) { password } let(:email) { Faker::Internet.email } let(:redirect) { Faker::Internet.url } context 'when using the user model' do let(:query) do <<-GRAPHQL mutation { registerConfirmedUser( email: "#{email}", name: "#{name}", password: "#{password}", passwordConfirmation: "#{password_confirmation}" ) { user { email name } } } GRAPHQL end context 'when params are correct' do it 'creates a new resource that is already confirmed' do expect { post_request }.to( change(User, :count).by(1) .and(not_change(ActionMailer::Base.deliveries, :count)) ) user = User.last expect(user).to be_confirmed expect(json_response[:data][:registerConfirmedUser]).to include( user: { email: email, name: name } ) end end context 'when params are incorrect' do let(:password_confirmation) { 'not the same' } it 'returns descriptive errors' do expect { post_request }.to not_change(User, :count) expect(json_response[:errors]).to contain_exactly( hash_including( message: 'Custom registration failed', extensions: { code: 'USER_ERROR', detailed_errors: ["Password confirmation doesn't match Password"] } ) ) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems