goca-spree-sample 3.1.14.rails.5.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 (63) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +5 -0
  3. data/LICENSE +26 -0
  4. data/Rakefile +15 -0
  5. data/db/samples/addresses.rb +26 -0
  6. data/db/samples/adjustments.rb +20 -0
  7. data/db/samples/assets.rb +159 -0
  8. data/db/samples/images/apache_baseball.png +0 -0
  9. data/db/samples/images/ror_bag.jpeg +0 -0
  10. data/db/samples/images/ror_baseball.jpeg +0 -0
  11. data/db/samples/images/ror_baseball_back.jpeg +0 -0
  12. data/db/samples/images/ror_baseball_jersey_back_blue.png +0 -0
  13. data/db/samples/images/ror_baseball_jersey_back_green.png +0 -0
  14. data/db/samples/images/ror_baseball_jersey_back_red.png +0 -0
  15. data/db/samples/images/ror_baseball_jersey_blue.png +0 -0
  16. data/db/samples/images/ror_baseball_jersey_green.png +0 -0
  17. data/db/samples/images/ror_baseball_jersey_red.png +0 -0
  18. data/db/samples/images/ror_jr_spaghetti.jpeg +0 -0
  19. data/db/samples/images/ror_mug.jpeg +0 -0
  20. data/db/samples/images/ror_mug_back.jpeg +0 -0
  21. data/db/samples/images/ror_ringer.jpeg +0 -0
  22. data/db/samples/images/ror_ringer_back.jpeg +0 -0
  23. data/db/samples/images/ror_stein.jpeg +0 -0
  24. data/db/samples/images/ror_stein_back.jpeg +0 -0
  25. data/db/samples/images/ror_tote.jpeg +0 -0
  26. data/db/samples/images/ror_tote_back.jpeg +0 -0
  27. data/db/samples/images/ruby_baseball.png +0 -0
  28. data/db/samples/images/spree_bag.jpeg +0 -0
  29. data/db/samples/images/spree_jersey.jpeg +0 -0
  30. data/db/samples/images/spree_jersey_back.jpeg +0 -0
  31. data/db/samples/images/spree_mug.jpeg +0 -0
  32. data/db/samples/images/spree_mug_back.jpeg +0 -0
  33. data/db/samples/images/spree_ringer_t.jpeg +0 -0
  34. data/db/samples/images/spree_ringer_t_back.jpeg +0 -0
  35. data/db/samples/images/spree_spaghetti.jpeg +0 -0
  36. data/db/samples/images/spree_stein.jpeg +0 -0
  37. data/db/samples/images/spree_stein_back.jpeg +0 -0
  38. data/db/samples/images/spree_tote_back.jpeg +0 -0
  39. data/db/samples/images/spree_tote_front.jpeg +0 -0
  40. data/db/samples/option_types.rb +12 -0
  41. data/db/samples/option_values.rb +49 -0
  42. data/db/samples/orders.rb +38 -0
  43. data/db/samples/payment_methods.rb +15 -0
  44. data/db/samples/payments.rb +22 -0
  45. data/db/samples/product_option_types.rb +12 -0
  46. data/db/samples/product_properties.rb +118 -0
  47. data/db/samples/products.rb +137 -0
  48. data/db/samples/prototypes.rb +21 -0
  49. data/db/samples/shipping_categories.rb +1 -0
  50. data/db/samples/shipping_methods.rb +60 -0
  51. data/db/samples/stock.rb +12 -0
  52. data/db/samples/store_credit_categories.rb +1 -0
  53. data/db/samples/tax_categories.rb +2 -0
  54. data/db/samples/tax_rates.rb +9 -0
  55. data/db/samples/taxonomies.rb +8 -0
  56. data/db/samples/taxons.rb +145 -0
  57. data/db/samples/variants.rb +164 -0
  58. data/db/samples.rb +2 -0
  59. data/lib/spree/sample.rb +23 -0
  60. data/lib/spree_sample.rb +32 -0
  61. data/lib/tasks/sample.rake +24 -0
  62. data/spree_sample.gemspec +21 -0
  63. metadata +119 -0
@@ -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: FFaker::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 @@
1
+ Spree::StoreCreditCategory.find_or_create_by!(name: "Default")
@@ -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
@@ -0,0 +1,164 @@
1
+ Spree::Sample.load_sample("option_values")
2
+ Spree::Sample.load_sample("products")
3
+
4
+ ror_baseball_jersey = Spree::Product.find_by_name!("Ruby on Rails Baseball Jersey")
5
+ ror_tote = Spree::Product.find_by_name!("Ruby on Rails Tote")
6
+ ror_bag = Spree::Product.find_by_name!("Ruby on Rails Bag")
7
+ ror_jr_spaghetti = Spree::Product.find_by_name!("Ruby on Rails Jr. Spaghetti")
8
+ ror_mug = Spree::Product.find_by_name!("Ruby on Rails Mug")
9
+ ror_ringer = Spree::Product.find_by_name!("Ruby on Rails Ringer T-Shirt")
10
+ ror_stein = Spree::Product.find_by_name!("Ruby on Rails Stein")
11
+ spree_baseball_jersey = Spree::Product.find_by_name!("Spree Baseball Jersey")
12
+ spree_stein = Spree::Product.find_by_name!("Spree Stein")
13
+ spree_jr_spaghetti = Spree::Product.find_by_name!("Spree Jr. Spaghetti")
14
+ spree_mug = Spree::Product.find_by_name!("Spree Mug")
15
+ spree_ringer = Spree::Product.find_by_name!("Spree Ringer T-Shirt")
16
+ spree_tote = Spree::Product.find_by_name!("Spree Tote")
17
+ spree_bag = Spree::Product.find_by_name!("Spree Bag")
18
+ ruby_baseball_jersey = Spree::Product.find_by_name!("Ruby Baseball Jersey")
19
+ apache_baseball_jersey = Spree::Product.find_by_name!("Apache Baseball Jersey")
20
+
21
+ small = Spree::OptionValue.where(name: "Small").first
22
+ medium = Spree::OptionValue.where(name: "Medium").first
23
+ large = Spree::OptionValue.where(name: "Large").first
24
+ extra_large = Spree::OptionValue.where(name: "Extra Large").first
25
+
26
+ red = Spree::OptionValue.where(name: "Red").first
27
+ blue = Spree::OptionValue.where(name: "Blue").first
28
+ green = Spree::OptionValue.where(name: "Green").first
29
+
30
+ variants = [
31
+ {
32
+ :product => ror_baseball_jersey,
33
+ :option_values => [small, red],
34
+ :sku => "ROR-00001",
35
+ :cost_price => 17
36
+ },
37
+ {
38
+ :product => ror_baseball_jersey,
39
+ :option_values => [small, blue],
40
+ :sku => "ROR-00002",
41
+ :cost_price => 17
42
+ },
43
+ {
44
+ :product => ror_baseball_jersey,
45
+ :option_values => [small, green],
46
+ :sku => "ROR-00003",
47
+ :cost_price => 17
48
+ },
49
+ {
50
+ :product => ror_baseball_jersey,
51
+ :option_values => [medium, red],
52
+ :sku => "ROR-00004",
53
+ :cost_price => 17
54
+ },
55
+ {
56
+ :product => ror_baseball_jersey,
57
+ :option_values => [medium, blue],
58
+ :sku => "ROR-00005",
59
+ :cost_price => 17
60
+ },
61
+ {
62
+ :product => ror_baseball_jersey,
63
+ :option_values => [medium, green],
64
+ :sku => "ROR-00006",
65
+ :cost_price => 17
66
+ },
67
+ {
68
+ :product => ror_baseball_jersey,
69
+ :option_values => [large, red],
70
+ :sku => "ROR-00007",
71
+ :cost_price => 17
72
+ },
73
+ {
74
+ :product => ror_baseball_jersey,
75
+ :option_values => [large, blue],
76
+ :sku => "ROR-00008",
77
+ :cost_price => 17
78
+ },
79
+ {
80
+ :product => ror_baseball_jersey,
81
+ :option_values => [large, green],
82
+ :sku => "ROR-00009",
83
+ :cost_price => 17
84
+ },
85
+ {
86
+ :product => ror_baseball_jersey,
87
+ :option_values => [extra_large, green],
88
+ :sku => "ROR-00010",
89
+ :cost_price => 17
90
+ },
91
+ ]
92
+
93
+ masters = {
94
+ ror_baseball_jersey => {
95
+ :sku => "ROR-001",
96
+ :cost_price => 17,
97
+ },
98
+ ror_tote => {
99
+ :sku => "ROR-00011",
100
+ :cost_price => 17
101
+ },
102
+ ror_bag => {
103
+ :sku => "ROR-00012",
104
+ :cost_price => 21
105
+ },
106
+ ror_jr_spaghetti => {
107
+ :sku => "ROR-00013",
108
+ :cost_price => 17
109
+ },
110
+ ror_mug => {
111
+ :sku => "ROR-00014",
112
+ :cost_price => 11
113
+ },
114
+ ror_ringer => {
115
+ :sku => "ROR-00015",
116
+ :cost_price => 17
117
+ },
118
+ ror_stein => {
119
+ :sku => "ROR-00016",
120
+ :cost_price => 15
121
+ },
122
+ apache_baseball_jersey => {
123
+ :sku => "APC-00001",
124
+ :cost_price => 17
125
+ },
126
+ ruby_baseball_jersey => {
127
+ :sku => "RUB-00001",
128
+ :cost_price => 17
129
+ },
130
+ spree_baseball_jersey => {
131
+ :sku => "SPR-00001",
132
+ :cost_price => 17
133
+ },
134
+ spree_stein => {
135
+ :sku => "SPR-00016",
136
+ :cost_price => 15
137
+ },
138
+ spree_jr_spaghetti => {
139
+ :sku => "SPR-00013",
140
+ :cost_price => 17
141
+ },
142
+ spree_mug => {
143
+ :sku => "SPR-00014",
144
+ :cost_price => 11
145
+ },
146
+ spree_ringer => {
147
+ :sku => "SPR-00015",
148
+ :cost_price => 17
149
+ },
150
+ spree_tote => {
151
+ :sku => "SPR-00011",
152
+ :cost_price => 13
153
+ },
154
+ spree_bag => {
155
+ :sku => "SPR-00012",
156
+ :cost_price => 21
157
+ }
158
+ }
159
+
160
+ Spree::Variant.create!(variants)
161
+
162
+ masters.each do |product, variant_attrs|
163
+ product.master.update_attributes!(variant_attrs)
164
+ end
data/db/samples.rb ADDED
@@ -0,0 +1,2 @@
1
+ Spree::Sample.load_sample("payment_methods")
2
+ Spree::Sample.load_sample("shipping_categories")
@@ -0,0 +1,23 @@
1
+ module Spree
2
+ module Sample
3
+ def self.load_sample(file)
4
+ # If file exists within application it takes precendence.
5
+ if File.exists?(File.join(Rails.root, 'db', 'samples', "#{file}.rb"))
6
+ path = File.expand_path(File.join(Rails.root, 'db', 'samples', "#{file}.rb"))
7
+ else
8
+ # Otherwise we will use this gems default file.
9
+ path = File.expand_path(samples_path + "#{file}.rb")
10
+ end
11
+ # Check to see if the specified file has been loaded before
12
+ if !$LOADED_FEATURES.include?(path)
13
+ require path
14
+ puts "Loaded #{file.titleize} samples"
15
+ end
16
+ end
17
+
18
+ private
19
+ def self.samples_path
20
+ Pathname.new(File.join(File.dirname(__FILE__), '..', '..', 'db', 'samples'))
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,32 @@
1
+ require 'spree_core'
2
+ require 'spree/sample'
3
+
4
+ module SpreeSample
5
+ class Engine < Rails::Engine
6
+ engine_name 'spree_sample'
7
+
8
+ # Needs to be here so we can access it inside the tests
9
+ def self.load_samples
10
+ Spree::Sample.load_sample("payment_methods")
11
+ Spree::Sample.load_sample("shipping_categories")
12
+ Spree::Sample.load_sample("shipping_methods")
13
+ Spree::Sample.load_sample("tax_categories")
14
+ Spree::Sample.load_sample("tax_rates")
15
+
16
+ Spree::Sample.load_sample("products")
17
+ Spree::Sample.load_sample("taxons")
18
+ Spree::Sample.load_sample("option_values")
19
+ Spree::Sample.load_sample("product_option_types")
20
+ Spree::Sample.load_sample("product_properties")
21
+ Spree::Sample.load_sample("prototypes")
22
+ Spree::Sample.load_sample("variants")
23
+ Spree::Sample.load_sample("stock")
24
+ Spree::Sample.load_sample("assets")
25
+
26
+ Spree::Sample.load_sample("orders")
27
+ Spree::Sample.load_sample("adjustments")
28
+ Spree::Sample.load_sample("payments")
29
+ Spree::Sample.load_sample("store_credit_categories")
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,24 @@
1
+ require 'ffaker'
2
+ require 'pathname'
3
+ require 'spree/sample'
4
+
5
+ namespace :spree_sample do
6
+ desc 'Loads sample data'
7
+ task :load => :environment do
8
+ if ARGV.include?("db:migrate")
9
+ puts %Q{
10
+ Please run db:migrate separately from spree_sample:load.
11
+
12
+ Running db:migrate and spree_sample:load at the same time has been known to
13
+ cause problems where columns may be not available during sample data loading.
14
+
15
+ Migrations have been run. Please run "rake spree_sample:load" by itself now.
16
+ }
17
+ exit(1)
18
+ end
19
+
20
+ SpreeSample::Engine.load_samples
21
+ end
22
+ end
23
+
24
+
@@ -0,0 +1,21 @@
1
+ # encoding: UTF-8
2
+ require_relative '../core/lib/spree/core/version.rb'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.platform = Gem::Platform::RUBY
6
+ s.name = 'goca-spree-sample'
7
+ s.version = Spree.version
8
+ s.summary = 'Sample data (including images) for use with Spree.'
9
+ s.description = 'Required dependency for Spree'
10
+
11
+ s.author = 'Sean Schofield'
12
+ s.email = 'sean@spreecommerce.com'
13
+ s.homepage = 'http://spreecommerce.com'
14
+ s.license = 'BSD-3'
15
+
16
+ s.files = `git ls-files`.split("\n").reject { |f| f.match(/^spec/) && !f.match(/^spec\/fixtures/) }
17
+ s.require_path = 'lib'
18
+ s.requirements << 'none'
19
+
20
+ s.add_dependency 'goca-spree-core', s.version
21
+ end