Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
simple_controller
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
simple_controller
Commits
f1409d6f
Commit
f1409d6f
authored
Dec 29, 2018
by
liyijie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support column_hash not respond_to
parent
9ee8dc7b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
simple_controller_generator.rb
...nerators/simple_controller/simple_controller_generator.rb
+1
-1
spec.rb.tt
lib/generators/simple_controller/templates/specs/spec.rb.tt
+2
-2
No files found.
lib/generators/simple_controller/simple_controller_generator.rb
View file @
f1409d6f
...
...
@@ -12,7 +12,7 @@ class SimpleControllerGenerator < Rails::Generators::NamedBase
def
setup
return
if
options
[
"auth-only"
]
@routes
=
RSpec
::
Rails
::
Swagger
::
RouteParser
.
new
(
controller_path
.
sub
(
/^\//
,
''
)).
routes
p
"Warning!! Resource is not exist, CHECK & regenerate after you have configurate the model and routes already"
if
resource_class
&
.
columns_hash
.
blank?
p
"Warning!! Resource is not exist, CHECK & regenerate after you have configurate the model and routes already"
if
resource_class
.
blank?
end
def
create_controller_files
...
...
lib/generators/simple_controller/templates/specs/spec.rb.tt
View file @
f1409d6f
...
...
@@ -5,8 +5,8 @@ RSpec.describe '<%= controller_path %>', type: :request, capture_examples: true,
type: :object, properties: {
<%= resource_singular %>: {
type: :object, properties: {
<%- if resource_class&.columns_hash.present? -%>
<%- resource_class.columns_hash.except('id', 'created_at', 'updated_at').values.each do |column| -%>
<%- if resource_class
.respond_to?(:columns_hash) && resource_class
&.columns_hash.present? -%>
<%- resource_class.
respond_to?(:columns_hash) && resource_class.
columns_hash.except('id', 'created_at', 'updated_at').values.each do |column| -%>
<%= column.name %>: { type: :<%= column.type %>, description: '<%= column&.comment %>' },
<%- end -%>
<%- end -%>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment