Commit e608ffd1 by ivan Lan

Fix merchant requests spec

parent 41793608
......@@ -2,7 +2,9 @@ require 'swagger_helper'
namespace = '<%= @namespace %>'
RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, tags: ["#{namespace} API", "order"] do
before do
@products = create_list(:product, 3)
@merchant = create(:merchant)
@products = create_list(:product, 3, manager: @merchant)
@product_1 = @products.first
@series_1 = create(
:product_series,
......@@ -45,6 +47,11 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta
let(:page) { 1 }
let(:per_page) { 100 }
parameter :manager_type, in: :query, type: :string
parameter :manager_id, in: :query, type: :integer
let(:manager_id) { @merchant.id }
let(:manager_type) { @merchant.class.name }
produces 'application/json'
consumes 'application/json'
response(200, description: 'successful') do
......@@ -62,9 +69,13 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta
path "/#{namespace}/orders/{id}" do
parameter 'id', in: :path, type: :string
let(:id) { @order_1.id }
parameter :manager_type, in: :query, type: :string
parameter :manager_id, in: :query, type: :integer
let(:manager_id) { @merchant.id }
let(:manager_type) { @merchant.class.name }
get(summary: '商户 订单详情') do
produces 'application/json'
consumes 'application/json'
......@@ -106,9 +117,13 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta
path "/#{namespace}/orders/{id}/send_out" do
parameter 'id', in: :path, type: :string
let(:id) { @order_1.id }
parameter :manager_type, in: :query, type: :string
parameter :manager_id, in: :query, type: :integer
let(:manager_id) { @merchant.id }
let(:manager_type) { @merchant.class.name }
post(summary: '商户 确认订单开始配送') do
before { @order_1.pay! }
produces 'application/json'
......
......@@ -2,10 +2,12 @@ require 'swagger_helper'
namespace = '<%= @namespace %>'
RSpec.describe "#{namespace}/products/:product_id/product_series", type: :request, capture_examples: true, tags: ["#{namespace} API", "product_series"] do
before do
@merchant = create(:merchant)
@clothes = Catalog.create!(name: '衣服')
@jacket = Catalog.create!(name: '上衣', super_catalog: @clothes)
@products = create_list(:product, 3)
@products = create_list(:product, 3, manager: @merchant)
@product_1 = @products.first
@product_1.update(catalog_list: ['衣服'])
@series_1 = create(
......@@ -31,11 +33,19 @@ RSpec.describe "#{namespace}/products/:product_id/product_series", type: :reques
parameter :product_id, in: :path, type: :string
let(:product_id) { @product_1.id }
parameter :manager_type, in: :query, type: :string
parameter :manager_id, in: :query, type: :integer
let(:manager_id) { @merchant.id }
let(:manager_type) { @merchant.class.name }
get(summary: '商家 某商品的 商品系列 列表') do
parameter :manager_type, in: :query, type: :string
parameter :manager_id, in: :query, type: :integer
let(:manager_id) { @merchant.id }
let(:manager_type) { @merchant.class.name }
parameter :page, in: :query, type: :string
parameter :per_page, in: :query, type: :string
let(:page) { 1 }
let(:per_page) { 100 }
......@@ -106,6 +116,11 @@ RSpec.describe "#{namespace}/products/:product_id/product_series", type: :reques
parameter :id, in: :path, type: :string
let(:id) { @series_1.id }
parameter :manager_type, in: :query, type: :string
parameter :manager_id, in: :query, type: :integer
let(:manager_id) { @merchant.id }
let(:manager_type) { @merchant.class.name }
get(summary: '商户 商品系列的详情') do
produces 'application/json'
consumes 'application/json'
......
......@@ -2,7 +2,8 @@ require 'swagger_helper'
namespace = '<%= @namespace %>'
RSpec.describe "#{namespace}/product_snapshots", type: :request, capture_examples: true, tags: ["#{namespace} API", "product_snapshots"] do
before do
@products = create_list(:product, 3)
@merchant = create(:merchant)
@products = create_list(:product, 3, manager: @merchant)
@product_1 = @products.first
@series_1 = create(
......@@ -37,6 +38,11 @@ RSpec.describe "#{namespace}/product_snapshots", type: :request, capture_example
parameter :product_id, in: :path, type: :string
let(:product_series_id) { @series_1.id }
parameter :manager_type, in: :query, type: :string
parameter :manager_id, in: :query, type: :integer
let(:manager_id) { @merchant.id }
let(:manager_type) { @merchant.class.name }
get(summary: '商家 (某商品系列中) 的已“在订单中”的快照列表') do
parameter :page, in: :query, type: :string
......@@ -59,6 +65,11 @@ RSpec.describe "#{namespace}/product_snapshots", type: :request, capture_example
parameter :order_id, in: :path, type: :string
let(:order_id) { @order.id }
parameter :manager_type, in: :query, type: :string
parameter :manager_id, in: :query, type: :integer
let(:manager_id) { @merchant.id }
let(:manager_type) { @merchant.class.name }
get(summary: '商家 (某订单中) 的快照列表') do
parameter :page, in: :query, type: :string
......@@ -81,6 +92,11 @@ RSpec.describe "#{namespace}/product_snapshots", type: :request, capture_example
parameter :id, in: :path, type: :string
let(:id) { @snapshot_1.id }
parameter :manager_type, in: :query, type: :string
parameter :manager_id, in: :query, type: :integer
let(:manager_id) { @merchant.id }
let(:manager_type) { @merchant.class.name }
get(summary: '商户 商品快照的详情') do
produces 'application/json'
consumes 'application/json'
......
......@@ -8,13 +8,17 @@ RSpec.describe "#{namespace}/products", type: :request, capture_examples: true,
@clothes = Catalog.create!(name: '衣服')
@jacket = Catalog.create!(name: '上衣', super_catalog: @clothes)
@products = create_list(:product, 3)
@products = create_list(:product, 3, manager: @merchant)
@product_1 = @products.first
@product_1.update(catalog_list: ['衣服'])
@series = create(:product_series, product: @product_1)
end
path "/#{namespace}/products" do
parameter :manager_type, in: :query, type: :string
parameter :manager_id, in: :query, type: :integer
let(:manager_id) { @merchant.id }
let(:manager_type) { @merchant.class.name }
get(summary: '商家 商品列表') do
parameter :manager_type, in: :query, type: :string
......@@ -110,9 +114,13 @@ RSpec.describe "#{namespace}/products", type: :request, capture_examples: true,
path "/#{namespace}/products/{id}" do
parameter 'id', in: :path, type: :string
let(:id) { @product_1.id }
parameter :manager_type, in: :query, type: :string
parameter :manager_id, in: :query, type: :integer
let(:manager_id) { @merchant.id }
let(:manager_type) { @merchant.class.name }
get(summary: '商户 商品详情') do
parameter :manager_type, in: :query, type: :string
parameter :manager_id, in: :query, type: :integer
......@@ -192,9 +200,13 @@ RSpec.describe "#{namespace}/products", type: :request, capture_examples: true,
path "/#{namespace}/products/{id}/put_on_shelf" do
parameter 'id', in: :path, type: :string
let(:id) { @product_1.id }
parameter :manager_type, in: :query, type: :string
parameter :manager_id, in: :query, type: :integer
let(:manager_id) { @merchant.id }
let(:manager_type) { @merchant.class.name }
post(summary: '商户 上架商品') do
parameter :manager_type, in: :query, type: :string
parameter :manager_id, in: :query, type: :integer
......@@ -211,9 +223,13 @@ RSpec.describe "#{namespace}/products", type: :request, capture_examples: true,
path "/#{namespace}/products/{id}/sold_out" do
parameter 'id', in: :path, type: :string
let(:id) { @product_1.id }
parameter :manager_type, in: :query, type: :string
parameter :manager_id, in: :query, type: :integer
let(:manager_id) { @merchant.id }
let(:manager_type) { @merchant.class.name }
post(summary: '商户 下架商品') do
parameter :manager_type, in: :query, type: :string
parameter :manager_id, in: :query, type: :integer
......
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