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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 032fbbb9b2a5a9b5bb0c978357797bbbfccc692c
|
4
|
+
data.tar.gz: 169d8e099c36086d2cc036f18959de1a0aa09990
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f799e7f012c903e4885fa9e94aa782a47ff3cc3a2a97bfaf8563e121bc6ca3d970d8c0130d274f01de1e0678fe63c946acac5f61b0687a1c3b5291eb80ee4a3a
|
7
|
+
data.tar.gz: 2058b2b9c55ab25c671cecc0d6d0ae1b2e8da832611cdc46b518fcac88c8efc9c0f130b6a7e799770d71d186d28a189dd8c84c0325fa77ea66e99998b0a35da0
|
data/Gemfile
CHANGED
data/db/samples/adjustments.rb
CHANGED
@@ -3,18 +3,20 @@ Spree::Sample.load_sample("orders")
|
|
3
3
|
first_order = Spree::Order.find_by_number!("R123456789")
|
4
4
|
last_order = Spree::Order.find_by_number!("R987654321")
|
5
5
|
|
6
|
-
first_order.adjustments.
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
|
6
|
+
first_order.adjustments.where(
|
7
|
+
source: Spree::TaxRate.find_by_name!("North America"),
|
8
|
+
order: first_order,
|
9
|
+
label: "Tax",
|
10
|
+
state: "open",
|
11
|
+
mandatory: true).first_or_create! do |adj|
|
12
|
+
adj.amount = 0
|
13
|
+
end
|
13
14
|
|
14
|
-
last_order.adjustments.
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
|
15
|
+
last_order.adjustments.where(
|
16
|
+
source: Spree::TaxRate.find_by_name!("North America"),
|
17
|
+
order: last_order,
|
18
|
+
label: "Tax",
|
19
|
+
state: "open",
|
20
|
+
mandatory: true).first_or_create! do |adj|
|
21
|
+
adj.amount = 0
|
22
|
+
end
|
data/db/samples/assets.rb
CHANGED
@@ -2,7 +2,7 @@ Spree::Sample.load_sample("products")
|
|
2
2
|
Spree::Sample.load_sample("variants")
|
3
3
|
|
4
4
|
products = {}
|
5
|
-
products[:ror_baseball_jersey] = Spree::Product.find_by_name!("Ruby on Rails Baseball Jersey")
|
5
|
+
products[:ror_baseball_jersey] = Spree::Product.find_by_name!("Ruby on Rails Baseball Jersey")
|
6
6
|
products[:ror_tote] = Spree::Product.find_by_name!("Ruby on Rails Tote")
|
7
7
|
products[:ror_bag] = Spree::Product.find_by_name!("Ruby on Rails Bag")
|
8
8
|
products[:ror_jr_spaghetti] = Spree::Product.find_by_name!("Ruby on Rails Jr. Spaghetti")
|
@@ -19,141 +19,177 @@ products[:spree_bag] = Spree::Product.find_by_name!("Spree Bag")
|
|
19
19
|
products[:ruby_baseball_jersey] = Spree::Product.find_by_name!("Ruby Baseball Jersey")
|
20
20
|
products[:apache_baseball_jersey] = Spree::Product.find_by_name!("Apache Baseball Jersey")
|
21
21
|
|
22
|
-
|
23
|
-
def image(name, type="jpeg")
|
22
|
+
def image(name, type = "jpeg")
|
24
23
|
images_path = Pathname.new(File.dirname(__FILE__)) + "images"
|
25
|
-
path = images_path +
|
24
|
+
path = images_path + file_name(name, type)
|
26
25
|
return false if !File.exist?(path)
|
27
26
|
File.open(path)
|
28
27
|
end
|
29
28
|
|
29
|
+
def file_name(name, type = "jpeg")
|
30
|
+
"#{name}.#{type}"
|
31
|
+
end
|
32
|
+
|
30
33
|
images = {
|
31
34
|
products[:ror_tote].master => [
|
32
35
|
{
|
33
|
-
:
|
36
|
+
name: file_name("ror_tote"),
|
37
|
+
attachment: image("ror_tote")
|
34
38
|
},
|
35
39
|
{
|
36
|
-
:
|
40
|
+
name: file_name("ror_tote_back"),
|
41
|
+
attachment: image("ror_tote_back")
|
37
42
|
}
|
38
43
|
],
|
39
44
|
products[:ror_bag].master => [
|
40
45
|
{
|
41
|
-
:
|
46
|
+
name: file_name("ror_bag"),
|
47
|
+
attachment: image("ror_bag")
|
42
48
|
}
|
43
49
|
],
|
44
50
|
products[:ror_baseball_jersey].master => [
|
45
51
|
{
|
46
|
-
:
|
52
|
+
name: file_name("ror_baseball"),
|
53
|
+
attachment: image("ror_baseball")
|
47
54
|
},
|
48
55
|
{
|
49
|
-
:
|
56
|
+
name: file_name("ror_baseball_back"),
|
57
|
+
attachment: image("ror_baseball_back")
|
50
58
|
}
|
51
59
|
],
|
52
60
|
products[:ror_jr_spaghetti].master => [
|
53
61
|
{
|
54
|
-
:
|
62
|
+
name: file_name("ror_jr_spaghetti"),
|
63
|
+
attachment: image("ror_jr_spaghetti")
|
55
64
|
}
|
56
65
|
],
|
57
66
|
products[:ror_mug].master => [
|
58
67
|
{
|
59
|
-
:
|
68
|
+
name: file_name("ror_mug"),
|
69
|
+
attachment: image("ror_mug")
|
60
70
|
},
|
61
71
|
{
|
62
|
-
:
|
72
|
+
name: file_name("ror_mug_back"),
|
73
|
+
attachment: image("ror_mug_back")
|
63
74
|
}
|
64
75
|
],
|
65
76
|
products[:ror_ringer].master => [
|
66
77
|
{
|
67
|
-
:
|
78
|
+
name: file_name("ror_ringer"),
|
79
|
+
attachment: image("ror_ringer")
|
68
80
|
},
|
69
81
|
{
|
70
|
-
:
|
82
|
+
name: file_name("ror_ringer_back"),
|
83
|
+
attachment: image("ror_ringer_back")
|
71
84
|
}
|
72
85
|
],
|
73
86
|
products[:ror_stein].master => [
|
74
87
|
{
|
75
|
-
:
|
88
|
+
name: file_name("ror_stein"),
|
89
|
+
attachment: image("ror_stein")
|
76
90
|
},
|
77
91
|
{
|
78
|
-
:
|
92
|
+
name: file_name("ror_stein_back"),
|
93
|
+
attachment: image("ror_stein_back")
|
79
94
|
}
|
80
95
|
],
|
81
96
|
products[:apache_baseball_jersey].master => [
|
82
97
|
{
|
83
|
-
:
|
98
|
+
name: file_name("apache_baseball", "png"),
|
99
|
+
attachment: image("apache_baseball", "png")
|
84
100
|
},
|
85
101
|
],
|
86
102
|
products[:ruby_baseball_jersey].master => [
|
87
103
|
{
|
88
|
-
:
|
104
|
+
name: file_name("ruby_baseball", "png"),
|
105
|
+
attachment: image("ruby_baseball", "png")
|
89
106
|
},
|
90
107
|
],
|
91
108
|
products[:spree_bag].master => [
|
92
109
|
{
|
93
|
-
:
|
110
|
+
name: file_name("spree_bag"),
|
111
|
+
attachment: image("spree_bag")
|
94
112
|
},
|
95
113
|
],
|
96
114
|
products[:spree_tote].master => [
|
97
115
|
{
|
98
|
-
:
|
116
|
+
name: file_name("spree_tote_front"),
|
117
|
+
attachment: image("spree_tote_front")
|
99
118
|
},
|
100
119
|
{
|
101
|
-
:
|
120
|
+
name: file_name("spree_tote_back"),
|
121
|
+
attachment: image("spree_tote_back")
|
102
122
|
}
|
103
123
|
],
|
104
124
|
products[:spree_ringer].master => [
|
105
125
|
{
|
106
|
-
:
|
126
|
+
name: file_name("spree_ringer_t"),
|
127
|
+
attachment: image("spree_ringer_t")
|
107
128
|
},
|
108
129
|
{
|
109
|
-
:
|
130
|
+
name: file_name("spree_ringer_t_back"),
|
131
|
+
attachment: image("spree_ringer_t_back")
|
110
132
|
}
|
111
133
|
],
|
112
134
|
products[:spree_jr_spaghetti].master => [
|
113
135
|
{
|
114
|
-
:
|
136
|
+
name: file_name("spree_spaghetti"),
|
137
|
+
attachment: image("spree_spaghetti")
|
115
138
|
}
|
116
139
|
],
|
117
140
|
products[:spree_baseball_jersey].master => [
|
118
141
|
{
|
119
|
-
:
|
142
|
+
name: file_name("spree_jersey"),
|
143
|
+
attachment: image("spree_jersey")
|
120
144
|
},
|
121
145
|
{
|
122
|
-
:
|
146
|
+
name: file_name("spree_jersey_back"),
|
147
|
+
attachment: image("spree_jersey_back")
|
123
148
|
}
|
124
149
|
],
|
125
150
|
products[:spree_stein].master => [
|
126
151
|
{
|
127
|
-
:
|
152
|
+
name: file_name("spree_stein"),
|
153
|
+
attachment: image("spree_stein")
|
128
154
|
},
|
129
155
|
{
|
130
|
-
:
|
156
|
+
name: file_name("spree_stein_back"),
|
157
|
+
attachment: image("spree_stein_back")
|
131
158
|
}
|
132
159
|
],
|
133
160
|
products[:spree_mug].master => [
|
134
161
|
{
|
135
|
-
:
|
162
|
+
name: file_name("spree_mug"),
|
163
|
+
attachment: image("spree_mug")
|
136
164
|
},
|
137
165
|
{
|
138
|
-
:
|
166
|
+
name: file_name("spree_mug_back"),
|
167
|
+
attachment: image("spree_mug_back")
|
139
168
|
}
|
140
169
|
],
|
141
170
|
}
|
142
171
|
|
143
172
|
products[:ror_baseball_jersey].variants.each do |variant|
|
144
173
|
color = variant.option_value("tshirt-color").downcase
|
145
|
-
|
146
|
-
variant.images.
|
147
|
-
|
148
|
-
|
149
|
-
|
174
|
+
|
175
|
+
if variant.images.where(attachment_file_name: file_name("ror_baseball_jersey_#{color}", "png")).none?
|
176
|
+
main_image = image("ror_baseball_jersey_#{color}", "png")
|
177
|
+
variant.images.create!(attachment: main_image)
|
178
|
+
end
|
179
|
+
|
180
|
+
if variant.images.where(attachment_file_name: file_name("ror_baseball_jersey_back_#{color}", "png")).none?
|
181
|
+
back_image = image("ror_baseball_jersey_back_#{color}", "png")
|
182
|
+
variant.images.create!(attachment: back_image)
|
150
183
|
end
|
151
184
|
end
|
152
185
|
|
153
186
|
images.each do |variant, attachments|
|
154
187
|
puts "Loading images for #{variant.product.name}"
|
155
|
-
attachments.each do |
|
156
|
-
|
188
|
+
attachments.each do |attrs|
|
189
|
+
file_name = attrs.delete(:name)
|
190
|
+
|
191
|
+
if variant.images.where(attachment_file_name: file_name).none?
|
192
|
+
variant.images.create!(attrs)
|
193
|
+
end
|
157
194
|
end
|
158
195
|
end
|
159
|
-
|
data/db/samples/option_types.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
|
-
|
1
|
+
option_types_attributes = [
|
2
2
|
{
|
3
|
-
:
|
4
|
-
:
|
5
|
-
:
|
3
|
+
name: "tshirt-size",
|
4
|
+
presentation: "Size",
|
5
|
+
position: 1
|
6
6
|
},
|
7
7
|
{
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
8
|
+
name: "tshirt-color",
|
9
|
+
presentation: "Color",
|
10
|
+
position: 2
|
11
11
|
}
|
12
|
-
]
|
12
|
+
]
|
13
|
+
|
14
|
+
option_types_attributes.each do |attrs|
|
15
|
+
Spree::OptionType.where(attrs).first_or_create!
|
16
|
+
end
|
data/db/samples/option_values.rb
CHANGED
@@ -3,47 +3,51 @@ Spree::Sample.load_sample("option_types")
|
|
3
3
|
size = Spree::OptionType.find_by_presentation!("Size")
|
4
4
|
color = Spree::OptionType.find_by_presentation!("Color")
|
5
5
|
|
6
|
-
|
6
|
+
option_values_attributes = [
|
7
7
|
{
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
8
|
+
name: "Small",
|
9
|
+
presentation: "S",
|
10
|
+
position: 1,
|
11
|
+
option_type: size
|
12
12
|
},
|
13
13
|
{
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
14
|
+
name: "Medium",
|
15
|
+
presentation: "M",
|
16
|
+
position: 2,
|
17
|
+
option_type: size
|
18
18
|
},
|
19
19
|
{
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
20
|
+
name: "Large",
|
21
|
+
presentation: "L",
|
22
|
+
position: 3,
|
23
|
+
option_type: size
|
24
24
|
},
|
25
25
|
{
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
26
|
+
name: "Extra Large",
|
27
|
+
presentation: "XL",
|
28
|
+
position: 4,
|
29
|
+
option_type: size
|
30
30
|
},
|
31
31
|
{
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
32
|
+
name: "Red",
|
33
|
+
presentation: "Red",
|
34
|
+
position: 1,
|
35
|
+
option_type: color,
|
36
36
|
},
|
37
37
|
{
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
38
|
+
name: "Green",
|
39
|
+
presentation: "Green",
|
40
|
+
position: 2,
|
41
|
+
option_type: color,
|
42
42
|
},
|
43
43
|
{
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
44
|
+
name: "Blue",
|
45
|
+
presentation: "Blue",
|
46
|
+
position: 3,
|
47
|
+
option_type: color
|
48
48
|
}
|
49
|
-
]
|
49
|
+
]
|
50
|
+
|
51
|
+
option_values_attributes.each do |attrs|
|
52
|
+
Spree::OptionValue.where(attrs).first_or_create!
|
53
|
+
end
|
data/db/samples/orders.rb
CHANGED
@@ -1,33 +1,37 @@
|
|
1
1
|
Spree::Sample.load_sample("addresses")
|
2
2
|
|
3
3
|
orders = []
|
4
|
-
orders << Spree::Order.
|
5
|
-
:
|
6
|
-
:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
:billing_address => Spree::Address.last)
|
4
|
+
orders << Spree::Order.where(
|
5
|
+
number: "R123456789",
|
6
|
+
email: "spree@example.com").first_or_create! do |order|
|
7
|
+
order.item_total = 150.95
|
8
|
+
order.adjustment_total = 150.95
|
9
|
+
order.total = 301.90
|
10
|
+
end
|
12
11
|
|
13
|
-
orders << Spree::Order.
|
14
|
-
:
|
15
|
-
:
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
orders << Spree::Order.where(
|
13
|
+
number: "R987654321",
|
14
|
+
email: "spree@example.com").first_or_create! do |order|
|
15
|
+
order.item_total = 15.95
|
16
|
+
order.adjustment_total = 15.95
|
17
|
+
order.total = 31.90
|
18
|
+
order.shipping_address = Spree::Address.first
|
19
|
+
order.billing_address = Spree::Address.last
|
20
|
+
end
|
21
21
|
|
22
|
-
orders[0].line_items.
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
unless orders[0].line_items.any?
|
23
|
+
orders[0].line_items.new(
|
24
|
+
variant: Spree::Product.find_by_name!("Ruby on Rails Tote").master,
|
25
|
+
quantity: 1,
|
26
|
+
price: 15.99).save!
|
27
|
+
end
|
26
28
|
|
27
|
-
orders[1].line_items.
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
unless orders[1].line_items.any?
|
30
|
+
orders[1].line_items.new(
|
31
|
+
variant: Spree::Product.find_by_name!("Ruby on Rails Bag").master,
|
32
|
+
quantity: 1,
|
33
|
+
price: 22.99).save!
|
34
|
+
end
|
31
35
|
|
32
36
|
orders.each(&:create_proposed_shipments)
|
33
37
|
|