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
970bb3d2
Commit
970bb3d2
authored
Sep 12, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve spec
parent
dabd39b9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
5 deletions
+42
-5
order_spec.rb
...generators/templates/spec/requests/customer/order_spec.rb
+41
-4
product_snapshot_spec.rb
...templates/spec/requests/customer/product_snapshot_spec.rb
+0
-0
product_snapshot_spec.rb
...templates/spec/requests/merchant/product_snapshot_spec.rb
+1
-1
No files found.
lib/generators/templates/spec/requests/customer/order_spec.rb
View file @
970bb3d2
...
@@ -54,7 +54,7 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta
...
@@ -54,7 +54,7 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta
path
"/
#{
namespace
}
/cart/product_snapshots"
do
path
"/
#{
namespace
}
/cart/product_snapshots"
do
post
(
summary:
'用户 添加快照至购物车( using series_id & count )'
)
do
post
(
summary:
'用户 添加快照至购物车( using s
hotengai_s
eries_id & count )'
)
do
produces
'application/json'
produces
'application/json'
consumes
'application/json'
consumes
'application/json'
parameter
:buyer_type
,
in: :query
,
type: :string
parameter
:buyer_type
,
in: :query
,
type: :string
...
@@ -92,6 +92,9 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta
...
@@ -92,6 +92,9 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta
end
end
path
"/
#{
namespace
}
/orders/{id}/product_snapshots"
do
path
"/
#{
namespace
}
/orders/{id}/product_snapshots"
do
parameter
:id
,
in: :path
,
type: :integer
let
(
:id
)
{
@order_1
.
id
}
get
(
summary:
'某订单的 order 所有snapshots'
)
do
get
(
summary:
'某订单的 order 所有snapshots'
)
do
produces
'application/json'
produces
'application/json'
consumes
'application/json'
consumes
'application/json'
...
@@ -100,14 +103,12 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta
...
@@ -100,14 +103,12 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta
let
(
:buyer_id
)
{
@user
.
id
}
let
(
:buyer_id
)
{
@user
.
id
}
let
(
:buyer_type
)
{
@user
.
class
.
name
}
let
(
:buyer_type
)
{
@user
.
class
.
name
}
parameter
:id
,
in: :path
,
type: :integer
parameter
:page
,
in: :query
,
type: :string
parameter
:page
,
in: :query
,
type: :string
parameter
:per_page
,
in: :query
,
type: :string
parameter
:per_page
,
in: :query
,
type: :string
let
(
:page
)
{
1
}
let
(
:page
)
{
1
}
let
(
:per_page
)
{
100
}
let
(
:per_page
)
{
100
}
let
(
:id
)
{
@order_1
.
id
}
before
do
before
do
@orders
.
last
.
product_snapshots
.
create!
(
@orders
.
last
.
product_snapshots
.
create!
(
...
@@ -123,6 +124,42 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta
...
@@ -123,6 +124,42 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta
}
}
end
end
end
end
post
(
summary:
'用户 添加快照至订单( using shotengai_series_id & count )'
)
do
produces
'application/json'
consumes
'application/json'
parameter
:buyer_type
,
in: :query
,
type: :string
parameter
:buyer_id
,
in: :query
,
type: :integer
let
(
:buyer_id
)
{
@user
.
id
}
let
(
:buyer_type
)
{
@user
.
class
.
name
}
parameter
:product_snapshot
,
in: :body
,
schema:
{
type: :object
,
properties:
{
product_snapshot:
{
type: :object
,
properties:
{
shotengai_series_id:
{
type: :integer
},
count:
{
type: :integer
},
}
}
}
}
before
{
@order_1_snapshots_count_was
=
@order_1
.
snapshots
.
count
}
response
(
201
,
description:
'Create snapshot and add it to the cart'
)
do
let
(
:product_snapshot
)
{
{
product_snapshot:
{
shotengai_series_id:
@series_1
.
id
,
count:
10
,
}
}
}
it
{
expect
(
JSON
.
parse
(
response
.
body
)[
'count'
]).
to
eq
(
10
)
expect
(
@order_1
.
snapshots
.
count
).
to
eq
(
@order_1_snapshots_count_was
+
1
)
}
end
end
end
end
path
"/
#{
namespace
}
/orders"
do
path
"/
#{
namespace
}
/orders"
do
...
...
lib/generators/templates/spec/requests/customer/product_snapshot_spec.rb
View file @
970bb3d2
This diff is collapsed.
Click to expand it.
lib/generators/templates/spec/requests/merchant/product_snapshot_spec.rb
View file @
970bb3d2
...
@@ -27,7 +27,7 @@ RSpec.describe "#{namespace}/product_snapshots", type: :request, capture_example
...
@@ -27,7 +27,7 @@ RSpec.describe "#{namespace}/product_snapshots", type: :request, capture_example
@snapshot_other
=
create
(
:product_snapshot
,
series:
@series_2
,
count:
5
)
@snapshot_other
=
create
(
:product_snapshot
,
series:
@series_2
,
count:
5
)
@order
=
create
(
:order
)
@order
=
create
(
:order
)
@cart
=
Order
::
Cart
.
create!
@cart
=
create
(
:user
).
order_cart
@snapshot_1
.
update!
(
order:
@order
)
@snapshot_1
.
update!
(
order:
@order
)
@snapshot_other
.
update!
(
order:
@order
)
@snapshot_other
.
update!
(
order:
@order
)
@snapshot_2
.
update!
(
order_cart:
@cart
)
@snapshot_2
.
update!
(
order_cart:
@cart
)
...
...
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