graphiti_scaffold_generator 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4002a3aebc4dd502a54dabdb5250a281c7f43d0a6d95792123aa79a0e29ed75
|
4
|
+
data.tar.gz: 8bee9f7f0972eda121ebe11a0292a9c0238aa09c1b4c2b48b34d022074087e05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54091104b0c1778328d421607360f56eda6186d548fc8d1e9633192f2ecc2885572bfaf2c3d2d3bcbc86b03383d35b3b8a958b02e8b6b9364fadd1f9add0e521
|
7
|
+
data.tar.gz: 3fe2671e210446f4f9ae44011019dcdc3e336fdfe8430fdce767f6cd2b83951ef14635db89306b86fac7cca6c77d44192d367d80db6485cbe5b1c3fb2db6ae74
|
data/Gemfile.lock
CHANGED
@@ -9,12 +9,12 @@ require 'spec_helper'
|
|
9
9
|
<% module_namespacing do -%>
|
10
10
|
describe "Request /<%= name.underscore.pluralize %>", <%= type_metatag(:request) %> do
|
11
11
|
<% if fbot -%>
|
12
|
-
let(:<%=
|
12
|
+
let(:<%= singular_name %>) { create :<%= singular_name %> }
|
13
13
|
<% if pundit -%>
|
14
14
|
let(:user) { create :user }
|
15
15
|
<% end -%>
|
16
16
|
<% else -%>
|
17
|
-
let(:<%=
|
17
|
+
let(:<%= singular_name %>) { <%= class_name %>.create! valid_attributes }
|
18
18
|
<% end -%>
|
19
19
|
|
20
20
|
# This should return the minimal set of attributes required to create a valid
|
@@ -27,7 +27,7 @@ describe "Request /<%= name.underscore.pluralize %>", <%= type_metatag(:request)
|
|
27
27
|
<% attribute_name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name -%>
|
28
28
|
<% if links.present? -%>
|
29
29
|
let(:valid_attributes) do
|
30
|
-
attributes_for(:<%=
|
30
|
+
attributes_for(:<%=singular_name%>)
|
31
31
|
.slice(*%i[<%= attribute_name %>])
|
32
32
|
.merge(
|
33
33
|
<% links.each do |relation| -%>
|
@@ -36,7 +36,7 @@ describe "Request /<%= name.underscore.pluralize %>", <%= type_metatag(:request)
|
|
36
36
|
)
|
37
37
|
end
|
38
38
|
<% else -%>
|
39
|
-
let(:valid_attributes) {attributes_for(:<%=
|
39
|
+
let(:valid_attributes) {attributes_for(:<%=singular_name%>).slice *%i[<%= attribute_name %>]}
|
40
40
|
<% end -%>
|
41
41
|
<% else -%>
|
42
42
|
let(:valid_attributes) {
|
@@ -60,7 +60,7 @@ describe "Request /<%= name.underscore.pluralize %>", <%= type_metatag(:request)
|
|
60
60
|
<% if pundit -%>
|
61
61
|
before do
|
62
62
|
allow_any_instance_of(GraphitiApiController).to receive(:authorize)
|
63
|
-
.and_return
|
63
|
+
.and_return <%= class_name %>
|
64
64
|
allow_any_instance_of(GraphitiApiController).to receive(:current_user)
|
65
65
|
.and_return(user)
|
66
66
|
allow_any_instance_of(GraphitiApiController).to receive :authenticate_user!
|
@@ -69,21 +69,51 @@ describe "Request /<%= name.underscore.pluralize %>", <%= type_metatag(:request)
|
|
69
69
|
|
70
70
|
<% unless options[:singleton] -%>
|
71
71
|
describe 'GET /index' do
|
72
|
+
subject(:get_index) do
|
73
|
+
get <%= plural_name %>_url, headers: valid_headers, as: :json
|
74
|
+
end
|
75
|
+
|
76
|
+
before do
|
77
|
+
<%= singular_name %>
|
78
|
+
end
|
79
|
+
|
72
80
|
it "renders a successful response" do
|
73
|
-
|
74
|
-
get <%= index_helper %>_url, headers: valid_headers, as: :json
|
81
|
+
get_index
|
75
82
|
expect(response).to be_successful
|
76
83
|
end
|
84
|
+
|
85
|
+
it 'renders content_type "application/vnd.api+json; charset=utf-8"' do
|
86
|
+
get_index
|
87
|
+
expect(response.content_type).to eq("application/vnd.api+json; charset=utf-8")
|
88
|
+
end
|
89
|
+
|
90
|
+
it "renders a JSON response with an Array of UserAbsences" do
|
91
|
+
get_index
|
92
|
+
expect(JSON.parse(response.body)['data']).to be_an Array
|
93
|
+
expect(JSON.parse(response.body)['data'].first['id']).to eq <%= singular_name %>.id
|
94
|
+
end
|
77
95
|
end
|
78
96
|
<% end -%>
|
79
97
|
|
80
98
|
describe 'GET /show' do
|
81
|
-
subject(:get_show)
|
99
|
+
subject(:get_show) do
|
100
|
+
get <%= singular_name %>_url(<%= singular_name %>), headers: valid_headers, as: :json
|
101
|
+
end
|
82
102
|
|
83
103
|
it "renders a successful response" do
|
84
104
|
get_show
|
85
105
|
expect(response).to be_successful
|
86
106
|
end
|
107
|
+
|
108
|
+
it 'renders content_type "application/vnd.api+json; charset=utf-8"' do
|
109
|
+
get_show
|
110
|
+
expect(response.content_type).to eq("application/vnd.api+json; charset=utf-8")
|
111
|
+
end
|
112
|
+
|
113
|
+
it "renders a JSON response with the requested <%= singular_name %>" do
|
114
|
+
get_show
|
115
|
+
expect(JSON.parse(response.body)['data']['id']).to eq <%= singular_name %>.id
|
116
|
+
end
|
87
117
|
end
|
88
118
|
|
89
119
|
describe 'POST /create' do
|
@@ -116,7 +146,7 @@ describe "Request /<%= name.underscore.pluralize %>", <%= type_metatag(:request)
|
|
116
146
|
expect(response.content_type).to eq("application/vnd.api+json; charset=utf-8")
|
117
147
|
end
|
118
148
|
|
119
|
-
it "renders a JSON response with the new <%=
|
149
|
+
it "renders a JSON response with the new <%= singular_name %>" do
|
120
150
|
post_create
|
121
151
|
expect(JSON.parse(response.body)['data']['id'])
|
122
152
|
.to eq <%= class_name %>.order(:created_at).last.id
|
@@ -140,7 +170,7 @@ describe "Request /<%= name.underscore.pluralize %>", <%= type_metatag(:request)
|
|
140
170
|
expect(response.content_type).to eq("application/vnd.api+json; charset=utf-8")
|
141
171
|
end
|
142
172
|
|
143
|
-
it 'renders a JSON response with errors for the new <%=
|
173
|
+
it 'renders a JSON response with errors for the new <%= singular_name %>' do
|
144
174
|
post_create
|
145
175
|
expect(JSON.parse(response.body).dig 'errors', 0, 'meta', 'attribute')
|
146
176
|
.to be_present
|
@@ -150,15 +180,15 @@ describe "Request /<%= name.underscore.pluralize %>", <%= type_metatag(:request)
|
|
150
180
|
|
151
181
|
describe 'PATCH /update' do
|
152
182
|
subject(:patch_update) do
|
153
|
-
patch <%=
|
183
|
+
patch <%= singular_name %>_url(<%= singular_name %>),
|
154
184
|
params: { data: data },
|
155
185
|
headers: valid_headers,
|
156
186
|
as: :json
|
157
187
|
end
|
158
188
|
let(:data) do
|
159
189
|
{
|
160
|
-
id: <%=
|
161
|
-
type: '<%=
|
190
|
+
id: <%= singular_name %>.id.to_s,
|
191
|
+
type: '<%= singular_name %>s',
|
162
192
|
attributes: new_attributes,
|
163
193
|
}
|
164
194
|
end
|
@@ -168,11 +198,11 @@ describe "Request /<%= name.underscore.pluralize %>", <%= type_metatag(:request)
|
|
168
198
|
end
|
169
199
|
|
170
200
|
context "with valid parameters" do
|
171
|
-
it "updates the requested <%=
|
201
|
+
it "updates the requested <%= singular_name %>" do
|
172
202
|
patch_update
|
173
|
-
<%=
|
203
|
+
<%= singular_name %>.reload
|
174
204
|
skip("Add assertions for updated state")
|
175
|
-
expect(<%=
|
205
|
+
expect(<%= singular_name %>.<%= attribute_name %>). to eq 'New <%= attribute_name %>'
|
176
206
|
end
|
177
207
|
|
178
208
|
it 'returns :ok' do
|
@@ -185,17 +215,17 @@ describe "Request /<%= name.underscore.pluralize %>", <%= type_metatag(:request)
|
|
185
215
|
expect(response.content_type).to eq("application/vnd.api+json; charset=utf-8")
|
186
216
|
end
|
187
217
|
|
188
|
-
it "renders a JSON response with the <%=
|
218
|
+
it "renders a JSON response with the <%= singular_name %>" do
|
189
219
|
patch_update
|
190
|
-
expect(JSON.parse(response.body)['data']['id']).to eq <%=
|
220
|
+
expect(JSON.parse(response.body)['data']['id']).to eq <%= singular_name %>.id
|
191
221
|
end
|
192
222
|
end
|
193
223
|
|
194
224
|
context "with invalid parameters" do
|
195
225
|
let(:new_attributes) { invalid_attributes }
|
196
226
|
|
197
|
-
it "does not update the requested <%=
|
198
|
-
expect { patch_update }.not_to change <%=
|
227
|
+
it "does not update the requested <%= singular_name %>" do
|
228
|
+
expect { patch_update }.not_to change <%= singular_name %>, :reload
|
199
229
|
end
|
200
230
|
|
201
231
|
it 'returns :unprocessable_entity' do
|
@@ -208,7 +238,7 @@ describe "Request /<%= name.underscore.pluralize %>", <%= type_metatag(:request)
|
|
208
238
|
expect(response.content_type).to eq("application/vnd.api+json; charset=utf-8")
|
209
239
|
end
|
210
240
|
|
211
|
-
it "renders a JSON response with errors for the new <%=
|
241
|
+
it "renders a JSON response with errors for the new <%= singular_name %>" do
|
212
242
|
patch_update
|
213
243
|
expect(JSON.parse(response.body).dig 'errors', 0, 'meta', 'attribute')
|
214
244
|
.to be_present
|
@@ -218,14 +248,14 @@ describe "Request /<%= name.underscore.pluralize %>", <%= type_metatag(:request)
|
|
218
248
|
|
219
249
|
describe "DELETE /destroy" do
|
220
250
|
subject(:delete_destroy) do
|
221
|
-
delete <%=
|
251
|
+
delete <%= singular_name %>_url(id: <%= singular_name %>.to_param)
|
222
252
|
end
|
223
253
|
|
224
254
|
before do
|
225
|
-
<%=
|
255
|
+
<%= singular_name %> # we need something to destroy
|
226
256
|
end
|
227
257
|
|
228
|
-
it "destroys the requested <%=
|
258
|
+
it "destroys the requested <%= singular_name %>" do
|
229
259
|
expect { delete_destroy }.to change(<%= class_name %>, :count).by -1
|
230
260
|
end
|
231
261
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphiti_scaffold_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Kulikov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
The graphiti gem has no support for scaffold generator.
|
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
requirements: []
|
63
|
-
rubygems_version: 3.
|
63
|
+
rubygems_version: 3.4.12
|
64
64
|
signing_key:
|
65
65
|
specification_version: 4
|
66
66
|
summary: When gem 'graphiti' is in use generates code for app/resources and /spec/resources
|