Commit b0dc8cc4 by ivan Lan

Add shallow to routes & Improve request spec

parent 5796caca
......@@ -8,3 +8,4 @@
/spec/reports/
/tmp/
/mysql.yml
/.rspec_status
\ No newline at end of file
......@@ -64,20 +64,20 @@ module Shotengai
product, order = @product.underscore, @order.underscore
"
namespace :#{@namespace.to_sym} do
resources :#{product.pluralize} do
resources :#{product.pluralize}, shallow: true do
member do
post :put_on_shelf
post :sold_out
end
resources :#{product}_series
end
resources :#{order.pluralize}, only: [:index, :show, :update] do
resources :#{order.pluralize}, only: [:index, :show, :update], shallow: true do
member do
post :send_out
end
resources :#{product}_snapshots, only: [:index, :show, :update]
end
resources :#{product}_series do #, excpet: :index
resources :#{product}_series, shallow: true do #, excpet: :index
resources :#{product}_snapshots, only: [:index, :show, :update]
end
end
......@@ -88,11 +88,11 @@ module Shotengai
product, order = @product.underscore, @order.underscore
"
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]
end
resources :#{product}_snapshots, only: [:index, :show]
resources :#{order.pluralize} do
resources :#{order.pluralize}, shallow: true do
member do
post :pay
post :cancel
......
......@@ -11,7 +11,7 @@ module Shotengai
Use --catalog to custom your own catalog class
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:
create app/models/my_product.rb
create app/models/my_product_series.rb
......
......@@ -18,7 +18,7 @@ module Shotengai
options.values_at(:customer, :merchant, :product, :order)
Dir["#{self.class.source_root}/**/*.rb"].each do |path|
relative_path = path.gsub(self.class.source_root, '')
template path, "app/spec/shotengai/#{relative_path}"
template path, "spec/shotengai/#{relative_path}"
end
end
end
......
......@@ -46,11 +46,9 @@ RSpec.describe "#{namespace}/products/:product_id/product_series", type: :reques
end
end
path "/#{namespace}/products/{product_id}/product_series/{id}" do
path "/#{namespace}/product_series/{id}" do
parameter :id, in: :path, type: :string
parameter :product_id, in: :path, type: :string
let(:product_id) { @product_1.id }
let(:id) { @series_1.id }
get(summary: '用户 商品系列的详情') do
......
......@@ -102,11 +102,8 @@ RSpec.describe "#{namespace}/products/:product_id/product_series", type: :reques
end
end
path "/#{namespace}/products/{product_id}/product_series/{id}" do
path "/#{namespace}/product_series/{id}" do
parameter :id, in: :path, type: :string
parameter :product_id, in: :path, type: :string
let(:product_id) { @product_1.id }
let(:id) { @series_1.id }
get(summary: '商户 商品系列的详情') do
......
......@@ -77,11 +77,8 @@ RSpec.describe "#{namespace}/product_snapshots", type: :request, capture_example
end
end
path "/#{namespace}/product_series/{product_series_id}/product_snapshots/{id}" do
parameter :product_series_id, in: :path, type: :string
path "/#{namespace}/product_snapshots/{id}" do
parameter :id, in: :path, type: :string
let(:product_series_id) { @series_1.id }
let(:id) { @snapshot_1.id }
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