graphql_devise 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +25 -15
- data/CHANGELOG.md +22 -0
- data/README.md +94 -14
- data/config/routes.rb +11 -0
- data/lib/graphql_devise.rb +1 -0
- data/lib/graphql_devise/concerns/controller_methods.rb +23 -0
- data/lib/graphql_devise/mutations/login.rb +4 -1
- data/lib/graphql_devise/mutations/resend_confirmation.rb +4 -1
- data/lib/graphql_devise/mutations/send_password_reset.rb +3 -2
- data/lib/graphql_devise/mutations/sign_up.rb +0 -4
- data/lib/graphql_devise/rails/routes.rb +0 -9
- data/{app/graphql → lib}/graphql_devise/schema.rb +0 -1
- data/lib/graphql_devise/version.rb +1 -1
- data/spec/dummy/log/test.log +43606 -0
- data/spec/requests/mutations/login_spec.rb +14 -2
- data/spec/requests/mutations/resend_confirmation_spec.rb +24 -9
- data/spec/requests/mutations/send_password_reset_spec.rb +9 -1
- data/spec/requests/mutations/sign_up_spec.rb +10 -0
- metadata +4 -3
@@ -6,12 +6,13 @@ RSpec.describe 'Login Requests' do
|
|
6
6
|
let(:password) { '12345678' }
|
7
7
|
|
8
8
|
context 'when using the user model' do
|
9
|
-
let(:user) { create(:user, :confirmed, password: password) }
|
9
|
+
let!(:user) { create(:user, :confirmed, password: password, email: 'vvega@wallaceinc.com') }
|
10
|
+
let(:email) { user.email }
|
10
11
|
let(:query) do
|
11
12
|
<<-GRAPHQL
|
12
13
|
mutation {
|
13
14
|
userLogin(
|
14
|
-
email: "#{
|
15
|
+
email: "#{email}",
|
15
16
|
password: "#{password}"
|
16
17
|
) {
|
17
18
|
user { email name signInCount }
|
@@ -40,6 +41,17 @@ RSpec.describe 'Login Requests' do
|
|
40
41
|
)
|
41
42
|
expect(json_response[:errors]).to be_nil
|
42
43
|
end
|
44
|
+
|
45
|
+
context 'when email address uses different casing' do
|
46
|
+
let(:email) { 'vVeGa@wallaceinc.com' }
|
47
|
+
|
48
|
+
it 'honors devise configuration for case insensitive fields' do
|
49
|
+
expect(response).to include_auth_headers
|
50
|
+
expect(json_response[:data][:userLogin]).to include(
|
51
|
+
user: { email: user.email, name: user.name, signInCount: 1 }
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
43
55
|
end
|
44
56
|
|
45
57
|
context 'when credentials are invalid' do
|
@@ -3,7 +3,7 @@ require 'rails_helper'
|
|
3
3
|
RSpec.describe 'Resend confirmation' do
|
4
4
|
include_context 'with graphql query request'
|
5
5
|
|
6
|
-
let(:user)
|
6
|
+
let!(:user) { create(:user, confirmed_at: nil, email: 'mwallace@wallaceinc.com') }
|
7
7
|
let(:email) { user.email }
|
8
8
|
let(:id) { user.id }
|
9
9
|
let(:redirect) { Faker::Internet.url }
|
@@ -28,20 +28,20 @@ RSpec.describe 'Resend confirmation' do
|
|
28
28
|
it 'sends an email to the user with confirmation url and returns a success message' do
|
29
29
|
expect { post_request }.to change(ActionMailer::Base.deliveries, :count).by(1)
|
30
30
|
expect(json_response[:data][:userResendConfirmation]).to include(
|
31
|
+
message: 'You will receive an email with instructions for how to confirm your email address in a few minutes.',
|
31
32
|
authenticatable: {
|
32
|
-
id:
|
33
|
+
id: id,
|
33
34
|
email: email
|
34
|
-
}
|
35
|
-
message: "You will receive an email with instructions for how to confirm your email address in a few minutes."
|
35
|
+
}
|
36
36
|
)
|
37
|
-
|
37
|
+
|
38
38
|
email = Nokogiri::HTML(ActionMailer::Base.deliveries.last.body.encoded)
|
39
39
|
link = email.css('a').first
|
40
40
|
confirm_link_msg_text = email.css('p')[1].inner_html
|
41
41
|
confirm_account_link_text = link.inner_html
|
42
42
|
|
43
|
-
expect(confirm_link_msg_text).to eq(
|
44
|
-
expect(confirm_account_link_text).to eq(
|
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
45
|
|
46
46
|
# TODO: Move to feature spec
|
47
47
|
expect do
|
@@ -50,6 +50,21 @@ RSpec.describe 'Resend confirmation' do
|
|
50
50
|
end.to change(user, :confirmed_at).from(NilClass).to(ActiveSupport::TimeWithZone)
|
51
51
|
end
|
52
52
|
|
53
|
+
context 'when email address uses different casing' do
|
54
|
+
let(:email) { 'mWallace@wallaceinc.com' }
|
55
|
+
|
56
|
+
it 'honors devise configuration for case insensitive fields' do
|
57
|
+
expect { post_request }.to change(ActionMailer::Base.deliveries, :count).by(1)
|
58
|
+
expect(json_response[:data][:userResendConfirmation]).to include(
|
59
|
+
message: 'You will receive an email with instructions for how to confirm your email address in a few minutes.',
|
60
|
+
authenticatable: {
|
61
|
+
id: id,
|
62
|
+
email: user.email
|
63
|
+
}
|
64
|
+
)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
53
68
|
context 'when the user has already been confirmed' do
|
54
69
|
before { user.confirm }
|
55
70
|
|
@@ -58,7 +73,7 @@ RSpec.describe 'Resend confirmation' do
|
|
58
73
|
expect(json_response[:data][:userResendConfirmation]).to be_nil
|
59
74
|
expect(json_response[:errors]).to contain_exactly(
|
60
75
|
hash_including(
|
61
|
-
message:
|
76
|
+
message: 'Email was already confirmed, please try signing in',
|
62
77
|
extensions: { code: 'USER_ERROR' }
|
63
78
|
)
|
64
79
|
)
|
@@ -74,7 +89,7 @@ RSpec.describe 'Resend confirmation' do
|
|
74
89
|
expect(json_response[:data][:userResendConfirmation]).to be_nil
|
75
90
|
expect(json_response[:errors]).to contain_exactly(
|
76
91
|
hash_including(
|
77
|
-
message:
|
92
|
+
message: "Unable to find user with email '#{email}'.",
|
78
93
|
extensions: { code: 'USER_ERROR' }
|
79
94
|
)
|
80
95
|
)
|
@@ -3,7 +3,7 @@ require 'rails_helper'
|
|
3
3
|
RSpec.describe 'Send Password Reset Requests' do
|
4
4
|
include_context 'with graphql query request'
|
5
5
|
|
6
|
-
let(:user)
|
6
|
+
let!(:user) { create(:user, :confirmed, email: 'jwinnfield@wallaceinc.com') }
|
7
7
|
let(:email) { user.email }
|
8
8
|
let(:redirect_url) { Faker::Internet.url }
|
9
9
|
let(:query) do
|
@@ -36,6 +36,14 @@ RSpec.describe 'Send Password Reset Requests' do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
context 'when email address uses different casing' do
|
40
|
+
let(:email) { 'jWinnfield@wallaceinc.com' }
|
41
|
+
|
42
|
+
it 'honors devise configuration for case insensitive fields' do
|
43
|
+
expect { post_request }.to change(ActionMailer::Base.deliveries, :count).by(1)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
39
47
|
context 'when user email is not found' do
|
40
48
|
let(:email) { 'nothere@gmail.com' }
|
41
49
|
|
@@ -55,6 +55,16 @@ RSpec.describe 'Sign Up process' do
|
|
55
55
|
user.reload
|
56
56
|
end.to change { user.active_for_authentication? }.to(true)
|
57
57
|
end
|
58
|
+
|
59
|
+
context 'when email address uses different casing' do
|
60
|
+
let(:email) { 'miaWallace@wallaceinc.com' }
|
61
|
+
|
62
|
+
it 'honors devise configuration for case insensitive fields' do
|
63
|
+
expect { post_request }.to change(ActionMailer::Base.deliveries, :count).by(1)
|
64
|
+
expect(User.last.email).to eq('miawallace@wallaceinc.com')
|
65
|
+
expect(json_response[:data][:userSignUp]).to include(user: { email: 'miawallace@wallaceinc.com', name: name })
|
66
|
+
end
|
67
|
+
end
|
58
68
|
end
|
59
69
|
|
60
70
|
context 'when required params are missing' do
|
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.11.
|
4
|
+
version: 0.11.1
|
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: 2020-
|
12
|
+
date: 2020-05-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: devise_token_auth
|
@@ -273,7 +273,6 @@ files:
|
|
273
273
|
- app/controllers/graphql_devise/application_controller.rb
|
274
274
|
- app/controllers/graphql_devise/concerns/set_user_by_token.rb
|
275
275
|
- app/controllers/graphql_devise/graphql_controller.rb
|
276
|
-
- app/graphql/graphql_devise/schema.rb
|
277
276
|
- app/helpers/graphql_devise/application_helper.rb
|
278
277
|
- app/helpers/graphql_devise/mailer_helper.rb
|
279
278
|
- app/models/graphql_devise/concerns/model.rb
|
@@ -284,6 +283,7 @@ files:
|
|
284
283
|
- bin/rails
|
285
284
|
- bin/setup
|
286
285
|
- config/locales/en.yml
|
286
|
+
- config/routes.rb
|
287
287
|
- graphql_devise.gemspec
|
288
288
|
- lib/generators/graphql_devise/install_generator.rb
|
289
289
|
- lib/graphql_devise.rb
|
@@ -323,6 +323,7 @@ files:
|
|
323
323
|
- lib/graphql_devise/resolvers/check_password_token.rb
|
324
324
|
- lib/graphql_devise/resolvers/confirm_account.rb
|
325
325
|
- lib/graphql_devise/resolvers/dummy.rb
|
326
|
+
- lib/graphql_devise/schema.rb
|
326
327
|
- lib/graphql_devise/types/authenticatable_type.rb
|
327
328
|
- lib/graphql_devise/types/credential_type.rb
|
328
329
|
- lib/graphql_devise/types/mutation_type.rb
|