Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shotengai
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
shotengai
Commits
b0dc8cc4
Commit
b0dc8cc4
authored
Aug 31, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add shallow to routes & Improve request spec
parent
5796caca
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
16 additions
and
20 deletions
+16
-20
.gitignore
.gitignore
+2
-0
controllers_generator.rb
lib/generators/shotengai/controllers_generator.rb
+5
-5
models_generator.rb
lib/generators/shotengai/models_generator.rb
+1
-1
spec_generator.rb
lib/generators/shotengai/spec_generator.rb
+1
-1
product_series_spec.rb
...s/templates/spec/requests/customer/product_series_spec.rb
+3
-4
product_series_spec.rb
...s/templates/spec/requests/merchant/product_series_spec.rb
+3
-5
product_snapshot_spec.rb
...templates/spec/requests/merchant/product_snapshot_spec.rb
+1
-4
No files found.
.gitignore
View file @
b0dc8cc4
...
@@ -8,3 +8,4 @@
...
@@ -8,3 +8,4 @@
/spec/reports/
/spec/reports/
/tmp/
/tmp/
/mysql.yml
/mysql.yml
/.rspec_status
\ No newline at end of file
lib/generators/shotengai/controllers_generator.rb
View file @
b0dc8cc4
...
@@ -64,20 +64,20 @@ module Shotengai
...
@@ -64,20 +64,20 @@ module Shotengai
product
,
order
=
@product
.
underscore
,
@order
.
underscore
product
,
order
=
@product
.
underscore
,
@order
.
underscore
"
"
namespace :
#{
@namespace
.
to_sym
}
do
namespace :
#{
@namespace
.
to_sym
}
do
resources :
#{
product
.
pluralize
}
do
resources :
#{
product
.
pluralize
}
, shallow: true
do
member do
member do
post :put_on_shelf
post :put_on_shelf
post :sold_out
post :sold_out
end
end
resources :
#{
product
}
_series
resources :
#{
product
}
_series
end
end
resources :
#{
order
.
pluralize
}
, only: [:index, :show, :update] do
resources :
#{
order
.
pluralize
}
, only: [:index, :show, :update]
, shallow: true
do
member do
member do
post :send_out
post :send_out
end
end
resources :
#{
product
}
_snapshots, only: [:index, :show, :update]
resources :
#{
product
}
_snapshots, only: [:index, :show, :update]
end
end
resources :
#{
product
}
_series do #, excpet: :index
resources :
#{
product
}
_series
, shallow: true
do #, excpet: :index
resources :
#{
product
}
_snapshots, only: [:index, :show, :update]
resources :
#{
product
}
_snapshots, only: [:index, :show, :update]
end
end
end
end
...
@@ -88,11 +88,11 @@ module Shotengai
...
@@ -88,11 +88,11 @@ module Shotengai
product
,
order
=
@product
.
underscore
,
@order
.
underscore
product
,
order
=
@product
.
underscore
,
@order
.
underscore
"
"
namespace :
#{
@namespace
.
to_sym
}
do
namespace :
#{
@namespace
.
to_sym
}
do
resources :
#{
product
.
pluralize
}
, only: [:index, :show] do
resources :
#{
product
.
pluralize
}
,
shallow: true,
only: [:index, :show] do
resources :
#{
product
}
_series, only: [:index, :show]
resources :
#{
product
}
_series, only: [:index, :show]
end
end
resources :
#{
product
}
_snapshots, only: [:index, :show]
resources :
#{
product
}
_snapshots, only: [:index, :show]
resources :
#{
order
.
pluralize
}
do
resources :
#{
order
.
pluralize
}
, shallow: true
do
member do
member do
post :pay
post :pay
post :cancel
post :cancel
...
...
lib/generators/shotengai/models_generator.rb
View file @
b0dc8cc4
...
@@ -11,7 +11,7 @@ module Shotengai
...
@@ -11,7 +11,7 @@ module Shotengai
Use --catalog to custom your own catalog class
Use --catalog to custom your own catalog class
For example:
For example:
rails g shotengai:models --product MyProduct --order MyOrder --catalog Catalog
rails g shotengai:models --product MyProduct --order MyOrder --catalog
My
Catalog
This will create some model file:
This will create some model file:
create app/models/my_product.rb
create app/models/my_product.rb
create app/models/my_product_series.rb
create app/models/my_product_series.rb
...
...
lib/generators/shotengai/spec_generator.rb
View file @
b0dc8cc4
...
@@ -18,7 +18,7 @@ module Shotengai
...
@@ -18,7 +18,7 @@ module Shotengai
options
.
values_at
(
:customer
,
:merchant
,
:product
,
:order
)
options
.
values_at
(
:customer
,
:merchant
,
:product
,
:order
)
Dir
[
"
#{
self
.
class
.
source_root
}
/**/*.rb"
].
each
do
|
path
|
Dir
[
"
#{
self
.
class
.
source_root
}
/**/*.rb"
].
each
do
|
path
|
relative_path
=
path
.
gsub
(
self
.
class
.
source_root
,
''
)
relative_path
=
path
.
gsub
(
self
.
class
.
source_root
,
''
)
template
path
,
"
app/
spec/shotengai/
#{
relative_path
}
"
template
path
,
"spec/shotengai/
#{
relative_path
}
"
end
end
end
end
end
end
...
...
lib/generators/templates/spec/requests/customer/product_series_spec.rb
View file @
b0dc8cc4
...
@@ -46,11 +46,9 @@ RSpec.describe "#{namespace}/products/:product_id/product_series", type: :reques
...
@@ -46,11 +46,9 @@ RSpec.describe "#{namespace}/products/:product_id/product_series", type: :reques
end
end
end
end
path
"/
#{
namespace
}
/product
s/{product_id}/product
_series/{id}"
do
path
"/
#{
namespace
}
/product_series/{id}"
do
parameter
:id
,
in: :path
,
type: :string
parameter
:id
,
in: :path
,
type: :string
parameter
:product_id
,
in: :path
,
type: :string
let
(
:product_id
)
{
@product_1
.
id
}
let
(
:id
)
{
@series_1
.
id
}
let
(
:id
)
{
@series_1
.
id
}
get
(
summary:
'用户 商品系列的详情'
)
do
get
(
summary:
'用户 商品系列的详情'
)
do
...
@@ -61,4 +59,4 @@ RSpec.describe "#{namespace}/products/:product_id/product_series", type: :reques
...
@@ -61,4 +59,4 @@ RSpec.describe "#{namespace}/products/:product_id/product_series", type: :reques
end
end
end
end
end
end
end
end
\ No newline at end of file
lib/generators/templates/spec/requests/merchant/product_series_spec.rb
View file @
b0dc8cc4
...
@@ -102,11 +102,8 @@ RSpec.describe "#{namespace}/products/:product_id/product_series", type: :reques
...
@@ -102,11 +102,8 @@ RSpec.describe "#{namespace}/products/:product_id/product_series", type: :reques
end
end
end
end
path
"/
#{
namespace
}
/product
s/{product_id}/product
_series/{id}"
do
path
"/
#{
namespace
}
/product_series/{id}"
do
parameter
:id
,
in: :path
,
type: :string
parameter
:id
,
in: :path
,
type: :string
parameter
:product_id
,
in: :path
,
type: :string
let
(
:product_id
)
{
@product_1
.
id
}
let
(
:id
)
{
@series_1
.
id
}
let
(
:id
)
{
@series_1
.
id
}
get
(
summary:
'商户 商品系列的详情'
)
do
get
(
summary:
'商户 商品系列的详情'
)
do
...
@@ -159,4 +156,4 @@ RSpec.describe "#{namespace}/products/:product_id/product_series", type: :reques
...
@@ -159,4 +156,4 @@ RSpec.describe "#{namespace}/products/:product_id/product_series", type: :reques
end
end
end
end
end
end
end
end
\ No newline at end of file
lib/generators/templates/spec/requests/merchant/product_snapshot_spec.rb
View file @
b0dc8cc4
...
@@ -77,11 +77,8 @@ RSpec.describe "#{namespace}/product_snapshots", type: :request, capture_example
...
@@ -77,11 +77,8 @@ RSpec.describe "#{namespace}/product_snapshots", type: :request, capture_example
end
end
end
end
path
"/
#{
namespace
}
/product_series/{product_series_id}/product_snapshots/{id}"
do
path
"/
#{
namespace
}
/product_snapshots/{id}"
do
parameter
:product_series_id
,
in: :path
,
type: :string
parameter
:id
,
in: :path
,
type: :string
parameter
:id
,
in: :path
,
type: :string
let
(
:product_series_id
)
{
@series_1
.
id
}
let
(
:id
)
{
@snapshot_1
.
id
}
let
(
:id
)
{
@snapshot_1
.
id
}
get
(
summary:
'商户 商品快照的详情'
)
do
get
(
summary:
'商户 商品快照的详情'
)
do
...
...
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