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
d8aa7e09
Commit
d8aa7e09
authored
Sep 26, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec_output to Product & Series
parent
a00700d7
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
7 deletions
+32
-7
product_spec.rb
...nerators/templates/spec/requests/customer/product_spec.rb
+6
-1
_product.json.jbuilder
lib/generators/templates/views/share/_product.json.jbuilder
+2
-1
_series.json.jbuilder
lib/generators/templates/views/share/_series.json.jbuilder
+3
-3
_series_simple.json.jbuilder
...rators/templates/views/share/_series_simple.json.jbuilder
+3
-2
product.rb
lib/shotengai/product.rb
+9
-0
series.rb
lib/shotengai/series.rb
+9
-0
No files found.
lib/generators/templates/spec/requests/customer/product_spec.rb
View file @
d8aa7e09
...
...
@@ -46,7 +46,12 @@ RSpec.describe "#{namespace}/products", type: :request, capture_examples: true,
consumes
'application/json'
response
(
200
,
description:
'successful'
)
do
it
{
expect
(
JSON
.
parse
(
response
.
body
)[
'series'
].
count
).
to
eq
(
@product_1
.
series
.
count
),
"correct product's series"
body
=
JSON
.
parse
(
response
.
body
)
expect
(
body
[
'series'
].
count
).
to
eq
(
@product_1
.
series
.
count
),
"correct product's series"
# check spec_output
expect
(
body
[
'spec'
]).
to
eq
(
[{
"key"
=>
"大小"
,
"val"
=>
[
"S"
,
"M"
,
"L"
]},
{
"key"
=>
"颜色"
,
"val"
=>
[
"黑色"
,
"红色"
,
"白色"
]}]
)
}
end
end
...
...
lib/generators/templates/views/share/_product.json.jbuilder
View file @
d8aa7e09
json.extract! product, :id, :title, :status, :status_zh,
:need_express, :need_time_attr,
:cover_image, :banners, :spec, :detail, :meta
:cover_image, :banners, :detail, :meta
json.spec product.spec_output
# TODO: NOTE: catalog_list is only vaild in the template example
json.catalog_list product.catalog_list if product.respond_to?(:catalog_list)
json.default_series product.default_series, partial: 'shotengai/share/series_simple', as: :series
...
...
lib/generators/templates/views/share/_series.json.jbuilder
View file @
d8aa7e09
json.extract! series, :id, :title, :original_price, :price,
:stock, :spec, :cover_image, :banners, :meta, :detail,
:shotengai_product_id
\ No newline at end of file
:stock, :cover_image, :banners, :meta, :detail,
:shotengai_product_id
json.spec series.spec_output
lib/generators/templates/views/share/_series_simple.json.jbuilder
View file @
d8aa7e09
json.extract! series, :id, :title, :original_price, :price,
:stock, :spec, :cover_image, :meta, :shotengai_product_id
\ No newline at end of file
:stock, :cover_image, :meta, :shotengai_product_id
json.spec series.spec_output
\ No newline at end of file
lib/shotengai/product.rb
View file @
d8aa7e09
...
...
@@ -71,6 +71,15 @@ module Shotengai
super
||
{}
end
def
spec_output
spec
.
map
{
|
key
,
val
|
{
key:
key
,
val:
val
,
}
}
end
class
<<
self
def
series_class
Shotengai
::
Series
...
...
lib/shotengai/series.rb
View file @
d8aa7e09
...
...
@@ -90,6 +90,15 @@ module Shotengai
def
meta
super
||
{}
end
def
spec_output
spec
.
map
{
|
key
,
val
|
{
key:
key
,
val:
val
,
}
}
end
private
# spec 字段
...
...
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