spree_sample 3.5.0 → 3.6.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/db/samples.rb +2 -2
- data/db/samples/addresses.rb +7 -5
- data/db/samples/adjustments.rb +17 -15
- data/db/samples/assets.rb +105 -92
- data/db/samples/option_types.rb +4 -4
- data/db/samples/option_values.rb +19 -19
- data/db/samples/orders.rb +24 -20
- data/db/samples/payment_methods.rb +4 -4
- data/db/samples/product_option_types.rb +5 -5
- data/db/samples/product_properties.rb +81 -81
- data/db/samples/products.rb +31 -32
- data/db/samples/prototypes.rb +6 -6
- data/db/samples/shipping_methods.rb +14 -14
- data/db/samples/stock.rb +1 -1
- data/db/samples/store_credit_categories.rb +1 -1
- data/db/samples/tax_rates.rb +5 -4
- data/db/samples/taxonomies.rb +1 -1
- data/db/samples/taxons.rb +32 -32
- data/db/samples/variants.rb +54 -56
- data/lib/spree/sample.rb +1 -3
- data/lib/tasks/sample.rake +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4c26831ae4064ae77d73f1dee1ef9c58b6b130ffca1a589eb16042706ef9f7b1
|
4
|
+
data.tar.gz: 875091811939c84887d2b90a3126b5f0bb47c6efba25e65c81f42b8e55eba8f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8ee152c2ea08268208fcb41bec8145578cd827ce418f3d0d67900d2cb0944749523fb8621fa1e42e7d0f94a8784d3a1c3f6301fb26919059a73c6e4c1c41c7c
|
7
|
+
data.tar.gz: 805ed9b71b26b978007a409cdb3a1aaffae49c5142bb1c8aad0767cf4aa88a9812a454812814c74d915a52fe3420308a45ca49c6b7b8927b630a45ea23636016
|
data/db/samples.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
Spree::Sample.load_sample(
|
2
|
-
Spree::Sample.load_sample(
|
1
|
+
Spree::Sample.load_sample('payment_methods')
|
2
|
+
Spree::Sample.load_sample('shipping_categories')
|
data/db/samples/addresses.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
united_states = Spree::Country.find_by!(iso:
|
2
|
-
new_york = Spree::State.find_by!(name:
|
1
|
+
united_states = Spree::Country.find_by!(iso: 'US')
|
2
|
+
new_york = Spree::State.find_by!(name: 'New York')
|
3
3
|
|
4
4
|
# Billing address
|
5
5
|
Spree::Address.create!(
|
@@ -11,9 +11,10 @@ Spree::Address.create!(
|
|
11
11
|
state: new_york,
|
12
12
|
zipcode: 16804,
|
13
13
|
country: united_states,
|
14
|
-
phone: FFaker::PhoneNumber.phone_number
|
14
|
+
phone: FFaker::PhoneNumber.phone_number
|
15
|
+
)
|
15
16
|
|
16
|
-
#Shipping address
|
17
|
+
# Shipping address
|
17
18
|
Spree::Address.create!(
|
18
19
|
firstname: FFaker::Name.first_name,
|
19
20
|
lastname: FFaker::Name.last_name,
|
@@ -23,4 +24,5 @@ Spree::Address.create!(
|
|
23
24
|
state: new_york,
|
24
25
|
zipcode: 16804,
|
25
26
|
country: united_states,
|
26
|
-
phone: FFaker::PhoneNumber.phone_number
|
27
|
+
phone: FFaker::PhoneNumber.phone_number
|
28
|
+
)
|
data/db/samples/adjustments.rb
CHANGED
@@ -1,22 +1,24 @@
|
|
1
|
-
Spree::Sample.load_sample(
|
1
|
+
Spree::Sample.load_sample('orders')
|
2
2
|
|
3
|
-
first_order = Spree::Order.find_by!(number:
|
4
|
-
last_order = Spree::Order.find_by!(number:
|
3
|
+
first_order = Spree::Order.find_by!(number: 'R123456789')
|
4
|
+
last_order = Spree::Order.find_by!(number: 'R987654321')
|
5
5
|
|
6
6
|
first_order.adjustments.where(
|
7
|
-
source: Spree::TaxRate.find_by!(name:
|
7
|
+
source: Spree::TaxRate.find_by!(name: 'North America'),
|
8
8
|
order: first_order,
|
9
|
-
label:
|
10
|
-
state:
|
11
|
-
mandatory: true
|
12
|
-
|
13
|
-
|
9
|
+
label: 'Tax',
|
10
|
+
state: 'open',
|
11
|
+
mandatory: true
|
12
|
+
).first_or_create! do |adj|
|
13
|
+
adj.amount = 0
|
14
|
+
end
|
14
15
|
|
15
16
|
last_order.adjustments.where(
|
16
|
-
source: Spree::TaxRate.find_by!(name:
|
17
|
+
source: Spree::TaxRate.find_by!(name: 'North America'),
|
17
18
|
order: last_order,
|
18
|
-
label:
|
19
|
-
state:
|
20
|
-
mandatory: true
|
21
|
-
|
22
|
-
|
19
|
+
label: 'Tax',
|
20
|
+
state: 'open',
|
21
|
+
mandatory: true
|
22
|
+
).first_or_create! do |adj|
|
23
|
+
adj.amount = 0
|
24
|
+
end
|
data/db/samples/assets.rb
CHANGED
@@ -1,196 +1,209 @@
|
|
1
1
|
unless ENV['SKIP_SAMPLE_IMAGES']
|
2
|
-
Spree::Sample.load_sample(
|
3
|
-
Spree::Sample.load_sample(
|
4
|
-
|
2
|
+
Spree::Sample.load_sample('products')
|
3
|
+
Spree::Sample.load_sample('variants')
|
5
4
|
products = {}
|
6
|
-
products[:ror_baseball_jersey] = Spree::Product.find_by!(name:
|
7
|
-
products[:ror_tote] = Spree::Product.find_by!(name:
|
8
|
-
products[:ror_bag] = Spree::Product.find_by!(name:
|
9
|
-
products[:ror_jr_spaghetti] = Spree::Product.find_by!(name:
|
10
|
-
products[:ror_mug] = Spree::Product.find_by!(name:
|
11
|
-
products[:ror_ringer] = Spree::Product.find_by!(name:
|
12
|
-
products[:ror_stein] = Spree::Product.find_by!(name:
|
13
|
-
products[:spree_baseball_jersey] = Spree::Product.find_by!(name:
|
14
|
-
products[:spree_stein] = Spree::Product.find_by!(name:
|
15
|
-
products[:spree_jr_spaghetti] = Spree::Product.find_by!(name:
|
16
|
-
products[:spree_mug] = Spree::Product.find_by!(name:
|
17
|
-
products[:spree_ringer] = Spree::Product.find_by!(name:
|
18
|
-
products[:spree_tote] = Spree::Product.find_by!(name:
|
19
|
-
products[:spree_bag] = Spree::Product.find_by!(name:
|
20
|
-
products[:ruby_baseball_jersey] = Spree::Product.find_by!(name:
|
21
|
-
products[:apache_baseball_jersey] = Spree::Product.find_by!(name:
|
5
|
+
products[:ror_baseball_jersey] = Spree::Product.find_by!(name: 'Ruby on Rails Baseball Jersey')
|
6
|
+
products[:ror_tote] = Spree::Product.find_by!(name: 'Ruby on Rails Tote')
|
7
|
+
products[:ror_bag] = Spree::Product.find_by!(name: 'Ruby on Rails Bag')
|
8
|
+
products[:ror_jr_spaghetti] = Spree::Product.find_by!(name: 'Ruby on Rails Jr. Spaghetti')
|
9
|
+
products[:ror_mug] = Spree::Product.find_by!(name: 'Ruby on Rails Mug')
|
10
|
+
products[:ror_ringer] = Spree::Product.find_by!(name: 'Ruby on Rails Ringer T-Shirt')
|
11
|
+
products[:ror_stein] = Spree::Product.find_by!(name: 'Ruby on Rails Stein')
|
12
|
+
products[:spree_baseball_jersey] = Spree::Product.find_by!(name: 'Spree Baseball Jersey')
|
13
|
+
products[:spree_stein] = Spree::Product.find_by!(name: 'Spree Stein')
|
14
|
+
products[:spree_jr_spaghetti] = Spree::Product.find_by!(name: 'Spree Jr. Spaghetti')
|
15
|
+
products[:spree_mug] = Spree::Product.find_by!(name: 'Spree Mug')
|
16
|
+
products[:spree_ringer] = Spree::Product.find_by!(name: 'Spree Ringer T-Shirt')
|
17
|
+
products[:spree_tote] = Spree::Product.find_by!(name: 'Spree Tote')
|
18
|
+
products[:spree_bag] = Spree::Product.find_by!(name: 'Spree Bag')
|
19
|
+
products[:ruby_baseball_jersey] = Spree::Product.find_by!(name: 'Ruby Baseball Jersey')
|
20
|
+
products[:apache_baseball_jersey] = Spree::Product.find_by!(name: 'Apache Baseball Jersey')
|
22
21
|
|
23
|
-
def image(name, type =
|
24
|
-
images_path = Pathname.new(File.dirname(__FILE__)) +
|
22
|
+
def image(name, type = 'jpeg')
|
23
|
+
images_path = Pathname.new(File.dirname(__FILE__)) + 'images'
|
25
24
|
path = images_path + file_name(name, type)
|
26
|
-
return false
|
25
|
+
return false unless File.exist?(path)
|
27
26
|
File.open(path)
|
28
27
|
end
|
29
28
|
|
30
|
-
def file_name(name, type =
|
29
|
+
def file_name(name, type = 'jpeg')
|
31
30
|
"#{name}.#{type}"
|
32
31
|
end
|
33
32
|
|
33
|
+
def attach_paperclip_image(variant, name, type)
|
34
|
+
if variant.images.where(attachment_file_name: file_name(name, type)).none?
|
35
|
+
image = image(name, type)
|
36
|
+
variant.images.create!(attachment: image)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def attach_active_storage_image(variant, name, type)
|
41
|
+
if variant.images.with_attached_attachment.where(active_storage_blobs: { filename: file_name(name, type) }).none?
|
42
|
+
image = image(name, type)
|
43
|
+
variant.images.create!(attachment: { io: image, filename: file_name(name, type) })
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
34
47
|
images = {
|
35
48
|
products[:ror_tote].master => [
|
36
49
|
{
|
37
|
-
name: file_name(
|
38
|
-
attachment: image(
|
50
|
+
name: file_name('ror_tote'),
|
51
|
+
attachment: image('ror_tote')
|
39
52
|
},
|
40
53
|
{
|
41
|
-
name: file_name(
|
42
|
-
attachment: image(
|
54
|
+
name: file_name('ror_tote_back'),
|
55
|
+
attachment: image('ror_tote_back')
|
43
56
|
}
|
44
57
|
],
|
45
58
|
products[:ror_bag].master => [
|
46
59
|
{
|
47
|
-
name: file_name(
|
48
|
-
attachment: image(
|
60
|
+
name: file_name('ror_bag'),
|
61
|
+
attachment: image('ror_bag')
|
49
62
|
}
|
50
63
|
],
|
51
64
|
products[:ror_baseball_jersey].master => [
|
52
65
|
{
|
53
|
-
name: file_name(
|
54
|
-
attachment: image(
|
66
|
+
name: file_name('ror_baseball'),
|
67
|
+
attachment: image('ror_baseball')
|
55
68
|
},
|
56
69
|
{
|
57
|
-
name: file_name(
|
58
|
-
attachment: image(
|
70
|
+
name: file_name('ror_baseball_back'),
|
71
|
+
attachment: image('ror_baseball_back')
|
59
72
|
}
|
60
73
|
],
|
61
74
|
products[:ror_jr_spaghetti].master => [
|
62
75
|
{
|
63
|
-
name: file_name(
|
64
|
-
attachment: image(
|
76
|
+
name: file_name('ror_jr_spaghetti'),
|
77
|
+
attachment: image('ror_jr_spaghetti')
|
65
78
|
}
|
66
79
|
],
|
67
80
|
products[:ror_mug].master => [
|
68
81
|
{
|
69
|
-
name: file_name(
|
70
|
-
attachment: image(
|
82
|
+
name: file_name('ror_mug'),
|
83
|
+
attachment: image('ror_mug')
|
71
84
|
},
|
72
85
|
{
|
73
|
-
name: file_name(
|
74
|
-
attachment: image(
|
86
|
+
name: file_name('ror_mug_back'),
|
87
|
+
attachment: image('ror_mug_back')
|
75
88
|
}
|
76
89
|
],
|
77
90
|
products[:ror_ringer].master => [
|
78
91
|
{
|
79
|
-
name: file_name(
|
80
|
-
attachment: image(
|
92
|
+
name: file_name('ror_ringer'),
|
93
|
+
attachment: image('ror_ringer')
|
81
94
|
},
|
82
95
|
{
|
83
|
-
name: file_name(
|
84
|
-
attachment: image(
|
96
|
+
name: file_name('ror_ringer_back'),
|
97
|
+
attachment: image('ror_ringer_back')
|
85
98
|
}
|
86
99
|
],
|
87
100
|
products[:ror_stein].master => [
|
88
101
|
{
|
89
|
-
name: file_name(
|
90
|
-
attachment: image(
|
102
|
+
name: file_name('ror_stein'),
|
103
|
+
attachment: image('ror_stein')
|
91
104
|
},
|
92
105
|
{
|
93
|
-
name: file_name(
|
94
|
-
attachment: image(
|
106
|
+
name: file_name('ror_stein_back'),
|
107
|
+
attachment: image('ror_stein_back')
|
95
108
|
}
|
96
109
|
],
|
97
110
|
products[:apache_baseball_jersey].master => [
|
98
111
|
{
|
99
|
-
name: file_name(
|
100
|
-
attachment: image(
|
101
|
-
}
|
112
|
+
name: file_name('apache_baseball', 'png'),
|
113
|
+
attachment: image('apache_baseball', 'png')
|
114
|
+
}
|
102
115
|
],
|
103
116
|
products[:ruby_baseball_jersey].master => [
|
104
117
|
{
|
105
|
-
name: file_name(
|
106
|
-
attachment: image(
|
107
|
-
}
|
118
|
+
name: file_name('ruby_baseball', 'png'),
|
119
|
+
attachment: image('ruby_baseball', 'png')
|
120
|
+
}
|
108
121
|
],
|
109
122
|
products[:spree_bag].master => [
|
110
123
|
{
|
111
|
-
name: file_name(
|
112
|
-
attachment: image(
|
113
|
-
}
|
124
|
+
name: file_name('spree_bag'),
|
125
|
+
attachment: image('spree_bag')
|
126
|
+
}
|
114
127
|
],
|
115
128
|
products[:spree_tote].master => [
|
116
129
|
{
|
117
|
-
name: file_name(
|
118
|
-
attachment: image(
|
130
|
+
name: file_name('spree_tote_front'),
|
131
|
+
attachment: image('spree_tote_front')
|
119
132
|
},
|
120
133
|
{
|
121
|
-
name: file_name(
|
122
|
-
attachment: image(
|
134
|
+
name: file_name('spree_tote_back'),
|
135
|
+
attachment: image('spree_tote_back')
|
123
136
|
}
|
124
137
|
],
|
125
138
|
products[:spree_ringer].master => [
|
126
139
|
{
|
127
|
-
name: file_name(
|
128
|
-
attachment: image(
|
140
|
+
name: file_name('spree_ringer_t'),
|
141
|
+
attachment: image('spree_ringer_t')
|
129
142
|
},
|
130
143
|
{
|
131
|
-
name: file_name(
|
132
|
-
attachment: image(
|
144
|
+
name: file_name('spree_ringer_t_back'),
|
145
|
+
attachment: image('spree_ringer_t_back')
|
133
146
|
}
|
134
147
|
],
|
135
148
|
products[:spree_jr_spaghetti].master => [
|
136
149
|
{
|
137
|
-
name: file_name(
|
138
|
-
attachment: image(
|
150
|
+
name: file_name('spree_spaghetti'),
|
151
|
+
attachment: image('spree_spaghetti')
|
139
152
|
}
|
140
153
|
],
|
141
154
|
products[:spree_baseball_jersey].master => [
|
142
155
|
{
|
143
|
-
name: file_name(
|
144
|
-
attachment: image(
|
156
|
+
name: file_name('spree_jersey'),
|
157
|
+
attachment: image('spree_jersey')
|
145
158
|
},
|
146
159
|
{
|
147
|
-
name: file_name(
|
148
|
-
attachment: image(
|
160
|
+
name: file_name('spree_jersey_back'),
|
161
|
+
attachment: image('spree_jersey_back')
|
149
162
|
}
|
150
163
|
],
|
151
164
|
products[:spree_stein].master => [
|
152
165
|
{
|
153
|
-
name: file_name(
|
154
|
-
attachment: image(
|
166
|
+
name: file_name('spree_stein'),
|
167
|
+
attachment: image('spree_stein')
|
155
168
|
},
|
156
169
|
{
|
157
|
-
name: file_name(
|
158
|
-
attachment: image(
|
170
|
+
name: file_name('spree_stein_back'),
|
171
|
+
attachment: image('spree_stein_back')
|
159
172
|
}
|
160
173
|
],
|
161
174
|
products[:spree_mug].master => [
|
162
175
|
{
|
163
|
-
name: file_name(
|
164
|
-
attachment: image(
|
176
|
+
name: file_name('spree_mug'),
|
177
|
+
attachment: image('spree_mug')
|
165
178
|
},
|
166
179
|
{
|
167
|
-
name: file_name(
|
168
|
-
attachment: image(
|
180
|
+
name: file_name('spree_mug_back'),
|
181
|
+
attachment: image('spree_mug_back')
|
169
182
|
}
|
170
|
-
]
|
183
|
+
]
|
171
184
|
}
|
172
185
|
|
173
186
|
products[:ror_baseball_jersey].variants.each do |variant|
|
174
|
-
color = variant.option_value(
|
175
|
-
|
176
|
-
if variant.images.where(attachment_file_name: file_name("ror_baseball_jersey_#{color}", "png")).none?
|
177
|
-
main_image = image("ror_baseball_jersey_#{color}", "png")
|
178
|
-
variant.images.create!(attachment: main_image)
|
179
|
-
end
|
187
|
+
color = variant.option_value('tshirt-color').downcase
|
180
188
|
|
181
|
-
if
|
182
|
-
|
183
|
-
variant
|
189
|
+
if Rails.application.config.use_paperclip
|
190
|
+
attach_paperclip_image(variant, "ror_baseball_jersey_#{color}", 'png')
|
191
|
+
attach_paperclip_image(variant, "ror_baseball_jersey_back_#{color}", 'png')
|
192
|
+
else
|
193
|
+
attach_active_storage_image(variant, "ror_baseball_jersey_#{color}", 'png')
|
194
|
+
attach_active_storage_image(variant, "ror_baseball_jersey_back_#{color}", 'png')
|
184
195
|
end
|
185
196
|
end
|
186
197
|
|
187
198
|
images.each do |variant, attachments|
|
188
199
|
puts "Loading images for #{variant.product.name}"
|
189
200
|
attachments.each do |attrs|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
201
|
+
if Rails.application.config.use_paperclip
|
202
|
+
file_name = attrs.delete(:name)
|
203
|
+
variant.images.create!(attrs) if variant.images.where(attachment_file_name: file_name).none?
|
204
|
+
else
|
205
|
+
name, type = attrs.delete(:name).split('.')
|
206
|
+
attach_active_storage_image(variant, name, type)
|
194
207
|
end
|
195
208
|
end
|
196
209
|
end
|
data/db/samples/option_types.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
option_types_attributes = [
|
2
2
|
{
|
3
|
-
name:
|
4
|
-
presentation:
|
3
|
+
name: 'tshirt-size',
|
4
|
+
presentation: 'Size',
|
5
5
|
position: 1
|
6
6
|
},
|
7
7
|
{
|
8
|
-
name:
|
9
|
-
presentation:
|
8
|
+
name: 'tshirt-color',
|
9
|
+
presentation: 'Color',
|
10
10
|
position: 2
|
11
11
|
}
|
12
12
|
]
|
data/db/samples/option_values.rb
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
Spree::Sample.load_sample(
|
1
|
+
Spree::Sample.load_sample('option_types')
|
2
2
|
|
3
|
-
size = Spree::OptionType.find_by!(presentation:
|
4
|
-
color = Spree::OptionType.find_by!(presentation:
|
3
|
+
size = Spree::OptionType.find_by!(presentation: 'Size')
|
4
|
+
color = Spree::OptionType.find_by!(presentation: 'Color')
|
5
5
|
|
6
6
|
option_values_attributes = [
|
7
7
|
{
|
8
|
-
name:
|
9
|
-
presentation:
|
8
|
+
name: 'Small',
|
9
|
+
presentation: 'S',
|
10
10
|
position: 1,
|
11
11
|
option_type: size
|
12
12
|
},
|
13
13
|
{
|
14
|
-
name:
|
15
|
-
presentation:
|
14
|
+
name: 'Medium',
|
15
|
+
presentation: 'M',
|
16
16
|
position: 2,
|
17
17
|
option_type: size
|
18
18
|
},
|
19
19
|
{
|
20
|
-
name:
|
21
|
-
presentation:
|
20
|
+
name: 'Large',
|
21
|
+
presentation: 'L',
|
22
22
|
position: 3,
|
23
23
|
option_type: size
|
24
24
|
},
|
25
25
|
{
|
26
|
-
name:
|
27
|
-
presentation:
|
26
|
+
name: 'Extra Large',
|
27
|
+
presentation: 'XL',
|
28
28
|
position: 4,
|
29
29
|
option_type: size
|
30
30
|
},
|
31
31
|
{
|
32
|
-
name:
|
33
|
-
presentation:
|
32
|
+
name: 'Red',
|
33
|
+
presentation: 'Red',
|
34
34
|
position: 1,
|
35
|
-
option_type: color
|
35
|
+
option_type: color
|
36
36
|
},
|
37
37
|
{
|
38
|
-
name:
|
39
|
-
presentation:
|
38
|
+
name: 'Green',
|
39
|
+
presentation: 'Green',
|
40
40
|
position: 2,
|
41
|
-
option_type: color
|
41
|
+
option_type: color
|
42
42
|
},
|
43
43
|
{
|
44
|
-
name:
|
45
|
-
presentation:
|
44
|
+
name: 'Blue',
|
45
|
+
presentation: 'Blue',
|
46
46
|
position: 3,
|
47
47
|
option_type: color
|
48
48
|
}
|