Commit b0dc8cc4 by ivan Lan

Add shallow to routes & Improve request spec

parent 5796caca
...@@ -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
...@@ -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
......
...@@ -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 MyCatalog
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
......
...@@ -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
......
...@@ -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}/products/{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
......
...@@ -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}/products/{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
......
...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment