spree_china_sample 3.0.0

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.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +26 -0
  3. data/db/samples/addresses.rb +26 -0
  4. data/db/samples/adjustments.rb +20 -0
  5. data/db/samples/assets.rb +159 -0
  6. data/db/samples/images/apache_baseball.png +0 -0
  7. data/db/samples/images/ror_bag.jpeg +0 -0
  8. data/db/samples/images/ror_baseball.jpeg +0 -0
  9. data/db/samples/images/ror_baseball_back.jpeg +0 -0
  10. data/db/samples/images/ror_baseball_jersey_back_blue.png +0 -0
  11. data/db/samples/images/ror_baseball_jersey_back_green.png +0 -0
  12. data/db/samples/images/ror_baseball_jersey_back_red.png +0 -0
  13. data/db/samples/images/ror_baseball_jersey_blue.png +0 -0
  14. data/db/samples/images/ror_baseball_jersey_green.png +0 -0
  15. data/db/samples/images/ror_baseball_jersey_red.png +0 -0
  16. data/db/samples/images/ror_jr_spaghetti.jpeg +0 -0
  17. data/db/samples/images/ror_mug.jpeg +0 -0
  18. data/db/samples/images/ror_mug_back.jpeg +0 -0
  19. data/db/samples/images/ror_ringer.jpeg +0 -0
  20. data/db/samples/images/ror_ringer_back.jpeg +0 -0
  21. data/db/samples/images/ror_stein.jpeg +0 -0
  22. data/db/samples/images/ror_stein_back.jpeg +0 -0
  23. data/db/samples/images/ror_tote.jpeg +0 -0
  24. data/db/samples/images/ror_tote_back.jpeg +0 -0
  25. data/db/samples/images/ruby_baseball.png +0 -0
  26. data/db/samples/images/spree_bag.jpeg +0 -0
  27. data/db/samples/images/spree_jersey.jpeg +0 -0
  28. data/db/samples/images/spree_jersey_back.jpeg +0 -0
  29. data/db/samples/images/spree_mug.jpeg +0 -0
  30. data/db/samples/images/spree_mug_back.jpeg +0 -0
  31. data/db/samples/images/spree_ringer_t.jpeg +0 -0
  32. data/db/samples/images/spree_ringer_t_back.jpeg +0 -0
  33. data/db/samples/images/spree_spaghetti.jpeg +0 -0
  34. data/db/samples/images/spree_stein.jpeg +0 -0
  35. data/db/samples/images/spree_stein_back.jpeg +0 -0
  36. data/db/samples/images/spree_tote_back.jpeg +0 -0
  37. data/db/samples/images/spree_tote_front.jpeg +0 -0
  38. data/db/samples/option_types.rb +12 -0
  39. data/db/samples/option_values.rb +49 -0
  40. data/db/samples/orders.rb +38 -0
  41. data/db/samples/payment_methods.rb +15 -0
  42. data/db/samples/payments.rb +22 -0
  43. data/db/samples/product_option_types.rb +12 -0
  44. data/db/samples/product_properties.rb +118 -0
  45. data/db/samples/products.rb +137 -0
  46. data/db/samples/prototypes.rb +21 -0
  47. data/db/samples/shipping_categories.rb +1 -0
  48. data/db/samples/shipping_methods.rb +60 -0
  49. data/db/samples/stock.rb +12 -0
  50. data/db/samples/tax_categories.rb +2 -0
  51. data/db/samples/tax_rates.rb +9 -0
  52. data/db/samples/taxonomies.rb +8 -0
  53. data/db/samples/taxons.rb +145 -0
  54. data/db/samples/variants.rb +164 -0
  55. data/db/samples.rb +2 -0
  56. data/lib/spree/sample.rb +23 -0
  57. data/lib/spree_sample.rb +31 -0
  58. data/lib/tasks/sample.rake +24 -0
  59. metadata +115 -0
