spree_sample 3.1.14 → 3.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/db/samples/adjustments.rb +16 -14
- data/db/samples/assets.rb +74 -38
- data/db/samples/option_types.rb +12 -8
- data/db/samples/option_values.rb +34 -30
- data/db/samples/orders.rb +28 -24
- data/db/samples/payment_methods.rb +10 -14
- data/db/samples/payments.rb +13 -6
- data/db/samples/product_properties.rb +15 -15
- data/db/samples/products.rb +77 -90
- data/db/samples/prototypes.rb +10 -9
- data/db/samples/shipping_categories.rb +1 -1
- data/db/samples/shipping_methods.rb +26 -24
- data/db/samples/stock.rb +9 -2
- data/db/samples/tax_categories.rb +2 -2
- data/db/samples/tax_rates.rb +8 -7
- data/db/samples/taxonomies.rb +2 -2
- data/db/samples/taxons.rb +68 -66
- data/db/samples/variants.rb +77 -73
- data/lib/tasks/sample.rake +1 -1
- data/spec/lib/load_sample_spec.rb +18 -0
- data/spec/spec_helper.rb +23 -0
- data/spree_sample.gemspec +2 -2
- metadata +10 -8
data/db/samples/stock.rb
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
Spree::Sample.load_sample("variants")
|
2
2
|
|
3
3
|
country = Spree::Country.find_by(iso: 'US')
|
4
|
-
location = Spree::StockLocation.first_or_create!
|
4
|
+
location = Spree::StockLocation.first_or_create!(name: 'default',
|
5
|
+
address1: 'Example Street',
|
6
|
+
city: 'City',
|
7
|
+
zipcode: '12345',
|
8
|
+
country: country,
|
9
|
+
state: country.states.first)
|
5
10
|
location.active = true
|
6
11
|
location.save!
|
7
12
|
|
8
13
|
Spree::Variant.all.each do |variant|
|
14
|
+
next if variant.is_master? && variant.product.has_variants?
|
15
|
+
|
9
16
|
variant.stock_items.each do |stock_item|
|
10
|
-
Spree::StockMovement.create(:
|
17
|
+
Spree::StockMovement.create(quantity: 10, stock_item: stock_item)
|
11
18
|
end
|
12
19
|
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
Spree::TaxCategory.
|
2
|
-
Spree::TaxCategory.
|
1
|
+
Spree::TaxCategory.where(name: 'Clothing').first_or_create!
|
2
|
+
Spree::TaxCategory.where(name: 'Food').first_or_create!
|
data/db/samples/tax_rates.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
north_america = Spree::Zone.find_by_name!("North America")
|
2
2
|
clothing = Spree::TaxCategory.find_by_name!("Clothing")
|
3
|
-
|
4
|
-
|
5
|
-
:
|
6
|
-
:
|
7
|
-
:
|
8
|
-
|
9
|
-
tax_rate.
|
3
|
+
|
4
|
+
Spree::TaxRate.where(
|
5
|
+
name: "North America",
|
6
|
+
zone: north_america,
|
7
|
+
amount: 0.05,
|
8
|
+
tax_category: clothing).first_or_create! do |tax_rate|
|
9
|
+
tax_rate.calculator = Spree::Calculator::DefaultTax.create!
|
10
|
+
end
|
data/db/samples/taxonomies.rb
CHANGED
data/db/samples/taxons.rb
CHANGED
@@ -1,45 +1,44 @@
|
|
1
1
|
Spree::Sample.load_sample("taxonomies")
|
2
2
|
Spree::Sample.load_sample("products")
|
3
3
|
|
4
|
-
categories = Spree::Taxonomy.find_by_name!(
|
4
|
+
categories = Spree::Taxonomy.find_by_name!(I18n.t('spree.taxonomy_brands_name'))
|
5
5
|
brands = Spree::Taxonomy.find_by_name!("Brand")
|
6
6
|
|
7
|
-
products = {
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
7
|
+
products = {
|
8
|
+
ror_tote: "Ruby on Rails Tote",
|
9
|
+
ror_bag: "Ruby on Rails Bag",
|
10
|
+
ror_mug: "Ruby on Rails Mug",
|
11
|
+
ror_stein: "Ruby on Rails Stein",
|
12
|
+
ror_baseball_jersey: "Ruby on Rails Baseball Jersey",
|
13
|
+
ror_jr_spaghetti: "Ruby on Rails Jr. Spaghetti",
|
14
|
+
ror_ringer: "Ruby on Rails Ringer T-Shirt",
|
15
|
+
spree_stein: "Spree Stein",
|
16
|
+
spree_mug: "Spree Mug",
|
17
|
+
spree_ringer: "Spree Ringer T-Shirt",
|
18
|
+
spree_baseball_jersey: "Spree Baseball Jersey",
|
19
|
+
spree_tote: "Spree Tote",
|
20
|
+
spree_bag: "Spree Bag",
|
21
|
+
spree_jr_spaghetti: "Spree Jr. Spaghetti",
|
22
|
+
apache_baseball_jersey: "Apache Baseball Jersey",
|
23
|
+
ruby_baseball_jersey: "Ruby Baseball Jersey",
|
24
24
|
}
|
25
25
|
|
26
|
-
|
27
26
|
products.each do |key, name|
|
28
27
|
products[key] = Spree::Product.find_by_name!(name)
|
29
28
|
end
|
30
29
|
|
31
30
|
taxons = [
|
32
31
|
{
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
32
|
+
name: I18n.t('spree.taxonomy_brands_name'),
|
33
|
+
taxonomy: categories,
|
34
|
+
position: 0
|
36
35
|
},
|
37
36
|
{
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
37
|
+
name: "Bags",
|
38
|
+
taxonomy: categories,
|
39
|
+
parent: I18n.t('spree.taxonomy_brands_name'),
|
40
|
+
position: 1,
|
41
|
+
products: [
|
43
42
|
products[:ror_tote],
|
44
43
|
products[:ror_bag],
|
45
44
|
products[:spree_tote],
|
@@ -47,11 +46,11 @@ taxons = [
|
|
47
46
|
]
|
48
47
|
},
|
49
48
|
{
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
49
|
+
name: "Mugs",
|
50
|
+
taxonomy: categories,
|
51
|
+
parent: I18n.t('spree.taxonomy_brands_name'),
|
52
|
+
position: 2,
|
53
|
+
products: [
|
55
54
|
products[:ror_mug],
|
56
55
|
products[:ror_stein],
|
57
56
|
products[:spree_stein],
|
@@ -59,25 +58,25 @@ taxons = [
|
|
59
58
|
]
|
60
59
|
},
|
61
60
|
{
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
61
|
+
name: "Clothing",
|
62
|
+
taxonomy: categories,
|
63
|
+
parent: I18n.t('spree.taxonomy_brands_name')
|
65
64
|
},
|
66
65
|
{
|
67
|
-
:
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
71
|
-
:
|
66
|
+
name: "Shirts",
|
67
|
+
taxonomy: categories,
|
68
|
+
parent: "Clothing",
|
69
|
+
position: 0,
|
70
|
+
products: [
|
72
71
|
products[:ror_jr_spaghetti],
|
73
72
|
products[:spree_jr_spaghetti]
|
74
73
|
]
|
75
74
|
},
|
76
75
|
{
|
77
|
-
:
|
78
|
-
:
|
79
|
-
:
|
80
|
-
:
|
76
|
+
name: "T-Shirts",
|
77
|
+
taxonomy: categories,
|
78
|
+
parent: "Clothing",
|
79
|
+
products: [
|
81
80
|
products[:ror_baseball_jersey],
|
82
81
|
products[:ror_ringer],
|
83
82
|
products[:apache_baseball_jersey],
|
@@ -85,33 +84,33 @@ taxons = [
|
|
85
84
|
products[:spree_baseball_jersey],
|
86
85
|
products[:spree_ringer]
|
87
86
|
],
|
88
|
-
:
|
87
|
+
position: 0
|
89
88
|
},
|
90
89
|
{
|
91
|
-
:
|
92
|
-
:
|
90
|
+
name: I18n.t('spree.taxonomy_brands_name'),
|
91
|
+
taxonomy: brands
|
93
92
|
},
|
94
93
|
{
|
95
|
-
:
|
96
|
-
:
|
97
|
-
:
|
98
|
-
:
|
94
|
+
name: "Ruby",
|
95
|
+
taxonomy: brands,
|
96
|
+
parent: I18n.t('spree.taxonomy_brands_name'),
|
97
|
+
products: [
|
99
98
|
products[:ruby_baseball_jersey]
|
100
99
|
]
|
101
100
|
},
|
102
101
|
{
|
103
|
-
:
|
104
|
-
:
|
105
|
-
:
|
106
|
-
:
|
102
|
+
name: "Apache",
|
103
|
+
taxonomy: brands,
|
104
|
+
parent: I18n.t('spree.taxonomy_brands_name'),
|
105
|
+
products: [
|
107
106
|
products[:apache_baseball_jersey]
|
108
107
|
]
|
109
108
|
},
|
110
109
|
{
|
111
|
-
:
|
112
|
-
:
|
113
|
-
:
|
114
|
-
:
|
110
|
+
name: "Spree",
|
111
|
+
taxonomy: brands,
|
112
|
+
parent: I18n.t('spree.taxonomy_brands_name'),
|
113
|
+
products: [
|
115
114
|
products[:spree_stein],
|
116
115
|
products[:spree_mug],
|
117
116
|
products[:spree_ringer],
|
@@ -122,10 +121,10 @@ taxons = [
|
|
122
121
|
]
|
123
122
|
},
|
124
123
|
{
|
125
|
-
:
|
126
|
-
:
|
127
|
-
:
|
128
|
-
:
|
124
|
+
name: "Rails",
|
125
|
+
taxonomy: brands,
|
126
|
+
parent: I18n.t('spree.taxonomy_brands_name'),
|
127
|
+
products: [
|
129
128
|
products[:ror_tote],
|
130
129
|
products[:ror_bag],
|
131
130
|
products[:ror_mug],
|
@@ -138,8 +137,11 @@ taxons = [
|
|
138
137
|
]
|
139
138
|
|
140
139
|
taxons.each do |taxon_attrs|
|
141
|
-
|
142
|
-
|
143
|
-
|
140
|
+
parent = Spree::Taxon.where(name: taxon_attrs[:parent]).first
|
141
|
+
taxonomy = taxon_attrs[:taxonomy]
|
142
|
+
Spree::Taxon.where(name: taxon_attrs[:name]).first_or_create! do |taxon|
|
143
|
+
taxon.parent = parent
|
144
|
+
taxon.taxonomy = taxonomy
|
145
|
+
taxon.products = taxon_attrs[:products] if taxon_attrs[:products]
|
144
146
|
end
|
145
147
|
end
|
data/db/samples/variants.rb
CHANGED
@@ -29,135 +29,139 @@ green = Spree::OptionValue.where(name: "Green").first
|
|
29
29
|
|
30
30
|
variants = [
|
31
31
|
{
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
32
|
+
product: ror_baseball_jersey,
|
33
|
+
option_values: [small, red],
|
34
|
+
sku: "ROR-00001",
|
35
|
+
cost_price: 17
|
36
36
|
},
|
37
37
|
{
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
38
|
+
product: ror_baseball_jersey,
|
39
|
+
option_values: [small, blue],
|
40
|
+
sku: "ROR-00002",
|
41
|
+
cost_price: 17
|
42
42
|
},
|
43
43
|
{
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
44
|
+
product: ror_baseball_jersey,
|
45
|
+
option_values: [small, green],
|
46
|
+
sku: "ROR-00003",
|
47
|
+
cost_price: 17
|
48
48
|
},
|
49
49
|
{
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
50
|
+
product: ror_baseball_jersey,
|
51
|
+
option_values: [medium, red],
|
52
|
+
sku: "ROR-00004",
|
53
|
+
cost_price: 17
|
54
54
|
},
|
55
55
|
{
|
56
|
-
:
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
56
|
+
product: ror_baseball_jersey,
|
57
|
+
option_values: [medium, blue],
|
58
|
+
sku: "ROR-00005",
|
59
|
+
cost_price: 17
|
60
60
|
},
|
61
61
|
{
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
62
|
+
product: ror_baseball_jersey,
|
63
|
+
option_values: [medium, green],
|
64
|
+
sku: "ROR-00006",
|
65
|
+
cost_price: 17
|
66
66
|
},
|
67
67
|
{
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
71
|
-
:
|
68
|
+
product: ror_baseball_jersey,
|
69
|
+
option_values: [large, red],
|
70
|
+
sku: "ROR-00007",
|
71
|
+
cost_price: 17
|
72
72
|
},
|
73
73
|
{
|
74
|
-
:
|
75
|
-
:
|
76
|
-
:
|
77
|
-
:
|
74
|
+
product: ror_baseball_jersey,
|
75
|
+
option_values: [large, blue],
|
76
|
+
sku: "ROR-00008",
|
77
|
+
cost_price: 17
|
78
78
|
},
|
79
79
|
{
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
80
|
+
product: ror_baseball_jersey,
|
81
|
+
option_values: [large, green],
|
82
|
+
sku: "ROR-00009",
|
83
|
+
cost_price: 17
|
84
84
|
},
|
85
85
|
{
|
86
|
-
:
|
87
|
-
:
|
88
|
-
:
|
89
|
-
:
|
86
|
+
product: ror_baseball_jersey,
|
87
|
+
option_values: [extra_large, green],
|
88
|
+
sku: "ROR-00010",
|
89
|
+
cost_price: 17
|
90
90
|
},
|
91
91
|
]
|
92
92
|
|
93
93
|
masters = {
|
94
94
|
ror_baseball_jersey => {
|
95
|
-
:
|
96
|
-
:
|
95
|
+
sku: "ROR-001",
|
96
|
+
cost_price: 17,
|
97
97
|
},
|
98
98
|
ror_tote => {
|
99
|
-
:
|
100
|
-
:
|
99
|
+
sku: "ROR-00011",
|
100
|
+
cost_price: 17
|
101
101
|
},
|
102
102
|
ror_bag => {
|
103
|
-
:
|
104
|
-
:
|
103
|
+
sku: "ROR-00012",
|
104
|
+
cost_price: 21
|
105
105
|
},
|
106
106
|
ror_jr_spaghetti => {
|
107
|
-
:
|
108
|
-
:
|
107
|
+
sku: "ROR-00013",
|
108
|
+
cost_price: 17
|
109
109
|
},
|
110
110
|
ror_mug => {
|
111
|
-
:
|
112
|
-
:
|
111
|
+
sku: "ROR-00014",
|
112
|
+
cost_price: 11
|
113
113
|
},
|
114
114
|
ror_ringer => {
|
115
|
-
:
|
116
|
-
:
|
115
|
+
sku: "ROR-00015",
|
116
|
+
cost_price: 17
|
117
117
|
},
|
118
118
|
ror_stein => {
|
119
|
-
:
|
120
|
-
:
|
119
|
+
sku: "ROR-00016",
|
120
|
+
cost_price: 15
|
121
121
|
},
|
122
122
|
apache_baseball_jersey => {
|
123
|
-
:
|
124
|
-
:
|
123
|
+
sku: "APC-00001",
|
124
|
+
cost_price: 17
|
125
125
|
},
|
126
126
|
ruby_baseball_jersey => {
|
127
|
-
:
|
128
|
-
:
|
127
|
+
sku: "RUB-00001",
|
128
|
+
cost_price: 17
|
129
129
|
},
|
130
130
|
spree_baseball_jersey => {
|
131
|
-
:
|
132
|
-
:
|
131
|
+
sku: "SPR-00001",
|
132
|
+
cost_price: 17
|
133
133
|
},
|
134
134
|
spree_stein => {
|
135
|
-
:
|
136
|
-
:
|
135
|
+
sku: "SPR-00016",
|
136
|
+
cost_price: 15
|
137
137
|
},
|
138
138
|
spree_jr_spaghetti => {
|
139
|
-
:
|
140
|
-
:
|
139
|
+
sku: "SPR-00013",
|
140
|
+
cost_price: 17
|
141
141
|
},
|
142
142
|
spree_mug => {
|
143
|
-
:
|
144
|
-
:
|
143
|
+
sku: "SPR-00014",
|
144
|
+
cost_price: 11
|
145
145
|
},
|
146
146
|
spree_ringer => {
|
147
|
-
:
|
148
|
-
:
|
147
|
+
sku: "SPR-00015",
|
148
|
+
cost_price: 17
|
149
149
|
},
|
150
150
|
spree_tote => {
|
151
|
-
:
|
152
|
-
:
|
151
|
+
sku: "SPR-00011",
|
152
|
+
cost_price: 13
|
153
153
|
},
|
154
154
|
spree_bag => {
|
155
|
-
:
|
156
|
-
:
|
155
|
+
sku: "SPR-00012",
|
156
|
+
cost_price: 21
|
157
157
|
}
|
158
158
|
}
|
159
159
|
|
160
|
-
|
160
|
+
variants.each do |attrs|
|
161
|
+
if Spree::Variant.where(product_id: attrs[:product].id, sku: attrs[:sku]).none?
|
162
|
+
Spree::Variant.create!(attrs)
|
163
|
+
end
|
164
|
+
end
|
161
165
|
|
162
166
|
masters.each do |product, variant_attrs|
|
163
167
|
product.master.update_attributes!(variant_attrs)
|