graphiti-rails 0.2.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +18 -1
- data/Rakefile +6 -1
- data/lib/generators/graphiti/api_test_generator.rb +6 -0
- data/lib/generators/graphiti/generator_mixin.rb +14 -0
- data/lib/generators/graphiti/resource_generator.rb +8 -0
- data/lib/generators/graphiti/templates/index_request_spec.rb.erb +1 -1
- data/lib/generators/graphiti/templates/resource_reads_spec.rb.erb +6 -6
- data/lib/generators/graphiti/templates/show_request_spec.rb.erb +1 -1
- data/lib/graphiti/rails/railtie.rb +1 -1
- data/lib/graphiti/rails/version.rb +1 -1
- data/lib/tasks/graphiti.rake +4 -1
- metadata +24 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 67a63788c6e7d8f499050adb18b2f7b7f5495eea70622d988e3d456f4126e94a
|
4
|
+
data.tar.gz: 35a4799fbbd289746c9488d9b719524f4ad88dfd052a0b5f05c4bb752c06604e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe9f5da5a0ec25ce89c6e06080391bd6d7093221fdd59003f10b8939a48b80fadd7d290356b83e8d8cf4bb2359c1c13e22a948f37369e9917bb50f59235d9788
|
7
|
+
data.tar.gz: ccd6afbdfcfc83061f0d8a0f3e0f60e89b70fbc85bf4e61de467315c7fce98a763fe269b92bcca499bee3b9884915e3cd8208859896981127fa0cc5cae34da11
|
data/CHANGELOG.md
CHANGED
@@ -7,7 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
---
|
9
9
|
|
10
|
-
## [0.
|
10
|
+
## [0.3.0] - 2021-05-11
|
11
|
+
### Changed
|
12
|
+
- `rescue_registry` has been updated to 0.3.0. This causes some changes to error payloads.
|
13
|
+
[CHANGELOG](https://github.com/wagenet/rescue_registry/blob/master/CHANGELOG.md#030---2021-05-11)
|
14
|
+
|
15
|
+
## [0.2.4] - 2020-08-10
|
16
|
+
### Changed
|
17
|
+
- The `rails` dependency has been replaced with `railties`. - #60
|
18
|
+
|
19
|
+
## [0.2.3] - 2019-10-31
|
20
|
+
### Added
|
21
|
+
- Add option to use rawid in generated tests
|
22
|
+
|
23
|
+
## [0.2.2] - 2019-10-26
|
24
|
+
### Fixed
|
25
|
+
- Let user disable the logger
|
26
|
+
|
27
|
+
## [0.2.1] - 2019-06-13
|
11
28
|
### Added
|
12
29
|
- Include `__raw_errors__` in detailed error payloads for use by Vandal and Request Responses
|
13
30
|
|
data/Rakefile
CHANGED
@@ -7,6 +7,7 @@ end
|
|
7
7
|
require 'yard'
|
8
8
|
require 'rspec/core/rake_task'
|
9
9
|
require 'bundler/gem_tasks'
|
10
|
+
require 'rails/version'
|
10
11
|
|
11
12
|
YARD::Rake::YardocTask.new
|
12
13
|
|
@@ -14,7 +15,11 @@ RSpec::Core::RakeTask.new(:spec) do |t|
|
|
14
15
|
t.rspec_opts = "--order random"
|
15
16
|
end
|
16
17
|
|
17
|
-
|
18
|
+
if Rails::VERSION::MAJOR < 7
|
19
|
+
APP_RAKEFILE = File.expand_path("spec/rails5/dummy/Rakefile", __dir__)
|
20
|
+
else
|
21
|
+
APP_RAKEFILE = File.expand_path("spec/rails7/dummy/Rakefile", __dir__)
|
22
|
+
end
|
18
23
|
load "rails/tasks/engine.rake"
|
19
24
|
|
20
25
|
task default: :spec
|
@@ -13,6 +13,12 @@ module Graphiti
|
|
13
13
|
aliases: ["--actions", "-a"],
|
14
14
|
desc: 'Array of controller actions, e.g. "index show destroy"'
|
15
15
|
|
16
|
+
class_option :'rawid',
|
17
|
+
type: :boolean,
|
18
|
+
default: false,
|
19
|
+
aliases: ["--rawid", "-r"],
|
20
|
+
desc: "Generate tests using rawid"
|
21
|
+
|
16
22
|
desc "Generates rspec request specs at spec/api"
|
17
23
|
def generate
|
18
24
|
generate_api_specs
|
@@ -41,5 +41,19 @@ module Graphiti
|
|
41
41
|
config = graphiti_config.merge(attrs)
|
42
42
|
File.open(".graphiticfg.yml", "w") { |f| f.write(config.to_yaml) }
|
43
43
|
end
|
44
|
+
|
45
|
+
def id_or_rawid
|
46
|
+
@options["rawid"] ? "rawid" : "id"
|
47
|
+
end
|
48
|
+
|
49
|
+
def sort_raw_ids
|
50
|
+
return unless @options["rawid"]
|
51
|
+
".sort"
|
52
|
+
end
|
53
|
+
|
54
|
+
def sort_raw_ids_descending
|
55
|
+
return unless @options["rawid"]
|
56
|
+
".sort.reverse"
|
57
|
+
end
|
44
58
|
end
|
45
59
|
end
|
@@ -14,6 +14,12 @@ module Graphiti
|
|
14
14
|
aliases: ["--omit-comments", "-c"],
|
15
15
|
desc: "Generate without documentation comments"
|
16
16
|
|
17
|
+
class_option :'rawid',
|
18
|
+
type: :boolean,
|
19
|
+
default: false,
|
20
|
+
aliases: ["--rawid", "-r"],
|
21
|
+
desc: "Generate tests using rawid"
|
22
|
+
|
17
23
|
class_option :actions,
|
18
24
|
type: :array,
|
19
25
|
default: nil,
|
@@ -143,12 +149,14 @@ module Graphiti
|
|
143
149
|
def generate_resource_specs
|
144
150
|
opts = {}
|
145
151
|
opts[:actions] = @options[:actions] if @options[:actions]
|
152
|
+
opts[:rawid] = @options[:rawid] if @options[:rawid]
|
146
153
|
invoke "graphiti:resource_test", [resource_klass], opts
|
147
154
|
end
|
148
155
|
|
149
156
|
def generate_api_specs
|
150
157
|
opts = {}
|
151
158
|
opts[:actions] = @options[:actions] if @options[:actions]
|
159
|
+
opts[:rawid] = @options[:rawid] if @options[:rawid]
|
152
160
|
invoke "graphiti:api_test", [resource_klass], opts
|
153
161
|
end
|
154
162
|
|
@@ -16,7 +16,7 @@ RSpec.describe "<%= type %>#index", type: :request do
|
|
16
16
|
make_request
|
17
17
|
expect(response.status).to eq(200), response.body
|
18
18
|
expect(d.map(&:jsonapi_type).uniq).to match_array(['<%= type %>'])
|
19
|
-
expect(d.map(
|
19
|
+
expect(d.map(&:<%= id_or_rawid %>)).to match_array([<%= var %>1.id, <%= var %>2.id])
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -7,7 +7,7 @@ RSpec.describe <%= resource_class %>, type: :resource do
|
|
7
7
|
it 'works' do
|
8
8
|
render
|
9
9
|
data = jsonapi_data[0]
|
10
|
-
expect(data
|
10
|
+
expect(data.<%= id_or_rawid %>).to eq(<%= var %>.id)
|
11
11
|
expect(data.jsonapi_type).to eq('<%= type %>')
|
12
12
|
<%- attributes.each do |a| -%>
|
13
13
|
<%- if [:created_at, :updated_at].include?(a.name.to_sym) -%>
|
@@ -31,7 +31,7 @@ RSpec.describe <%= resource_class %>, type: :resource do
|
|
31
31
|
|
32
32
|
it 'works' do
|
33
33
|
render
|
34
|
-
expect(d.map(
|
34
|
+
expect(d.map(&:<%= id_or_rawid %>)).to eq([<%= var %>2.id])
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -48,10 +48,10 @@ RSpec.describe <%= resource_class %>, type: :resource do
|
|
48
48
|
|
49
49
|
it 'works' do
|
50
50
|
render
|
51
|
-
expect(d.map(
|
51
|
+
expect(d.map(&:<%= id_or_rawid %>)).to eq([
|
52
52
|
<%= var %>1.id,
|
53
53
|
<%= var %>2.id
|
54
|
-
])
|
54
|
+
]<%= sort_raw_ids %>)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -62,10 +62,10 @@ RSpec.describe <%= resource_class %>, type: :resource do
|
|
62
62
|
|
63
63
|
it 'works' do
|
64
64
|
render
|
65
|
-
expect(d.map(
|
65
|
+
expect(d.map(&:<%= id_or_rawid %>)).to eq([
|
66
66
|
<%= var %>2.id,
|
67
67
|
<%= var %>1.id
|
68
|
-
])
|
68
|
+
]<%= sort_raw_ids_descending %>)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
@@ -15,7 +15,7 @@ RSpec.describe "<%= type %>#show", type: :request do
|
|
15
15
|
make_request
|
16
16
|
expect(response.status).to eq(200)
|
17
17
|
expect(d.jsonapi_type).to eq('<%= type %>')
|
18
|
-
expect(d
|
18
|
+
expect(d.<%= id_or_rawid %>).to eq(<%= var %>.id)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -37,7 +37,7 @@ module Graphiti
|
|
37
37
|
|
38
38
|
initializer "graphti-rails.logger" do
|
39
39
|
config.after_initialize do
|
40
|
-
Graphiti.config.debug = ::Rails.logger.
|
40
|
+
Graphiti.config.debug = ::Rails.logger.debug? && Graphiti.config.debug
|
41
41
|
Graphiti.logger = ::Rails.logger
|
42
42
|
end
|
43
43
|
end
|
data/lib/tasks/graphiti.rake
CHANGED
@@ -22,7 +22,10 @@ namespace :graphiti do
|
|
22
22
|
end
|
23
23
|
path = "#{path}&debug=true" if debug
|
24
24
|
handle_request_exceptions do
|
25
|
-
|
25
|
+
headers = {
|
26
|
+
"Authorization": ENV['AUTHORIZATION_HEADER']
|
27
|
+
}.compact
|
28
|
+
session.get(path.to_s, headers: headers)
|
26
29
|
end
|
27
30
|
JSON.parse(session.response.body)
|
28
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphiti-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Wagenet
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphiti
|
@@ -30,16 +30,16 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
33
|
+
version: '1.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0
|
40
|
+
version: '1.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: railties
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rspec-rails
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,7 +192,7 @@ dependencies:
|
|
178
192
|
- - ">="
|
179
193
|
- !ruby/object:Gem::Version
|
180
194
|
version: '0'
|
181
|
-
description:
|
195
|
+
description:
|
182
196
|
email:
|
183
197
|
- peter.wagenet@gmail.com
|
184
198
|
executables: []
|
@@ -222,7 +236,7 @@ metadata:
|
|
222
236
|
bug_tracker_uri: https://github.com/graphiti-api/graphiti-rails/issues
|
223
237
|
changelog_uri: https://github.com/graphiti-api/graphiti-rails/CHANGELOG.md
|
224
238
|
source_code_uri: https://github.com/graphiti-api/graphiti-rails
|
225
|
-
post_install_message:
|
239
|
+
post_install_message:
|
226
240
|
rdoc_options: []
|
227
241
|
require_paths:
|
228
242
|
- lib
|
@@ -237,9 +251,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
251
|
- !ruby/object:Gem::Version
|
238
252
|
version: '0'
|
239
253
|
requirements: []
|
240
|
-
|
241
|
-
|
242
|
-
signing_key:
|
254
|
+
rubygems_version: 3.3.3
|
255
|
+
signing_key:
|
243
256
|
specification_version: 4
|
244
257
|
summary: Rails integration for Graphiti
|
245
258
|
test_files: []
|