graphql_devise 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,83 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe 'Resend confirmation' do
4
+ include_context 'with graphql query request'
5
+
6
+ let(:user) { create(:user, confirmed_at: nil) }
7
+ let(:email) { user.email }
8
+ let(:id) { user.id }
9
+ let(:redirect) { Faker::Internet.url }
10
+ let(:query) do
11
+ <<-GRAPHQL
12
+ mutation {
13
+ userResendConfirmation(
14
+ email:"#{email}",
15
+ redirectUrl:"#{redirect}"
16
+ ) {
17
+ message
18
+ authenticable {
19
+ id
20
+ email
21
+ }
22
+ }
23
+ }
24
+ GRAPHQL
25
+ end
26
+
27
+ context 'when params are correct' do
28
+ it 'sends an email to the user with confirmation url and returns a success message' do
29
+ expect { post_request }.to change(ActionMailer::Base.deliveries, :count).by(1)
30
+ expect(json_response[:data][:userResendConfirmation]).to include(
31
+ authenticable: {
32
+ id: id,
33
+ email: email
34
+ },
35
+ message: "You will receive an email with instructions for how to confirm your email address in a few minutes."
36
+ )
37
+
38
+ email = Nokogiri::HTML(ActionMailer::Base.deliveries.last.body.encoded)
39
+ link = email.css('a').first
40
+ confirm_link_msg_text = email.css('p')[1].inner_html
41
+ confirm_account_link_text = link.inner_html
42
+
43
+ expect(confirm_link_msg_text).to eq("You can confirm your account email through the link below:")
44
+ expect(confirm_account_link_text).to eq("Confirm my account")
45
+
46
+ # TODO: Move to feature spec
47
+ expect do
48
+ get link['href']
49
+ user.reload
50
+ end.to change(user, :confirmed_at).from(NilClass).to(ActiveSupport::TimeWithZone)
51
+ end
52
+
53
+ context 'when the user has already been confirmed' do
54
+ before { user.confirm }
55
+
56
+ it 'does *NOT* send an email and raises an error' do
57
+ expect { post_request }.to not_change(ActionMailer::Base.deliveries, :count)
58
+ expect(json_response[:data][:userResendConfirmation]).to be_nil
59
+ expect(json_response[:errors]).to contain_exactly(
60
+ hash_including(
61
+ message: "Email was already confirmed, please try signing in",
62
+ extensions: { code: 'USER_ERROR' }
63
+ )
64
+ )
65
+ end
66
+ end
67
+ end
68
+
69
+ context "when the email isn't in the system" do
70
+ let(:email) { 'nothere@gmail.com' }
71
+
72
+ it 'does *NOT* send an email and raises an error' do
73
+ expect { post_request }.to not_change(ActionMailer::Base.deliveries, :count)
74
+ expect(json_response[:data][:userResendConfirmation]).to be_nil
75
+ expect(json_response[:errors]).to contain_exactly(
76
+ hash_including(
77
+ message: "Unable to find user with email '#{email}'.",
78
+ extensions: { code: 'USER_ERROR' }
79
+ )
80
+ )
81
+ end
82
+ end
83
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql_devise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Celi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-10-30 00:00:00.000000000 Z
12
+ date: 2019-11-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: devise_token_auth
@@ -243,6 +243,9 @@ executables: []
243
243
  extensions: []
244
244
  extra_rdoc_files: []
245
245
  files:
246
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
247
+ - ".github/ISSUE_TEMPLATE/enhancement.md"
248
+ - ".github/ISSUE_TEMPLATE/question.md"
246
249
  - ".gitignore"
247
250
  - ".rspec"
248
251
  - ".rubocop.yml"
@@ -259,6 +262,7 @@ files:
259
262
  - app/graphql/graphql_devise/mutations/base.rb
260
263
  - app/graphql/graphql_devise/mutations/login.rb
261
264
  - app/graphql/graphql_devise/mutations/logout.rb
265
+ - app/graphql/graphql_devise/mutations/resend_confirmation.rb
262
266
  - app/graphql/graphql_devise/mutations/send_password_reset.rb
263
267
  - app/graphql/graphql_devise/mutations/sign_up.rb
264
268
  - app/graphql/graphql_devise/mutations/update_password.rb
@@ -343,11 +347,10 @@ files:
343
347
  - spec/dummy/config/initializers/devise.rb
344
348
  - spec/dummy/config/initializers/devise_token_auth.rb
345
349
  - spec/dummy/config/initializers/filter_parameter_logging.rb
350
+ - spec/dummy/config/initializers/i18n.rb
346
351
  - spec/dummy/config/initializers/inflections.rb
347
352
  - spec/dummy/config/initializers/mime_types.rb
348
353
  - spec/dummy/config/initializers/wrap_parameters.rb
349
- - spec/dummy/config/locales/devise.en.yml
350
- - spec/dummy/config/locales/en.yml
351
354
  - spec/dummy/config/master.key
352
355
  - spec/dummy/config/puma.rb
353
356
  - spec/dummy/config/routes.rb
@@ -374,6 +377,7 @@ files:
374
377
  - spec/rails_helper.rb
375
378
  - spec/requests/mutations/login_spec.rb
376
379
  - spec/requests/mutations/logout_spec.rb
380
+ - spec/requests/mutations/resend_confirmation_spec.rb
377
381
  - spec/requests/mutations/send_password_reset_spec.rb
378
382
  - spec/requests/mutations/sign_up_spec.rb
379
383
  - spec/requests/mutations/update_password_spec.rb
@@ -442,8 +446,6 @@ test_files:
442
446
  - spec/dummy/bin/rails
443
447
  - spec/dummy/config/secrets.yml
444
448
  - spec/dummy/config/routes.rb
445
- - spec/dummy/config/locales/en.yml
446
- - spec/dummy/config/locales/devise.en.yml
447
449
  - spec/dummy/config/environments/production.rb
448
450
  - spec/dummy/config/environments/development.rb
449
451
  - spec/dummy/config/environments/test.rb
@@ -460,6 +462,7 @@ test_files:
460
462
  - spec/dummy/config/initializers/mime_types.rb
461
463
  - spec/dummy/config/initializers/filter_parameter_logging.rb
462
464
  - spec/dummy/config/initializers/wrap_parameters.rb
465
+ - spec/dummy/config/initializers/i18n.rb
463
466
  - spec/dummy/config/initializers/devise.rb
464
467
  - spec/dummy/config/initializers/inflections.rb
465
468
  - spec/dummy/config/initializers/cors.rb
@@ -486,6 +489,7 @@ test_files:
486
489
  - spec/requests/mutations/send_password_reset_spec.rb
487
490
  - spec/requests/mutations/update_password_spec.rb
488
491
  - spec/requests/mutations/sign_up_spec.rb
492
+ - spec/requests/mutations/resend_confirmation_spec.rb
489
493
  - spec/requests/queries/confirm_account_spec.rb
490
494
  - spec/requests/queries/check_password_token_spec.rb
491
495
  - spec/support/factory_bot.rb
@@ -1,65 +0,0 @@
1
- # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2
-
3
- en:
4
- devise:
5
- confirmations:
6
- confirmed: "Your email address has been successfully confirmed."
7
- send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
8
- send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
9
- failure:
10
- already_authenticated: "You are already signed in."
11
- inactive: "Your account is not activated yet."
12
- invalid: "Invalid %{authentication_keys} or password."
13
- locked: "Your account is locked."
14
- last_attempt: "You have one more attempt before your account is locked."
15
- not_found_in_database: "Invalid %{authentication_keys} or password."
16
- timeout: "Your session expired. Please sign in again to continue."
17
- unauthenticated: "You need to sign in or sign up before continuing."
18
- unconfirmed: "You have to confirm your email address before continuing."
19
- mailer:
20
- confirmation_instructions:
21
- subject: "Confirmation instructions"
22
- reset_password_instructions:
23
- subject: "Reset password instructions"
24
- unlock_instructions:
25
- subject: "Unlock instructions"
26
- email_changed:
27
- subject: "Email Changed"
28
- password_change:
29
- subject: "Password Changed"
30
- omniauth_callbacks:
31
- failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
32
- success: "Successfully authenticated from %{kind} account."
33
- passwords:
34
- no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
35
- send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
36
- send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
37
- updated: "Your password has been changed successfully. You are now signed in."
38
- updated_not_active: "Your password has been changed successfully."
39
- registrations:
40
- destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
41
- signed_up: "Welcome! You have signed up successfully."
42
- signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
43
- signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
44
- signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
45
- update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
46
- updated: "Your account has been updated successfully."
47
- updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again"
48
- sessions:
49
- signed_in: "Signed in successfully."
50
- signed_out: "Signed out successfully."
51
- already_signed_out: "Signed out successfully."
52
- unlocks:
53
- send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
54
- send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
55
- unlocked: "Your account has been unlocked successfully. Please sign in to continue."
56
- errors:
57
- messages:
58
- already_confirmed: "was already confirmed, please try signing in"
59
- confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
60
- expired: "has expired, please request a new one"
61
- not_found: "not found"
62
- not_locked: "was not locked"
63
- not_saved:
64
- one: "1 error prohibited this %{resource} from being saved:"
65
- other: "%{count} errors prohibited this %{resource} from being saved:"
@@ -1,33 +0,0 @@
1
- # Files in the config/locales directory are used for internationalization
2
- # and are automatically loaded by Rails. If you want to use locales other
3
- # than English, add the necessary files in this directory.
4
- #
5
- # To use the locales, use `I18n.t`:
6
- #
7
- # I18n.t 'hello'
8
- #
9
- # In views, this is aliased to just `t`:
10
- #
11
- # <%= t('hello') %>
12
- #
13
- # To use a different locale, set it with `I18n.locale`:
14
- #
15
- # I18n.locale = :es
16
- #
17
- # This would use the information in config/locales/es.yml.
18
- #
19
- # The following keys must be escaped otherwise they will not be retrieved by
20
- # the default I18n backend:
21
- #
22
- # true, false, on, off, yes, no
23
- #
24
- # Instead, surround them with single quotes.
25
- #
26
- # en:
27
- # 'true': 'foo'
28
- #
29
- # To learn more, please read the Rails Internationalization guide
30
- # available at http://guides.rubyonrails.org/i18n.html.
31
-
32
- en:
33
- hello_world: "Hello world"