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
@@ -1,15 +1,11 @@
|
|
1
|
-
Spree::Gateway::Bogus.
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
}
|
7
|
-
)
|
1
|
+
Spree::Gateway::Bogus.where(
|
2
|
+
name: "Credit Card",
|
3
|
+
description: "Bogus payment gateway.",
|
4
|
+
active: true
|
5
|
+
).first_or_create!
|
8
6
|
|
9
|
-
Spree::PaymentMethod::Check.
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
15
|
-
)
|
7
|
+
Spree::PaymentMethod::Check.where(
|
8
|
+
name: "Check",
|
9
|
+
description: "Pay by check.",
|
10
|
+
active: true
|
11
|
+
).first_or_create!
|
data/db/samples/payments.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# create payments based on the totals since they can't be known in YAML (quantities are random)
|
2
|
-
method = Spree::PaymentMethod.where(:
|
2
|
+
method = Spree::PaymentMethod.where(name: 'Credit Card', active: true).first
|
3
3
|
|
4
4
|
# Hack the current method so we're able to return a gateway without a RAILS_ENV
|
5
5
|
Spree::Gateway.class_eval do
|
@@ -12,11 +12,18 @@ end
|
|
12
12
|
# reference it as such. Make it explicit here that this table has been renamed.
|
13
13
|
Spree::CreditCard.table_name = 'spree_credit_cards'
|
14
14
|
|
15
|
-
|
16
|
-
:
|
15
|
+
credit_card = Spree::CreditCard.where(cc_type: 'visa',
|
16
|
+
month: 12,
|
17
|
+
year: 2.years.from_now.year,
|
18
|
+
last_digits: '1111',
|
19
|
+
name: 'Sean Schofield',
|
20
|
+
gateway_customer_profile_id: 'BGS-1234').first_or_create!
|
17
21
|
|
18
|
-
Spree::Order.all.each_with_index do |order,
|
22
|
+
Spree::Order.all.each_with_index do |order, _index|
|
19
23
|
order.update_with_updater!
|
20
|
-
payment = order.payments.
|
21
|
-
|
24
|
+
payment = order.payments.where(amount: BigDecimal(order.total, 4),
|
25
|
+
source: credit_card.clone,
|
26
|
+
payment_method: method).first_or_create!
|
27
|
+
|
28
|
+
payment.update_columns(state: 'pending', response_code: '12345')
|
22
29
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
products =
|
2
|
-
{
|
3
|
-
"Ruby on Rails Baseball Jersey" =>
|
4
|
-
{
|
2
|
+
{
|
3
|
+
"Ruby on Rails Baseball Jersey" =>
|
4
|
+
{
|
5
5
|
"Manufacturer" => "Wilson",
|
6
6
|
"Brand" => "Wannabe Sports",
|
7
7
|
"Model" => "JK1002",
|
@@ -36,44 +36,44 @@ products =
|
|
36
36
|
"Ruby on Rails Tote" =>
|
37
37
|
{
|
38
38
|
"Type" => "Tote",
|
39
|
-
"Size" => %
|
39
|
+
"Size" => %{15" x 18" x 6"},
|
40
40
|
"Material" => "Canvas"
|
41
41
|
},
|
42
42
|
"Ruby on Rails Bag" =>
|
43
43
|
{
|
44
44
|
"Type" => "Messenger",
|
45
|
-
"Size" => %
|
45
|
+
"Size" => %{14 1/2" x 12" x 5"},
|
46
46
|
"Material" => "600 Denier Polyester"
|
47
47
|
},
|
48
|
-
"Ruby on Rails Mug" =>
|
48
|
+
"Ruby on Rails Mug" =>
|
49
49
|
{
|
50
50
|
"Type" => "Mug",
|
51
|
-
"Size" => %
|
51
|
+
"Size" => %{4.5" tall, 3.25" dia.}
|
52
52
|
},
|
53
53
|
"Ruby on Rails Stein" =>
|
54
54
|
{
|
55
55
|
"Type" => "Stein",
|
56
|
-
"Size" => %
|
56
|
+
"Size" => %{6.75" tall, 3.75" dia. base, 3" dia. rim}
|
57
57
|
},
|
58
58
|
"Spree Stein" =>
|
59
59
|
{
|
60
60
|
"Type" => "Stein",
|
61
|
-
"Size" => %
|
61
|
+
"Size" => %{6.75" tall, 3.75" dia. base, 3" dia. rim}
|
62
62
|
},
|
63
|
-
"Spree Mug" =>
|
63
|
+
"Spree Mug" =>
|
64
64
|
{
|
65
65
|
"Type" => "Mug",
|
66
|
-
"Size" => %
|
66
|
+
"Size" => %{4.5" tall, 3.25" dia.}
|
67
67
|
},
|
68
|
-
"Spree Tote" =>
|
68
|
+
"Spree Tote" =>
|
69
69
|
{
|
70
70
|
"Type" => "Tote",
|
71
|
-
"Size" => %
|
71
|
+
"Size" => %{15" x 18" x 6"}
|
72
72
|
},
|
73
|
-
"Spree Bag" =>
|
73
|
+
"Spree Bag" =>
|
74
74
|
{
|
75
75
|
"Type" => "Messenger",
|
76
|
-
"Size" => %
|
76
|
+
"Size" => %{14 1/2" x 12" x 5"}
|
77
77
|
},
|
78
78
|
"Spree Baseball Jersey" =>
|
79
79
|
{
|
data/db/samples/products.rb
CHANGED
@@ -2,136 +2,123 @@ Spree::Sample.load_sample("tax_categories")
|
|
2
2
|
Spree::Sample.load_sample("shipping_categories")
|
3
3
|
|
4
4
|
clothing = Spree::TaxCategory.find_by_name!("Clothing")
|
5
|
-
shipping_category = Spree::ShippingCategory.find_by_name!("Default")
|
6
|
-
|
7
|
-
default_attrs = {
|
8
|
-
description: FFaker::Lorem.paragraph,
|
9
|
-
available_on: Time.zone.now
|
10
|
-
}
|
11
5
|
|
12
6
|
products = [
|
13
7
|
{
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:eur_price => 14,
|
8
|
+
name: "Ruby on Rails Tote",
|
9
|
+
tax_category: clothing,
|
10
|
+
price: 15.99,
|
11
|
+
eur_price: 14,
|
19
12
|
},
|
20
13
|
{
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:eur_price => 19,
|
14
|
+
name: "Ruby on Rails Bag",
|
15
|
+
tax_category: clothing,
|
16
|
+
price: 22.99,
|
17
|
+
eur_price: 19,
|
26
18
|
},
|
27
19
|
{
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:eur_price => 16
|
20
|
+
name: "Ruby on Rails Baseball Jersey",
|
21
|
+
tax_category: clothing,
|
22
|
+
price: 19.99,
|
23
|
+
eur_price: 16
|
33
24
|
},
|
34
25
|
{
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:eur_price => 16
|
26
|
+
name: "Ruby on Rails Jr. Spaghetti",
|
27
|
+
tax_category: clothing,
|
28
|
+
price: 19.99,
|
29
|
+
eur_price: 16
|
40
30
|
|
41
31
|
},
|
42
32
|
{
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:eur_price => 16
|
33
|
+
name: "Ruby on Rails Ringer T-Shirt",
|
34
|
+
tax_category: clothing,
|
35
|
+
price: 19.99,
|
36
|
+
eur_price: 16
|
48
37
|
},
|
49
38
|
{
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:eur_price => 16
|
39
|
+
name: "Ruby Baseball Jersey",
|
40
|
+
tax_category: clothing,
|
41
|
+
price: 19.99,
|
42
|
+
eur_price: 16
|
55
43
|
},
|
56
44
|
{
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:eur_price => 16
|
45
|
+
name: "Apache Baseball Jersey",
|
46
|
+
tax_category: clothing,
|
47
|
+
price: 19.99,
|
48
|
+
eur_price: 16
|
62
49
|
},
|
63
50
|
{
|
64
|
-
:
|
65
|
-
:
|
66
|
-
:
|
67
|
-
:
|
68
|
-
:eur_price => 16
|
51
|
+
name: "Spree Baseball Jersey",
|
52
|
+
tax_category: clothing,
|
53
|
+
price: 19.99,
|
54
|
+
eur_price: 16
|
69
55
|
},
|
70
56
|
{
|
71
|
-
:
|
72
|
-
:
|
73
|
-
:
|
74
|
-
:
|
75
|
-
:eur_price => 16
|
57
|
+
name: "Spree Jr. Spaghetti",
|
58
|
+
tax_category: clothing,
|
59
|
+
price: 19.99,
|
60
|
+
eur_price: 16
|
76
61
|
},
|
77
62
|
{
|
78
|
-
:
|
79
|
-
:
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:eur_price => 16
|
63
|
+
name: "Spree Ringer T-Shirt",
|
64
|
+
tax_category: clothing,
|
65
|
+
price: 19.99,
|
66
|
+
eur_price: 16
|
83
67
|
},
|
84
68
|
{
|
85
|
-
:
|
86
|
-
:
|
87
|
-
:
|
88
|
-
:
|
89
|
-
:eur_price => 14,
|
69
|
+
name: "Spree Tote",
|
70
|
+
tax_category: clothing,
|
71
|
+
price: 15.99,
|
72
|
+
eur_price: 14,
|
90
73
|
},
|
91
74
|
{
|
92
|
-
:
|
93
|
-
:
|
94
|
-
:
|
95
|
-
:
|
96
|
-
:eur_price => 19
|
75
|
+
name: "Spree Bag",
|
76
|
+
tax_category: clothing,
|
77
|
+
price: 22.99,
|
78
|
+
eur_price: 19
|
97
79
|
},
|
98
80
|
{
|
99
|
-
:
|
100
|
-
:
|
101
|
-
:
|
102
|
-
:eur_price => 12
|
81
|
+
name: "Ruby on Rails Mug",
|
82
|
+
price: 13.99,
|
83
|
+
eur_price: 12
|
103
84
|
},
|
104
85
|
{
|
105
|
-
:
|
106
|
-
:
|
107
|
-
:
|
108
|
-
:eur_price => 14
|
86
|
+
name: "Ruby on Rails Stein",
|
87
|
+
price: 16.99,
|
88
|
+
eur_price: 14
|
109
89
|
},
|
110
90
|
{
|
111
|
-
:
|
112
|
-
:
|
113
|
-
:
|
114
|
-
:eur_price => 14,
|
91
|
+
name: "Spree Stein",
|
92
|
+
price: 16.99,
|
93
|
+
eur_price: 14,
|
115
94
|
},
|
116
95
|
{
|
117
|
-
:
|
118
|
-
:
|
119
|
-
:
|
120
|
-
:eur_price => 12
|
96
|
+
name: "Spree Mug",
|
97
|
+
price: 13.99,
|
98
|
+
eur_price: 12
|
121
99
|
}
|
122
100
|
]
|
123
101
|
|
102
|
+
default_shipping_category = Spree::ShippingCategory.find_by_name!("Default")
|
103
|
+
|
124
104
|
products.each do |product_attrs|
|
125
|
-
eur_price = product_attrs.delete(:eur_price)
|
126
105
|
Spree::Config[:currency] = "USD"
|
106
|
+
eur_price = product_attrs.delete(:eur_price)
|
107
|
+
|
108
|
+
new_product = Spree::Product.where(name: product_attrs[:name],
|
109
|
+
tax_category: product_attrs[:tax_category]).first_or_create! do |product|
|
110
|
+
product.price = product_attrs[:price]
|
111
|
+
product.description = FFaker::Lorem.paragraph
|
112
|
+
product.available_on = Time.zone.now
|
113
|
+
product.shipping_category = default_shipping_category
|
114
|
+
end
|
127
115
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
product.save!
|
116
|
+
if new_product
|
117
|
+
Spree::Config[:currency] = "EUR"
|
118
|
+
new_product.reload
|
119
|
+
new_product.price = eur_price
|
120
|
+
new_product.save
|
121
|
+
end
|
135
122
|
end
|
136
123
|
|
137
124
|
Spree::Config[:currency] = "USD"
|
data/db/samples/prototypes.rb
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
prototypes = [
|
2
2
|
{
|
3
|
-
:
|
4
|
-
:
|
3
|
+
name: "Shirt",
|
4
|
+
properties: ["Manufacturer", "Brand", "Model", "Shirt Type", "Sleeve Type", "Material", "Fit", "Gender"]
|
5
5
|
},
|
6
6
|
{
|
7
|
-
:
|
8
|
-
:
|
7
|
+
name: "Bag",
|
8
|
+
properties: ["Type", "Size", "Material"]
|
9
9
|
},
|
10
10
|
{
|
11
|
-
:
|
12
|
-
:
|
11
|
+
name: "Mugs",
|
12
|
+
properties: ["Size", "Type"]
|
13
13
|
}
|
14
14
|
]
|
15
15
|
|
16
16
|
prototypes.each do |prototype_attrs|
|
17
|
-
prototype = Spree::Prototype.
|
18
|
-
prototype_attrs[:properties].each do |
|
19
|
-
|
17
|
+
prototype = Spree::Prototype.where(name: prototype_attrs[:name]).first_or_create!
|
18
|
+
prototype_attrs[:properties].each do |property_name|
|
19
|
+
property = Spree::Property.where(name: property_name).first
|
20
|
+
prototype.properties << property unless prototype.properties.include?(property)
|
20
21
|
end
|
21
22
|
end
|
@@ -1 +1 @@
|
|
1
|
-
Spree::ShippingCategory.find_or_create_by!(:
|
1
|
+
Spree::ShippingCategory.find_or_create_by!(name: 'Default')
|
@@ -1,5 +1,5 @@
|
|
1
1
|
begin
|
2
|
-
north_america = Spree::Zone.find_by_name!("North America")
|
2
|
+
north_america = Spree::Zone.find_by_name!("North America")
|
3
3
|
rescue ActiveRecord::RecordNotFound
|
4
4
|
puts "Couldn't find 'North America' zone. Did you run `rake db:seed` first?"
|
5
5
|
puts "That task will set up the countries, states and zones required for Spree."
|
@@ -9,38 +9,41 @@ end
|
|
9
9
|
europe_vat = Spree::Zone.find_by_name!("EU_VAT")
|
10
10
|
shipping_category = Spree::ShippingCategory.find_or_create_by!(name: 'Default')
|
11
11
|
|
12
|
-
|
12
|
+
shipping_methods = [
|
13
13
|
{
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:shipping_categories => [shipping_category]
|
14
|
+
name: "UPS Ground (USD)",
|
15
|
+
zones: [north_america],
|
16
|
+
shipping_categories: [shipping_category]
|
18
17
|
},
|
19
18
|
{
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:shipping_categories => [shipping_category]
|
19
|
+
name: "UPS Two Day (USD)",
|
20
|
+
zones: [north_america],
|
21
|
+
shipping_categories: [shipping_category]
|
24
22
|
},
|
25
23
|
{
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:shipping_categories => [shipping_category]
|
24
|
+
name: "UPS One Day (USD)",
|
25
|
+
zones: [north_america],
|
26
|
+
shipping_categories: [shipping_category]
|
30
27
|
},
|
31
28
|
{
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:shipping_categories => [shipping_category]
|
29
|
+
name: "UPS Ground (EU)",
|
30
|
+
zones: [europe_vat],
|
31
|
+
shipping_categories: [shipping_category]
|
36
32
|
},
|
37
33
|
{
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:shipping_categories => [shipping_category]
|
34
|
+
name: "UPS Ground (EUR)",
|
35
|
+
zones: [europe_vat],
|
36
|
+
shipping_categories: [shipping_category]
|
42
37
|
}
|
43
|
-
]
|
38
|
+
]
|
39
|
+
|
40
|
+
shipping_methods.each do |attributes|
|
41
|
+
Spree::ShippingMethod.where(name: attributes[:name]).first_or_create! do |shipping_method|
|
42
|
+
shipping_method.calculator = Spree::Calculator::Shipping::FlatRate.create!
|
43
|
+
shipping_method.zones = attributes[:zones]
|
44
|
+
shipping_method.shipping_categories = attributes[:shipping_categories]
|
45
|
+
end
|
46
|
+
end
|
44
47
|
|
45
48
|
{
|
46
49
|
"UPS Ground (USD)" => [5, "USD"],
|
@@ -57,4 +60,3 @@ Spree::ShippingMethod.create!([
|
|
57
60
|
shipping_method.calculator.save!
|
58
61
|
shipping_method.save!
|
59
62
|
end
|
60
|
-
|