graphiti_scaffold_generator 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8d0c144c7d84bee66406b31d5e2922c83ad4f9cbc4196360d3cf206ea8cade5
4
- data.tar.gz: bc589e4db463e07ffbb4f6f22823e2f630d901e56999a390aee8ba7306b84982
3
+ metadata.gz: fe50af1227fbf67ae6966ebdc03b8d61ed12fc9bcc9aaa08137a93df3845fb73
4
+ data.tar.gz: 05e51a9ace3926e919aa34248f238736495f2768e5c67fb99fa590431fe7b69c
5
5
  SHA512:
6
- metadata.gz: 4a8790f79b7c7c0d4fae2a96412e32d72148c11303b52a338be98d7b49227b393ba085158fce28f91a9747ec5493d2a594a1c2f451b0716ec2e3529e518dc5e3
7
- data.tar.gz: 3154e7591493660c86586a81ca4d40337ae82234f2c80ec6f2eb27218a2eac7bcacf03b8469b5f7e90ca41182b2cb825c0ef3373b50cd8cc1e30b6b4acadf795
6
+ metadata.gz: 14cfcd09d212a2658df7be76d8d20543b85a516fb373475785f2d21e837e7c8efd8ae151d413bb323b99dddd29130c9d41bdff45a1bd1d636dec0048017409d4
7
+ data.tar.gz: ecb3429e7e30718baa38955bf64a45d913b7b559ce9e96bb2d99dc2e2df99fe8e85ffded52fa63f99a581f27cd77c1806495556a8405a040ffb7e14fcbe5a1b4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphiti_scaffold_generator (0.1.0)
4
+ graphiti_scaffold_generator (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -22,7 +22,6 @@
22
22
  end
23
23
  all_attributes = id_attr + all_attributes
24
24
  -%>
25
-
26
25
  <% if File.exist?(File.join %w[spec rails_helper.rb]) -%>
27
26
  require 'rails_helper'
28
27
  <% else -%>
@@ -1,10 +1,8 @@
1
1
  <% resource = class_name + 'Resource' -%>
2
2
  <% pundit = defined?(Pundit) -%>
3
- # resource = <%= resource %>
4
- # pundit = <%= pundit %>
5
3
  <% module_namespacing do -%>
6
- class <%= controller_class_name %>Controller < ApplicationController
7
- before_action :set_<%= pundit ? 'and_authorise_' : '' %><%= singular_table_name %>, only: %i[ show update destroy ]
4
+ class <%= controller_class_name %>Controller < GraphitiApiController
5
+ before_action :set_<%= pundit ? 'and_authorize_' : '' %><%= singular_table_name %>, only: %i[show update destroy]
8
6
 
9
7
  # GET <%= route_url %>
10
8
  def index
@@ -25,18 +23,18 @@ class <%= controller_class_name %>Controller < ApplicationController
25
23
  <% end -%>
26
24
 
27
25
  if @<%= singular_table_name %>.save
28
- render jsonapi: <%= singular_table_name %>, status: :created
26
+ render jsonapi: @<%= singular_table_name %>, status: :created
29
27
  else
30
- render jsonapi_errors: <%= singular_table_name %>
28
+ render jsonapi_errors: @<%= singular_table_name %>
31
29
  end
32
30
  end
33
31
 
34
32
  # PATCH/PUT <%= route_url %>/1
35
33
  def update
36
34
  if @<%= singular_table_name %>.update_attributes
37
- render jsonapi: <%= singular_table_name %>
35
+ render jsonapi: @<%= singular_table_name %>
38
36
  else
39
- render jsonapi_errors: <%= singular_table_name %>
37
+ render jsonapi_errors: @<%= singular_table_name %>
40
38
  end
41
39
  end
42
40
 
@@ -48,10 +46,10 @@ class <%= controller_class_name %>Controller < ApplicationController
48
46
  private
49
47
 
50
48
  # Use callbacks to share common setup or constraints between actions.
51
- def set_<%= pundit ? 'and_authorise_' : '' %><%= singular_table_name %>
49
+ def set_<%= pundit ? 'and_authorize_' : '' %><%= singular_table_name %>
52
50
  @<%= singular_table_name %> = <%= resource %>.find(params)
53
51
  <% if pundit -%>
54
- authorize @<%= singular_table_name %>
52
+ authorize @<%= singular_table_name %>.data
55
53
  <% end -%>
56
54
  end
57
55
 
@@ -63,7 +61,7 @@ class <%= controller_class_name %>Controller < ApplicationController
63
61
  list = %i[
64
62
  <%= attributes_names.join(' ') %>
65
63
  ]
66
- params.require(:<%= singular_table_name %>).permit(*list)
64
+ params.require(:data).require(:attributes).permit(*list)
67
65
  <%- end -%>
68
66
  end
69
67
  end
@@ -57,6 +57,16 @@ describe "Request /<%= name.underscore.pluralize %>", <%= type_metatag(:request)
57
57
  {}
58
58
  }
59
59
 
60
+ <% if pundit -%>
61
+ before do
62
+ allow_any_instance_of(GraphitiApiController).to receive(:authorize)
63
+ .and_return UserAbsence
64
+ allow_any_instance_of(GraphitiApiController).to receive(:current_user)
65
+ .and_return(user)
66
+ allow_any_instance_of(GraphitiApiController).to receive :authenticate_user!
67
+ end
68
+ <% end -%>
69
+
60
70
  <% unless options[:singleton] -%>
61
71
  describe 'GET /index' do
62
72
  it "renders a successful response" do
@@ -152,10 +162,10 @@ describe "Request /<%= name.underscore.pluralize %>", <%= type_metatag(:request)
152
162
  attributes: new_attributes,
153
163
  }
154
164
  end
155
- let(:new_attributes) {
165
+ let(:new_attributes) do
156
166
  skip("Add a hash of attributes valid for <%= class_name %>")
157
167
  { <%= attribute_name %>: 'New <%= attribute_name %>' }
158
- }
168
+ end
159
169
 
160
170
  context "with valid parameters" do
161
171
  it "updates the requested <%= file_name %>" do
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GraphitiScaffoldGenerator
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiti_scaffold_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Kulikov