graphql_devise 1.0.0 → 1.1.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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +28 -28
- data/Appraisals +6 -15
- data/CHANGELOG.md +22 -0
- data/README.md +1 -1
- data/graphql_devise.gemspec +2 -2
- data/lib/generators/graphql_devise/install_generator.rb +1 -1
- data/lib/graphql_devise/concerns/additional_controller_methods.rb +1 -1
- data/lib/graphql_devise/concerns/controller_methods.rb +13 -2
- data/lib/graphql_devise/mutations/confirm_registration_with_token.rb +1 -1
- data/lib/graphql_devise/mutations/login.rb +1 -1
- data/lib/graphql_devise/mutations/register.rb +1 -1
- data/lib/graphql_devise/mutations/update_password_with_token.rb +1 -1
- data/lib/graphql_devise/version.rb +1 -1
- data/lib/graphql_devise.rb +1 -1
- data/spec/dummy/app/controllers/api/v1/graphql_controller.rb +1 -0
- data/spec/dummy/app/graphql/types/query_type.rb +5 -1
- data/spec/generators/graphql_devise/install_generator_spec.rb +2 -2
- data/spec/requests/mutations/login_spec.rb +34 -0
- data/spec/requests/user_controller_spec.rb +20 -0
- data/spec/services/resource_loader_spec.rb +39 -0
- data/spec/spec_helper.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7325ecea583beb248fe28de9d2421121ddbff9776178bca006d16880b39867df
|
|
4
|
+
data.tar.gz: 7005c49c45623fa02a7f6ebd1f72d893890264564ad91ae2628814c99d811a24
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: da309b6629078b7e83ac491958b613ac501be53f9166de18f0bb5df8256e4d906012454770fc76bca2c5c4b0c2b6803dec01ad58a0c8553ccbd182033f9daf6e
|
|
7
|
+
data.tar.gz: 5109daf3bd8103f7c70e723ed7f096e5e4b3c1eb1ebe36d02f3b7d9bea693dcc0eaf41a7f9147d1588cb7a56cd7ecccfeff1c9ecec20c9ea802ceba7794665c2
|
data/.circleci/config.yml
CHANGED
|
@@ -69,35 +69,11 @@ workflows:
|
|
|
69
69
|
- gemfiles/rails6.1_graphql1.12.gemfile
|
|
70
70
|
- gemfiles/rails6.1_graphql1.13.gemfile
|
|
71
71
|
- gemfiles/rails6.1_graphql2.0.gemfile
|
|
72
|
+
- gemfiles/rails7.0_graphql1.11.gemfile
|
|
73
|
+
- gemfiles/rails7.0_graphql1.12.gemfile
|
|
74
|
+
- gemfiles/rails7.0_graphql1.13.gemfile
|
|
75
|
+
- gemfiles/rails7.0_graphql2.0.gemfile
|
|
72
76
|
exclude:
|
|
73
|
-
- ruby-version: '2.2'
|
|
74
|
-
gemfile: gemfiles/rails6.0_graphql1.11.gemfile
|
|
75
|
-
- ruby-version: '2.2'
|
|
76
|
-
gemfile: gemfiles/rails6.0_graphql1.12.gemfile
|
|
77
|
-
- ruby-version: '2.2'
|
|
78
|
-
gemfile: gemfiles/rails6.0_graphql1.13.gemfile
|
|
79
|
-
- ruby-version: '2.2'
|
|
80
|
-
gemfile: gemfiles/rails6.1_graphql1.11.gemfile
|
|
81
|
-
- ruby-version: '2.2'
|
|
82
|
-
gemfile: gemfiles/rails6.1_graphql1.12.gemfile
|
|
83
|
-
- ruby-version: '2.2'
|
|
84
|
-
gemfile: gemfiles/rails6.1_graphql1.13.gemfile
|
|
85
|
-
- ruby-version: '2.2'
|
|
86
|
-
gemfile: gemfiles/rails6.1_graphql2.0.gemfile
|
|
87
|
-
- ruby-version: '2.3'
|
|
88
|
-
gemfile: gemfiles/rails6.0_graphql1.11.gemfile
|
|
89
|
-
- ruby-version: '2.3'
|
|
90
|
-
gemfile: gemfiles/rails6.0_graphql1.12.gemfile
|
|
91
|
-
- ruby-version: '2.3'
|
|
92
|
-
gemfile: gemfiles/rails6.0_graphql1.13.gemfile
|
|
93
|
-
- ruby-version: '2.3'
|
|
94
|
-
gemfile: gemfiles/rails6.1_graphql1.11.gemfile
|
|
95
|
-
- ruby-version: '2.3'
|
|
96
|
-
gemfile: gemfiles/rails6.1_graphql1.12.gemfile
|
|
97
|
-
- ruby-version: '2.3'
|
|
98
|
-
gemfile: gemfiles/rails6.1_graphql1.13.gemfile
|
|
99
|
-
- ruby-version: '2.3'
|
|
100
|
-
gemfile: gemfiles/rails6.1_graphql2.0.gemfile
|
|
101
77
|
- ruby-version: '2.4'
|
|
102
78
|
gemfile: gemfiles/rails6.0_graphql1.11.gemfile
|
|
103
79
|
- ruby-version: '2.4'
|
|
@@ -112,10 +88,34 @@ workflows:
|
|
|
112
88
|
gemfile: gemfiles/rails6.1_graphql1.13.gemfile
|
|
113
89
|
- ruby-version: '2.4'
|
|
114
90
|
gemfile: gemfiles/rails6.1_graphql2.0.gemfile
|
|
91
|
+
- ruby-version: '2.4'
|
|
92
|
+
gemfile: gemfiles/rails7.0_graphql1.11.gemfile
|
|
93
|
+
- ruby-version: '2.4'
|
|
94
|
+
gemfile: gemfiles/rails7.0_graphql1.12.gemfile
|
|
95
|
+
- ruby-version: '2.4'
|
|
96
|
+
gemfile: gemfiles/rails7.0_graphql1.13.gemfile
|
|
97
|
+
- ruby-version: '2.4'
|
|
98
|
+
gemfile: gemfiles/rails7.0_graphql2.0.gemfile
|
|
99
|
+
- ruby-version: '2.5'
|
|
100
|
+
gemfile: gemfiles/rails7.0_graphql1.11.gemfile
|
|
115
101
|
- ruby-version: '2.5'
|
|
116
102
|
gemfile: gemfiles/rails6.0_graphql1.13.gemfile
|
|
117
103
|
- ruby-version: '2.5'
|
|
118
104
|
gemfile: gemfiles/rails6.1_graphql1.13.gemfile
|
|
105
|
+
- ruby-version: '2.5'
|
|
106
|
+
gemfile: gemfiles/rails7.0_graphql1.12.gemfile
|
|
107
|
+
- ruby-version: '2.5'
|
|
108
|
+
gemfile: gemfiles/rails7.0_graphql1.13.gemfile
|
|
109
|
+
- ruby-version: '2.5'
|
|
110
|
+
gemfile: gemfiles/rails7.0_graphql2.0.gemfile
|
|
111
|
+
- ruby-version: '2.6'
|
|
112
|
+
gemfile: gemfiles/rails7.0_graphql1.11.gemfile
|
|
113
|
+
- ruby-version: '2.6'
|
|
114
|
+
gemfile: gemfiles/rails7.0_graphql1.12.gemfile
|
|
115
|
+
- ruby-version: '2.6'
|
|
116
|
+
gemfile: gemfiles/rails7.0_graphql1.13.gemfile
|
|
117
|
+
- ruby-version: '2.6'
|
|
118
|
+
gemfile: gemfiles/rails7.0_graphql2.0.gemfile
|
|
119
119
|
- ruby-version: '2.7'
|
|
120
120
|
gemfile: gemfiles/rails4.2_graphql1.8.gemfile
|
|
121
121
|
- ruby-version: '3.0'
|
data/Appraisals
CHANGED
|
@@ -145,20 +145,11 @@ appraise 'rails6.1-graphql2.0' do
|
|
|
145
145
|
gem 'graphql', '~> 2.0.1'
|
|
146
146
|
end
|
|
147
147
|
|
|
148
|
-
appraise 'rails7.0-graphql1.10' do
|
|
149
|
-
gem 'sassc-rails'
|
|
150
|
-
gem 'sqlite3', '~> 1.4'
|
|
151
|
-
gem 'devise', '>= 4.7'
|
|
152
|
-
gem 'devise_token_auth', git: 'https://github.com/lynndylanhurley/devise_token_auth', branch: 'master'
|
|
153
|
-
gem 'rails', git: 'https://github.com/rails/rails', branch: '7-0-stable'
|
|
154
|
-
gem 'graphql', '~> 1.10.0'
|
|
155
|
-
end
|
|
156
|
-
|
|
157
148
|
appraise 'rails7.0-graphql1.11' do
|
|
158
149
|
gem 'sassc-rails'
|
|
159
150
|
gem 'sqlite3', '~> 1.4'
|
|
160
151
|
gem 'devise', '>= 4.7'
|
|
161
|
-
gem 'devise_token_auth',
|
|
152
|
+
gem 'devise_token_auth', '>= 1.2.1'
|
|
162
153
|
gem 'rails', git: 'https://github.com/rails/rails', branch: '7-0-stable'
|
|
163
154
|
gem 'graphql', '~> 1.11.0'
|
|
164
155
|
end
|
|
@@ -167,7 +158,7 @@ appraise 'rails7.0-graphql1.12' do
|
|
|
167
158
|
gem 'sassc-rails'
|
|
168
159
|
gem 'sqlite3', '~> 1.4'
|
|
169
160
|
gem 'devise', '>= 4.7'
|
|
170
|
-
gem 'devise_token_auth',
|
|
161
|
+
gem 'devise_token_auth', '>= 1.2.1'
|
|
171
162
|
gem 'rails', git: 'https://github.com/rails/rails', branch: '7-0-stable'
|
|
172
163
|
gem 'graphql', '~> 1.12.0'
|
|
173
164
|
end
|
|
@@ -176,16 +167,16 @@ appraise 'rails7.0-graphql1.13' do
|
|
|
176
167
|
gem 'sassc-rails'
|
|
177
168
|
gem 'sqlite3', '~> 1.4'
|
|
178
169
|
gem 'devise', '>= 4.7'
|
|
179
|
-
gem 'devise_token_auth',
|
|
170
|
+
gem 'devise_token_auth', '>= 1.2.1'
|
|
180
171
|
gem 'rails', git: 'https://github.com/rails/rails', branch: '7-0-stable'
|
|
181
172
|
gem 'graphql', '~> 1.13.0'
|
|
182
173
|
end
|
|
183
174
|
|
|
184
|
-
appraise 'rails7.0-
|
|
175
|
+
appraise 'rails7.0-graphql2.0' do
|
|
185
176
|
gem 'sassc-rails'
|
|
186
177
|
gem 'sqlite3', '~> 1.4'
|
|
187
|
-
gem 'devise_token_auth',
|
|
178
|
+
gem 'devise_token_auth', '>= 1.2.1'
|
|
188
179
|
gem 'devise', '>= 4.7'
|
|
189
180
|
gem 'rails', git: 'https://github.com/rails/rails', branch: '7-0-stable'
|
|
190
|
-
gem 'graphql',
|
|
181
|
+
gem 'graphql', '~> 2.0.1'
|
|
191
182
|
end
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [v1.1.0](https://github.com/graphql-devise/graphql_devise/tree/v1.1.0) (2022-09-15)
|
|
4
|
+
|
|
5
|
+
[Full Changelog](https://github.com/graphql-devise/graphql_devise/compare/v1.0.1...v1.1.0)
|
|
6
|
+
|
|
7
|
+
**Implemented enhancements:**
|
|
8
|
+
|
|
9
|
+
- Support Rails 7 [\#241](https://github.com/graphql-devise/graphql_devise/pull/241) ([mcelicalderon](https://github.com/mcelicalderon))
|
|
10
|
+
|
|
11
|
+
**Merged pull requests:**
|
|
12
|
+
|
|
13
|
+
- Fix typo in README file. [\#238](https://github.com/graphql-devise/graphql_devise/pull/238) ([MathiasPfeil](https://github.com/MathiasPfeil))
|
|
14
|
+
|
|
15
|
+
## [v1.0.1](https://github.com/graphql-devise/graphql_devise/tree/v1.0.1) (2022-08-15)
|
|
16
|
+
|
|
17
|
+
[Full Changelog](https://github.com/graphql-devise/graphql_devise/compare/v1.0.0...v1.0.1)
|
|
18
|
+
|
|
19
|
+
**Fixed bugs:**
|
|
20
|
+
|
|
21
|
+
- A class must be provided when mounting a model. String values are no longer supported [\#235](https://github.com/graphql-devise/graphql_devise/issues/235)
|
|
22
|
+
- Use the class itself in the route generator instead of a string representation [\#236](https://github.com/graphql-devise/graphql_devise/pull/236) ([whotwagner](https://github.com/whotwagner))
|
|
23
|
+
- Honor dta auth cookie when using the schema plugin in a main rails project route [\#233](https://github.com/graphql-devise/graphql_devise/pull/233) ([00dav00](https://github.com/00dav00))
|
|
24
|
+
|
|
3
25
|
## [v1.0.0](https://github.com/graphql-devise/graphql_devise/tree/v1.0.0) (2022-08-04)
|
|
4
26
|
|
|
5
27
|
[Full Changelog](https://github.com/graphql-devise/graphql_devise/compare/v0.18.2...v1.0.0)
|
data/README.md
CHANGED
|
@@ -176,7 +176,7 @@ options go [here](#available-mount-options)
|
|
|
176
176
|
### Mounting Operations In an Existing Schema
|
|
177
177
|
|
|
178
178
|
Starting with `v0.12.0` you can mount the GQL operations provided by this gem into an
|
|
179
|
-
existing schema in
|
|
179
|
+
existing schema in your app.
|
|
180
180
|
|
|
181
181
|
```ruby
|
|
182
182
|
# app/graphql/dummy_schema.rb
|
data/graphql_devise.gemspec
CHANGED
|
@@ -29,11 +29,11 @@ Gem::Specification.new do |spec|
|
|
|
29
29
|
|
|
30
30
|
spec.add_dependency 'devise_token_auth', '>= 0.1.43', '< 2.0'
|
|
31
31
|
spec.add_dependency 'graphql', '>= 1.8', '< 2.1'
|
|
32
|
-
spec.add_dependency 'rails', '>= 4.2', '<
|
|
32
|
+
spec.add_dependency 'rails', '>= 4.2', '< 7.1'
|
|
33
33
|
spec.add_dependency 'zeitwerk'
|
|
34
34
|
|
|
35
35
|
spec.add_development_dependency 'appraisal'
|
|
36
|
-
spec.add_development_dependency '
|
|
36
|
+
spec.add_development_dependency 'coveralls_reborn'
|
|
37
37
|
spec.add_development_dependency 'factory_bot'
|
|
38
38
|
spec.add_development_dependency 'faker'
|
|
39
39
|
spec.add_development_dependency 'generator_spec'
|
|
@@ -38,7 +38,7 @@ module GraphqlDevise
|
|
|
38
38
|
if options['mount'] != 'separate_route'
|
|
39
39
|
gsub_file(routes_file, /^\s+#{Regexp.escape(dta_route + "\n")}/i, '')
|
|
40
40
|
else
|
|
41
|
-
gem_route = "mount_graphql_devise_for
|
|
41
|
+
gem_route = "mount_graphql_devise_for #{user_class}, at: '#{mount_path}'"
|
|
42
42
|
|
|
43
43
|
if file_contains_str?(routes_file, gem_route)
|
|
44
44
|
gsub_file(routes_file, /^\s+#{Regexp.escape(dta_route + "\n")}/i, '')
|
|
@@ -37,7 +37,7 @@ module GraphqlDevise
|
|
|
37
37
|
|
|
38
38
|
def build_redirect_headers(access_token, client, redirect_header_options = {})
|
|
39
39
|
{
|
|
40
|
-
DeviseTokenAuth.headers_names[:
|
|
40
|
+
DeviseTokenAuth.headers_names[:'access-token'] => access_token,
|
|
41
41
|
DeviseTokenAuth.headers_names[:client] => client,
|
|
42
42
|
:config => params[:config],
|
|
43
43
|
:client_id => client,
|
|
@@ -66,9 +66,20 @@ module GraphqlDevise
|
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
def
|
|
69
|
+
def generate_auth_headers(resource)
|
|
70
70
|
auth_headers = resource.create_new_auth_token
|
|
71
|
-
|
|
71
|
+
controller.resource = resource
|
|
72
|
+
access_token_name = DeviseTokenAuth.headers_names[:'access-token']
|
|
73
|
+
client_name = DeviseTokenAuth.headers_names[:'client']
|
|
74
|
+
|
|
75
|
+
# NOTE: Depending on the DTA version, the token will be an object or nil
|
|
76
|
+
if controller.token
|
|
77
|
+
controller.token.client = auth_headers[client_name]
|
|
78
|
+
controller.token.token = auth_headers[access_token_name]
|
|
79
|
+
else
|
|
80
|
+
controller.client_id = auth_headers[client_name]
|
|
81
|
+
controller.token = auth_headers[access_token_name]
|
|
82
|
+
end
|
|
72
83
|
|
|
73
84
|
auth_headers
|
|
74
85
|
end
|
|
@@ -18,7 +18,7 @@ module GraphqlDevise
|
|
|
18
18
|
|
|
19
19
|
response_payload = { authenticatable: resource }
|
|
20
20
|
|
|
21
|
-
response_payload[:credentials] =
|
|
21
|
+
response_payload[:credentials] = generate_auth_headers(resource) if resource.active_for_authentication?
|
|
22
22
|
|
|
23
23
|
response_payload
|
|
24
24
|
else
|
|
@@ -19,7 +19,7 @@ module GraphqlDevise
|
|
|
19
19
|
raise_user_error(I18n.t('graphql_devise.sessions.bad_credentials'))
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
new_headers =
|
|
22
|
+
new_headers = generate_auth_headers(resource)
|
|
23
23
|
controller.sign_in(:user, resource, store: false, bypass: false)
|
|
24
24
|
|
|
25
25
|
yield resource if block_given?
|
|
@@ -38,7 +38,7 @@ module GraphqlDevise
|
|
|
38
38
|
|
|
39
39
|
response_payload = { authenticatable: resource }
|
|
40
40
|
|
|
41
|
-
response_payload[:credentials] =
|
|
41
|
+
response_payload[:credentials] = generate_auth_headers(resource) if resource.active_for_authentication?
|
|
42
42
|
|
|
43
43
|
response_payload
|
|
44
44
|
else
|
|
@@ -23,7 +23,7 @@ module GraphqlDevise
|
|
|
23
23
|
yield resource if block_given?
|
|
24
24
|
|
|
25
25
|
response_payload = { authenticatable: resource }
|
|
26
|
-
response_payload[:credentials] =
|
|
26
|
+
response_payload[:credentials] = generate_auth_headers(resource) if controller.signed_in?(resource_name)
|
|
27
27
|
|
|
28
28
|
response_payload
|
|
29
29
|
else
|
data/lib/graphql_devise.rb
CHANGED
|
@@ -15,7 +15,7 @@ loader = Zeitwerk::Loader.for_gem
|
|
|
15
15
|
|
|
16
16
|
loader.collapse("#{__dir__}/graphql_devise/concerns")
|
|
17
17
|
loader.collapse("#{__dir__}/graphql_devise/errors")
|
|
18
|
-
loader.
|
|
18
|
+
loader.ignore("#{__dir__}/generators")
|
|
19
19
|
|
|
20
20
|
loader.inflector.inflect('error_codes' => 'ERROR_CODES')
|
|
21
21
|
loader.inflector.inflect('supported_options' => 'SUPPORTED_OPTIONS')
|
|
@@ -10,7 +10,11 @@ module Types
|
|
|
10
10
|
field :vip_field, String, null: false, authenticate: ->(user) { user.is_a?(User) && user.vip? }
|
|
11
11
|
|
|
12
12
|
def public_field
|
|
13
|
-
|
|
13
|
+
if context[:current_resource]
|
|
14
|
+
"Authenticated user on public field: #{context[:current_resource].email}"
|
|
15
|
+
else
|
|
16
|
+
'Field does not require authentication'
|
|
17
|
+
end
|
|
14
18
|
end
|
|
15
19
|
|
|
16
20
|
def private_field
|
|
@@ -41,7 +41,7 @@ RSpec.describe GraphqlDevise::InstallGenerator, type: :generator do
|
|
|
41
41
|
let(:args) { [] }
|
|
42
42
|
|
|
43
43
|
it 'creates and updated required files' do
|
|
44
|
-
assert_file 'config/routes.rb', /^\s{2}mount_graphql_devise_for
|
|
44
|
+
assert_file 'config/routes.rb', /^\s{2}mount_graphql_devise_for User, at: 'graphql_auth'/
|
|
45
45
|
expect(routes_content).not_to match(dta_route)
|
|
46
46
|
|
|
47
47
|
assert_file 'config/initializers/devise.rb'
|
|
@@ -60,7 +60,7 @@ RSpec.describe GraphqlDevise::InstallGenerator, type: :generator do
|
|
|
60
60
|
let(:args) { %w[Admin api] }
|
|
61
61
|
|
|
62
62
|
it 'creates and updated required files' do
|
|
63
|
-
assert_file 'config/routes.rb', /^\s{2}mount_graphql_devise_for
|
|
63
|
+
assert_file 'config/routes.rb', /^\s{2}mount_graphql_devise_for Admin, at: 'api'/
|
|
64
64
|
expect(routes_content).not_to match(dta_route)
|
|
65
65
|
|
|
66
66
|
assert_file 'config/initializers/devise.rb'
|
|
@@ -184,4 +184,38 @@ RSpec.describe 'Login Requests' do
|
|
|
184
184
|
)
|
|
185
185
|
end
|
|
186
186
|
end
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
if DeviseTokenAuth.respond_to?(:cookie_enabled)
|
|
190
|
+
context 'when using cookies for auth' do
|
|
191
|
+
let!(:user) { create(:user, :confirmed, password: password, email: 'vvega@wallaceinc.com') }
|
|
192
|
+
let(:email) { user.email }
|
|
193
|
+
let(:query) do
|
|
194
|
+
<<-GRAPHQL
|
|
195
|
+
mutation {
|
|
196
|
+
userLogin(
|
|
197
|
+
email: "#{email}",
|
|
198
|
+
password: "#{password}"
|
|
199
|
+
) {
|
|
200
|
+
authenticatable { email }
|
|
201
|
+
credentials { accessToken uid tokenType client expiry }
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
GRAPHQL
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
around do |example|
|
|
208
|
+
DeviseTokenAuth.cookie_enabled = true
|
|
209
|
+
example.run
|
|
210
|
+
DeviseTokenAuth.cookie_enabled = false
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
before { post_request('/api/v1/graphql') }
|
|
214
|
+
|
|
215
|
+
it 'honors DTA configuration of setting auth info in cookies' do
|
|
216
|
+
cookie = cookies.get_cookie('auth_cookie')
|
|
217
|
+
expect(JSON.parse(cookie.value).keys).to include(*%w[uid access-token client])
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
end
|
|
187
221
|
end
|
|
@@ -30,6 +30,16 @@ RSpec.describe "Integrations with the user's controller" do
|
|
|
30
30
|
it 'does not require authentication' do
|
|
31
31
|
expect(json_response[:data][:publicField]).to eq('Field does not require authentication')
|
|
32
32
|
end
|
|
33
|
+
|
|
34
|
+
context 'when user sends authentication headers anyway' do
|
|
35
|
+
let(:headers) { user.create_new_auth_token }
|
|
36
|
+
|
|
37
|
+
it 'sets current resource in the context' do
|
|
38
|
+
expect(json_response[:data][:publicField]).to eq(
|
|
39
|
+
"Authenticated user on public field: #{user.email}"
|
|
40
|
+
)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
33
43
|
end
|
|
34
44
|
|
|
35
45
|
context 'when using an interpreter schema' do
|
|
@@ -38,6 +48,16 @@ RSpec.describe "Integrations with the user's controller" do
|
|
|
38
48
|
it 'does not require authentication' do
|
|
39
49
|
expect(json_response[:data][:publicField]).to eq('Field does not require authentication')
|
|
40
50
|
end
|
|
51
|
+
|
|
52
|
+
context 'when user sends authentication headers anyway' do
|
|
53
|
+
let(:headers) { user.create_new_auth_token }
|
|
54
|
+
|
|
55
|
+
it 'sets current resource in the context' do
|
|
56
|
+
expect(json_response[:data][:publicField]).to eq(
|
|
57
|
+
"Authenticated user on public field: #{user.email}"
|
|
58
|
+
)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
41
61
|
end
|
|
42
62
|
end
|
|
43
63
|
|
|
@@ -91,5 +91,44 @@ RSpec.describe GraphqlDevise::ResourceLoader do
|
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
|
+
|
|
95
|
+
context 'when argument errors are raised when field is set' do
|
|
96
|
+
context 'when mutation raises an argument error' do
|
|
97
|
+
before { allow(mutation).to receive(:field).and_raise(ArgumentError, 'mutation error') }
|
|
98
|
+
|
|
99
|
+
if Gem::Version.new(GraphQL::VERSION) < Gem::Version.new('2.0')
|
|
100
|
+
it 'raises the same argument error' do
|
|
101
|
+
expect { loader }.to raise_error(
|
|
102
|
+
ArgumentError,
|
|
103
|
+
'mutation error'
|
|
104
|
+
)
|
|
105
|
+
end
|
|
106
|
+
else
|
|
107
|
+
it 'raises a GraphqlDevise::Error error' do
|
|
108
|
+
expect { loader }.to raise_error(GraphqlDevise::Error)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
context 'when query raises an argument error' do
|
|
114
|
+
before do
|
|
115
|
+
allow(mutation).to receive(:field)
|
|
116
|
+
allow(query).to receive(:field).and_raise(ArgumentError, 'query error')
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
if Gem::Version.new(GraphQL::VERSION) < Gem::Version.new('2.0')
|
|
120
|
+
it 'raises the same argument error' do
|
|
121
|
+
expect { loader }.to raise_error(
|
|
122
|
+
ArgumentError,
|
|
123
|
+
'query error'
|
|
124
|
+
)
|
|
125
|
+
end
|
|
126
|
+
else
|
|
127
|
+
it 'raises a GraphqlDevise::Error error' do
|
|
128
|
+
expect { loader }.to raise_error(GraphqlDevise::Error)
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
94
133
|
end
|
|
95
134
|
end
|
data/spec/spec_helper.rb
CHANGED
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: 1.
|
|
4
|
+
version: 1.1.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: 2022-
|
|
12
|
+
date: 2022-09-15 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: devise_token_auth
|
|
@@ -60,7 +60,7 @@ dependencies:
|
|
|
60
60
|
version: '4.2'
|
|
61
61
|
- - "<"
|
|
62
62
|
- !ruby/object:Gem::Version
|
|
63
|
-
version: '
|
|
63
|
+
version: '7.1'
|
|
64
64
|
type: :runtime
|
|
65
65
|
prerelease: false
|
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -70,7 +70,7 @@ dependencies:
|
|
|
70
70
|
version: '4.2'
|
|
71
71
|
- - "<"
|
|
72
72
|
- !ruby/object:Gem::Version
|
|
73
|
-
version: '
|
|
73
|
+
version: '7.1'
|
|
74
74
|
- !ruby/object:Gem::Dependency
|
|
75
75
|
name: zeitwerk
|
|
76
76
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -100,19 +100,19 @@ dependencies:
|
|
|
100
100
|
- !ruby/object:Gem::Version
|
|
101
101
|
version: '0'
|
|
102
102
|
- !ruby/object:Gem::Dependency
|
|
103
|
-
name:
|
|
103
|
+
name: coveralls_reborn
|
|
104
104
|
requirement: !ruby/object:Gem::Requirement
|
|
105
105
|
requirements:
|
|
106
|
-
- - "
|
|
106
|
+
- - ">="
|
|
107
107
|
- !ruby/object:Gem::Version
|
|
108
|
-
version: '0
|
|
108
|
+
version: '0'
|
|
109
109
|
type: :development
|
|
110
110
|
prerelease: false
|
|
111
111
|
version_requirements: !ruby/object:Gem::Requirement
|
|
112
112
|
requirements:
|
|
113
|
-
- - "
|
|
113
|
+
- - ">="
|
|
114
114
|
- !ruby/object:Gem::Version
|
|
115
|
-
version: '0
|
|
115
|
+
version: '0'
|
|
116
116
|
- !ruby/object:Gem::Dependency
|
|
117
117
|
name: factory_bot
|
|
118
118
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -526,7 +526,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
526
526
|
- !ruby/object:Gem::Version
|
|
527
527
|
version: '0'
|
|
528
528
|
requirements: []
|
|
529
|
-
rubygems_version: 3.3.
|
|
529
|
+
rubygems_version: 3.3.22
|
|
530
530
|
signing_key:
|
|
531
531
|
specification_version: 4
|
|
532
532
|
summary: GraphQL queries and mutations on top of devise_token_auth
|