signup_resend_spec.rb 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Gql::Mutations::User::SignupResend, type: :graphql do
  4. context 'when resending signup verification email' do
  5. let(:user) { create(:user, verified: false) }
  6. let(:query) do
  7. <<~QUERY
  8. mutation userSignupResend($email: String!) {
  9. userSignupResend(email: $email) {
  10. success
  11. errors {
  12. message
  13. }
  14. }
  15. }
  16. QUERY
  17. end
  18. let(:variables) do
  19. {
  20. email: user.email,
  21. }
  22. end
  23. context 'with disabled user signup' do
  24. before do
  25. Setting.set('user_create_account', false)
  26. end
  27. it 'raises an error' do
  28. gql.execute(query, variables: variables)
  29. expect(gql.result.error_message).to eq 'This feature is not enabled.'
  30. end
  31. end
  32. context 'with valid user email address' do
  33. it 'returns success' do
  34. gql.execute(query, variables: variables)
  35. expect(gql.result.data).to eq({ 'success' => true, 'errors' => nil })
  36. end
  37. end
  38. context 'with invalid user email address' do
  39. let(:variables) do
  40. {
  41. email: 'foobar@example.tld',
  42. }
  43. end
  44. it 'returns success' do
  45. gql.execute(query, variables: variables)
  46. expect(gql.result.data).to eq({ 'success' => true, 'errors' => nil })
  47. end
  48. end
  49. end
  50. end