@@ -0,0 +1,12 @@
1
+ Spree::Sample.load_sample("products")
2
+
3
+ size = Spree::OptionType.find_by_presentation!("Size")
4
+ color = Spree::OptionType.find_by_presentation!("Color")
5
+
6
+ ror_baseball_jersey = Spree::Product.find_by_name!("Ruby on Rails Baseball Jersey")
7
+ ror_baseball_jersey.option_types = [size, color]
8
+ ror_baseball_jersey.save!
9
+
10
+ spree_baseball_jersey = Spree::Product.find_by_name!("Spree Baseball Jersey")
11
+ spree_baseball_jersey.option_types = [size, color]
12
+ spree_baseball_jersey.save!
@@ -0,0 +1,118 @@
1
+ products =
2
+ {
3
+ "Ruby on Rails Baseball Jersey" =>
4
+ {
5
+ "Manufacturer" => "Wilson",
6
+ "Brand" => "Wannabe Sports",
7
+ "Model" => "JK1002",
8
+ "Shirt Type" => "Baseball Jersey",
9
+ "Sleeve Type" => "Long",
10
+ "Made from" => "100% cotton",
11
+ "Fit" => "Loose",
12
+ "Gender" => "Men's"
13
+ },
14
+ "Ruby on Rails Jr. Spaghetti" =>
15
+ {
16
+ "Manufacturer" => "Jerseys",
17
+ "Brand" => "Resiliance",
18
+ "Model" => "TL174",
19
+ "Shirt Type" => "Jr. Spaghetti T",
20
+ "Sleeve Type" => "None",
21
+ "Made from" => "90% Cotton, 10% Nylon",
22
+ "Fit" => "Form",
23
+ "Gender" => "Women's"
24
+ },
25
+ "Ruby on Rails Ringer T-Shirt" =>
26
+ {
27
+ "Manufacturer" => "Jerseys",
28
+ "Brand" => "Conditioned",
29
+ "Model" => "TL9002",
30
+ "Shirt Type" => "Ringer T",
31
+ "Sleeve Type" => "Short",
32
+ "Made from" => "100% Vellum",
33
+ "Fit" => "Loose",
34
+ "Gender" => "Men's"
35
+ },
36
+ "Ruby on Rails Tote" =>
37
+ {
38
+ "Type" => "Tote",
39
+ "Size" => %Q{15" x 18" x 6"},
40
+ "Material" => "Canvas"
41
+ },
42
+ "Ruby on Rails Bag" =>
43
+ {
44
+ "Type" => "Messenger",
45
+ "Size" => %Q{14 1/2" x 12" x 5"},
46
+ "Material" => "600 Denier Polyester"
47
+ },
48
+ "Ruby on Rails Mug" =>
49
+ {
50
+ "Type" => "Mug",
51
+ "Size" => %Q{4.5" tall, 3.25" dia.}
52
+ },
53
+ "Ruby on Rails Stein" =>
54
+ {
55
+ "Type" => "Stein",
56
+ "Size" => %Q{6.75" tall, 3.75" dia. base, 3" dia. rim}
57
+ },
58
+ "Spree Stein" =>
59
+ {
60
+ "Type" => "Stein",
61
+ "Size" => %Q{6.75" tall, 3.75" dia. base, 3" dia. rim}
62
+ },
63
+ "Spree Mug" =>
64
+ {
65
+ "Type" => "Mug",
66
+ "Size" => %Q{4.5" tall, 3.25" dia.}
67
+ },
68
+ "Spree Tote" =>
69
+ {
70
+ "Type" => "Tote",
71
+ "Size" => %Q{15" x 18" x 6"}
72
+ },
73
+ "Spree Bag" =>
74
+ {
75
+ "Type" => "Messenger",
76
+ "Size" => %Q{14 1/2" x 12" x 5"}
77
+ },
78
+ "Spree Baseball Jersey" =>
79
+ {
80
+ "Manufacturer" => "Wilson",
81
+ "Brand" => "Wannabe Sports",
82
+ "Model" => "JK1002",
83
+ "Shirt Type" => "Baseball Jersey",
84
+ "Sleeve Type" => "Long",
85
+ "Made from" => "100% cotton",
86
+ "Fit" => "Loose",
87
+ "Gender" => "Men's"
88
+ },
89
+ "Spree Jr. Spaghetti" =>
90
+ {
91
+ "Manufacturer" => "Jerseys",
92
+ "Brand" => "Resiliance",
93
+ "Model" => "TL174",
94
+ "Shirt Type" => "Jr. Spaghetti T",
95
+ "Sleeve Type" => "None",
96
+ "Made from" => "90% Cotton, 10% Nylon",
97
+ "Fit" => "Form",
98
+ "Gender" => "Women's"
99
+ },
100
+ "Spree Ringer T-Shirt" =>
101
+ {
102
+ "Manufacturer" => "Jerseys",
103
+ "Brand" => "Conditioned",
104
+ "Model" => "TL9002",
105
+ "Shirt Type" => "Ringer T",
106
+ "Sleeve Type" => "Short",
107
+ "Made from" => "100% Vellum",
108
+ "Fit" => "Loose",
109
+ "Gender" => "Men's"
110
+ },
111
+ }
112
+
113
+ products.each do |name, properties|
114
+ product = Spree::Product.find_by_name(name)
115
+ properties.each do |prop_name, prop_value|
116
+ product.set_property(prop_name, prop_value)
117
+ end
118
+ end
@@ -0,0 +1,137 @@
1
+ Spree::Sample.load_sample("tax_categories")
2
+ Spree::Sample.load_sample("shipping_categories")
3
+
4
+ clothing = Spree::TaxCategory.find_by_name!("Clothing")
5
+ shipping_category = Spree::ShippingCategory.find_by_name!("Default")
6
+
7
+ default_attrs = {
8
+ :description => Faker::Lorem.paragraph,
9
+ :available_on => Time.zone.now
10
+ }
11
+
12
+ products = [
13
+ {
14
+ :name => "Ruby on Rails Tote",
15
+ :tax_category => clothing,
16
+ :shipping_category => shipping_category,
17
+ :price => 15.99,
18
+ :eur_price => 14,
19
+ },
20
+ {
21
+ :name => "Ruby on Rails Bag",
22
+ :tax_category => clothing,
23
+ :shipping_category => shipping_category,
24
+ :price => 22.99,
25
+ :eur_price => 19,
26
+ },
27
+ {
28
+ :name => "Ruby on Rails Baseball Jersey",
29
+ :tax_category => clothing,
30
+ :shipping_category => shipping_category,
31
+ :price => 19.99,
32
+ :eur_price => 16
33
+ },
34
+ {
35
+ :name => "Ruby on Rails Jr. Spaghetti",
36
+ :tax_category => clothing,
37
+ :shipping_category => shipping_category,
38
+ :price => 19.99,
39
+ :eur_price => 16
40
+
41
+ },
42
+ {
43
+ :name => "Ruby on Rails Ringer T-Shirt",
44
+ :shipping_category => shipping_category,
45
+ :tax_category => clothing,
46
+ :price => 19.99,
47
+ :eur_price => 16
48
+ },
49
+ {
50
+ :name => "Ruby Baseball Jersey",
51
+ :tax_category => clothing,
52
+ :shipping_category => shipping_category,
53
+ :price => 19.99,
54
+ :eur_price => 16
55
+ },
56
+ {
57
+ :name => "Apache Baseball Jersey",
58
+ :tax_category => clothing,
59
+ :shipping_category => shipping_category,
60
+ :price => 19.99,
61
+ :eur_price => 16
62
+ },
63
+ {
64
+ :name => "Spree Baseball Jersey",
65
+ :tax_category => clothing,
66
+ :shipping_category => shipping_category,
67
+ :price => 19.99,
68
+ :eur_price => 16
69
+ },
70
+ {
71
+ :name => "Spree Jr. Spaghetti",
72
+ :tax_category => clothing,
73
+ :shipping_category => shipping_category,
74
+ :price => 19.99,
75
+ :eur_price => 16
76
+ },
77
+ {
78
+ :name => "Spree Ringer T-Shirt",
79
+ :tax_category => clothing,
80
+ :shipping_category => shipping_category,
81
+ :price => 19.99,
82
+ :eur_price => 16
83
+ },
84
+ {
85
+ :name => "Spree Tote",
86
+ :tax_category => clothing,
87
+ :shipping_category => shipping_category,
88
+ :price => 15.99,
89
+ :eur_price => 14,
90
+ },
91
+ {
92
+ :name => "Spree Bag",
93
+ :tax_category => clothing,
94
+ :shipping_category => shipping_category,
95
+ :price => 22.99,
96
+ :eur_price => 19
97
+ },
98
+ {
99
+ :name => "Ruby on Rails Mug",
100
+ :shipping_category => shipping_category,
101
+ :price => 13.99,
102
+ :eur_price => 12
103
+ },
104
+ {
105
+ :name => "Ruby on Rails Stein",
106
+ :shipping_category => shipping_category,
107
+ :price => 16.99,
108
+ :eur_price => 14
109
+ },
110
+ {
111
+ :name => "Spree Stein",
112
+ :shipping_category => shipping_category,
113
+ :price => 16.99,
114
+ :eur_price => 14,
115
+ },
116
+ {
117
+ :name => "Spree Mug",
118
+ :shipping_category => shipping_category,
119
+ :price => 13.99,
120
+ :eur_price => 12
121
+ }
122
+ ]
123
+
124
+ products.each do |product_attrs|
125
+ eur_price = product_attrs.delete(:eur_price)
126
+ Spree::Config[:currency] = "USD"
127
+
128
+ default_shipping_category = Spree::ShippingCategory.find_by_name!("Default")
129
+ product = Spree::Product.create!(default_attrs.merge(product_attrs))
130
+ Spree::Config[:currency] = "EUR"
131
+ product.reload
132
+ product.price = eur_price
133
+ product.shipping_category = default_shipping_category
134
+ product.save!
135
+ end
136
+
137
+ Spree::Config[:currency] = "USD"
@@ -0,0 +1,21 @@
1
+ prototypes = [
2
+ {
3
+ :name => "Shirt",
4
+ :properties => ["Manufacturer", "Brand", "Model", "Shirt Type", "Sleeve Type", "Material", "Fit", "Gender"]
5
+ },
6
+ {
7
+ :name => "Bag",
8
+ :properties => ["Type", "Size", "Material"]
9
+ },
10
+ {
11
+ :name => "Mugs",
12
+ :properties => ["Size", "Type"]
13
+ }
14
+ ]
15
+
16
+ prototypes.each do |prototype_attrs|
17
+ prototype = Spree::Prototype.create!(:name => prototype_attrs[:name])
18
+ prototype_attrs[:properties].each do |property|
19
+ prototype.properties << Spree::Property.where(name: property).first
20
+ end
21
+ end
@@ -0,0 +1 @@
1
+ Spree::ShippingCategory.find_or_create_by!(:name => "Default")
@@ -0,0 +1,60 @@
1
+ begin
2
+ north_america = Spree::Zone.find_by_name!("North America")
3
+ rescue ActiveRecord::RecordNotFound
4
+ puts "Couldn't find 'North America' zone. Did you run `rake db:seed` first?"
5
+ puts "That task will set up the countries, states and zones required for Spree."
6
+ exit
7
+ end
8
+
9
+ europe_vat = Spree::Zone.find_by_name!("EU_VAT")
10
+ shipping_category = Spree::ShippingCategory.find_or_create_by!(name: 'Default')
11
+
12
+ Spree::ShippingMethod.create!([
13
+ {
14
+ :name => "UPS Ground (USD)",
15
+ :zones => [north_america],
16
+ :calculator => Spree::Calculator::Shipping::FlatRate.create!,
17
+ :shipping_categories => [shipping_category]
18
+ },
19
+ {
20
+ :name => "UPS Two Day (USD)",
21
+ :zones => [north_america],
22
+ :calculator => Spree::Calculator::Shipping::FlatRate.create!,
23
+ :shipping_categories => [shipping_category]
24
+ },
25
+ {
26
+ :name => "UPS One Day (USD)",
27
+ :zones => [north_america],
28
+ :calculator => Spree::Calculator::Shipping::FlatRate.create!,
29
+ :shipping_categories => [shipping_category]
30
+ },
31
+ {
32
+ :name => "UPS Ground (EU)",
33
+ :zones => [europe_vat],
34
+ :calculator => Spree::Calculator::Shipping::FlatRate.create!,
35
+ :shipping_categories => [shipping_category]
36
+ },
37
+ {
38
+ :name => "UPS Ground (EUR)",
39
+ :zones => [europe_vat],
40
+ :calculator => Spree::Calculator::Shipping::FlatRate.create!,
41
+ :shipping_categories => [shipping_category]
42
+ }
43
+ ])
44
+
45
+ {
46
+ "UPS Ground (USD)" => [5, "USD"],
47
+ "UPS Ground (EU)" => [5, "USD"],
48
+ "UPS One Day (USD)" => [15, "USD"],
49
+ "UPS Two Day (USD)" => [10, "USD"],
50
+ "UPS Ground (EUR)" => [8, "EUR"]
51
+ }.each do |shipping_method_name, (price, currency)|
52
+ shipping_method = Spree::ShippingMethod.find_by_name!(shipping_method_name)
53
+ shipping_method.calculator.preferences = {
54
+ amount: price,
55
+ currency: currency
56
+ }
57
+ shipping_method.calculator.save!
58
+ shipping_method.save!
59
+ end
60
+
@@ -0,0 +1,12 @@
1
+ Spree::Sample.load_sample("variants")
2
+
3
+ country = Spree::Country.find_by(iso: 'US')
4
+ location = Spree::StockLocation.first_or_create! name: 'default', address1: 'Example Street', city: 'City', zipcode: '12345', country: country, state: country.states.first
5
+ location.active = true
6
+ location.save!
7
+
8
+ Spree::Variant.all.each do |variant|
9
+ variant.stock_items.each do |stock_item|
10
+ Spree::StockMovement.create(:quantity => 10, :stock_item => stock_item)
11
+ end
12
+ end
@@ -0,0 +1,2 @@
1
+ Spree::TaxCategory.create!(:name => "Clothing")
2
+ Spree::TaxCategory.create!(:name => "Food")
@@ -0,0 +1,9 @@
1
+ north_america = Spree::Zone.find_by_name!("North America")
2
+ clothing = Spree::TaxCategory.find_by_name!("Clothing")
3
+ tax_rate = Spree::TaxRate.create(
4
+ :name => "North America",
5
+ :zone => north_america,
6
+ :amount => 0.05,
7
+ :tax_category => clothing)
8
+ tax_rate.calculator = Spree::Calculator::DefaultTax.create!
9
+ tax_rate.save!
@@ -0,0 +1,8 @@
1
+ taxonomies = [
2
+ { name: "Categories" },
3
+ { name: "Brand" }
4
+ ]
5
+
6
+ taxonomies.each do |taxonomy_attrs|
7
+ Spree::Taxonomy.create!(taxonomy_attrs)
8
+ end
@@ -0,0 +1,145 @@
1
+ Spree::Sample.load_sample("taxonomies")
2
+ Spree::Sample.load_sample("products")
3
+
4
+ categories = Spree::Taxonomy.find_by_name!("Categories")
5
+ brands = Spree::Taxonomy.find_by_name!("Brand")
6
+
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
+ }
25
+
26
+
27
+ products.each do |key, name|
28
+ products[key] = Spree::Product.find_by_name!(name)
29
+ end
30
+
31
+ taxons = [
32
+ {
33
+ :name => "Categories",
34
+ :taxonomy => categories,
35
+ :position => 0
36
+ },
37
+ {
38
+ :name => "Bags",
39
+ :taxonomy => categories,
40
+ :parent => "Categories",
41
+ :position => 1,
42
+ :products => [
43
+ products[:ror_tote],
44
+ products[:ror_bag],
45
+ products[:spree_tote],
46
+ products[:spree_bag]
47
+ ]
48
+ },
49
+ {
50
+ :name => "Mugs",
51
+ :taxonomy => categories,
52
+ :parent => "Categories",
53
+ :position => 2,
54
+ :products => [
55
+ products[:ror_mug],
56
+ products[:ror_stein],
57
+ products[:spree_stein],
58
+ products[:spree_mug]
59
+ ]
60
+ },
61
+ {
62
+ :name => "Clothing",
63
+ :taxonomy => categories,
64
+ :parent => "Categories"
65
+ },
66
+ {
67
+ :name => "Shirts",
68
+ :taxonomy => categories,
69
+ :parent => "Clothing",
70
+ :position => 0,
71
+ :products => [
72
+ products[:ror_jr_spaghetti],
73
+ products[:spree_jr_spaghetti]
74
+ ]
75
+ },
76
+ {
77
+ :name => "T-Shirts",
78
+ :taxonomy => categories,
79
+ :parent => "Clothing" ,
80
+ :products => [
81
+ products[:ror_baseball_jersey],
82
+ products[:ror_ringer],
83
+ products[:apache_baseball_jersey],
84
+ products[:ruby_baseball_jersey],
85
+ products[:spree_baseball_jersey],
86
+ products[:spree_ringer]
87
+ ],
88
+ :position => 0
89
+ },
90
+ {
91
+ :name => "Brands",
92
+ :taxonomy => brands
93
+ },
94
+ {
95
+ :name => "Ruby",
96
+ :taxonomy => brands,
97
+ :parent => "Brand",
98
+ :products => [
99
+ products[:ruby_baseball_jersey]
100
+ ]
101
+ },
102
+ {
103
+ :name => "Apache",
104
+ :taxonomy => brands,
105
+ :parent => "Brand",
106
+ :products => [
107
+ products[:apache_baseball_jersey]
108
+ ]
109
+ },
110
+ {
111
+ :name => "Spree",
112
+ :taxonomy => brands,
113
+ :parent => "Brand",
114
+ :products => [
115
+ products[:spree_stein],
116
+ products[:spree_mug],
117
+ products[:spree_ringer],
118
+ products[:spree_baseball_jersey],
119
+ products[:spree_tote],
120
+ products[:spree_bag],
121
+ products[:spree_jr_spaghetti],
122
+ ]
123
+ },
124
+ {
125
+ :name => "Rails",
126
+ :taxonomy => brands,
127
+ :parent => "Brand",
128
+ :products => [
129
+ products[:ror_tote],
130
+ products[:ror_bag],
131
+ products[:ror_mug],
132
+ products[:ror_stein],
133
+ products[:ror_baseball_jersey],
134
+ products[:ror_jr_spaghetti],
135
+ products[:ror_ringer],
136
+ ]
137
+ },
138
+ ]
139
+
140
+ taxons.each do |taxon_attrs|
141
+ if taxon_attrs[:parent]
142
+ taxon_attrs[:parent] = Spree::Taxon.where(name: taxon_attrs[:parent]).first
143
+ Spree::Taxon.create!(taxon_attrs)
144
+ end
145
+ end