solidus_sample 1.0.0.pre

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 (47) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +26 -0
  3. data/db/samples/addresses.rb +26 -0
  4. data/db/samples/assets.rb +102 -0
  5. data/db/samples/images/apache_baseball.png +0 -0
  6. data/db/samples/images/ror_bag.jpeg +0 -0
  7. data/db/samples/images/ror_baseball.jpeg +0 -0
  8. data/db/samples/images/ror_baseball_back.jpeg +0 -0
  9. data/db/samples/images/ror_baseball_jersey_back_blue.png +0 -0
  10. data/db/samples/images/ror_baseball_jersey_back_green.png +0 -0
  11. data/db/samples/images/ror_baseball_jersey_back_red.png +0 -0
  12. data/db/samples/images/ror_baseball_jersey_blue.png +0 -0
  13. data/db/samples/images/ror_baseball_jersey_green.png +0 -0
  14. data/db/samples/images/ror_baseball_jersey_red.png +0 -0
  15. data/db/samples/images/ror_jr_spaghetti.jpeg +0 -0
  16. data/db/samples/images/ror_mug.jpeg +0 -0
  17. data/db/samples/images/ror_mug_back.jpeg +0 -0
  18. data/db/samples/images/ror_ringer.jpeg +0 -0
  19. data/db/samples/images/ror_ringer_back.jpeg +0 -0
  20. data/db/samples/images/ror_stein.jpeg +0 -0
  21. data/db/samples/images/ror_stein_back.jpeg +0 -0
  22. data/db/samples/images/ror_tote.jpeg +0 -0
  23. data/db/samples/images/ror_tote_back.jpeg +0 -0
  24. data/db/samples/images/ruby_baseball.png +0 -0
  25. data/db/samples/option_types.rb +12 -0
  26. data/db/samples/option_values.rb +49 -0
  27. data/db/samples/orders.rb +39 -0
  28. data/db/samples/payment_methods.rb +43 -0
  29. data/db/samples/payments.rb +22 -0
  30. data/db/samples/product_option_types.rb +9 -0
  31. data/db/samples/product_properties.rb +65 -0
  32. data/db/samples/products.rb +90 -0
  33. data/db/samples/prototypes.rb +21 -0
  34. data/db/samples/shipping_categories.rb +1 -0
  35. data/db/samples/shipping_methods.rb +66 -0
  36. data/db/samples/stock.rb +12 -0
  37. data/db/samples/tax_categories.rb +1 -0
  38. data/db/samples/tax_rates.rb +9 -0
  39. data/db/samples/taxonomies.rb +8 -0
  40. data/db/samples/taxons.rb +117 -0
  41. data/db/samples/variants.rb +129 -0
  42. data/db/samples.rb +2 -0
  43. data/lib/solidus_sample.rb +1 -0
  44. data/lib/spree/sample.rb +24 -0
  45. data/lib/spree_sample.rb +30 -0
  46. data/lib/tasks/sample.rake +24 -0
  47. metadata +103 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1554766c4e3a244942ea121b1b1e1b9945af53c4
4
+ data.tar.gz: 339df5d753aabd79f5e3132952274b2da5cb7f86
5
+ SHA512:
6
+ metadata.gz: d205e6380dc364c930ab873cb77619e8a698b68b1d7c783423e9cc97d86ed6c4aef4ffc9b724c3b599b386b397a6a6bf7c4d7dc8970798ba4228d13564317132
7
+ data.tar.gz: d03c8d90627c748591ed027ed44a756624eb46d4a27d67dcfbfb787dd091376d08ebf7107cf146e104532f9e9f19222c65778456bee3e7e0d22b48369ab2fad3
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2007-2014, Spree Commerce, Inc. and other contributors
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,26 @@
1
+ united_states = Spree::Country.find_by_name!("United States")
2
+ new_york = Spree::State.find_by_name!("New York")
3
+
4
+ # Billing address
5
+ Spree::Address.create!(
6
+ :firstname => Faker::Name.first_name,
7
+ :lastname => Faker::Name.last_name,
8
+ :address1 => Faker::Address.street_address,
9
+ :address2 => Faker::Address.secondary_address,
10
+ :city => Faker::Address.city,
11
+ :state => new_york,
12
+ :zipcode => 16804,
13
+ :country => united_states,
14
+ :phone => Faker::PhoneNumber.phone_number)
15
+
16
+ #Shipping address
17
+ Spree::Address.create!(
18
+ :firstname => Faker::Name.first_name,
19
+ :lastname => Faker::Name.last_name,
20
+ :address1 => Faker::Address.street_address,
21
+ :address2 => Faker::Address.secondary_address,
22
+ :city => Faker::Address.city,
23
+ :state => new_york,
24
+ :zipcode => 16804,
25
+ :country => united_states,
26
+ :phone => Faker::PhoneNumber.phone_number)
@@ -0,0 +1,102 @@
1
+ Spree::Sample.load_sample("products")
2
+ Spree::Sample.load_sample("variants")
3
+
4
+ products = {}
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[:ruby_baseball_jersey] = Spree::Product.find_by_name!("Ruby Baseball Jersey")
13
+ products[:apache_baseball_jersey] = Spree::Product.find_by_name!("Apache Baseball Jersey")
14
+
15
+
16
+ def image(name, type="jpeg")
17
+ images_path = Pathname.new(File.dirname(__FILE__)) + "images"
18
+ path = images_path + "#{name}.#{type}"
19
+ return false if !File.exist?(path)
20
+ File.open(path)
21
+ end
22
+
23
+ images = {
24
+ products[:ror_tote].master => [
25
+ {
26
+ :attachment => image("ror_tote")
27
+ },
28
+ {
29
+ :attachment => image("ror_tote_back")
30
+ }
31
+ ],
32
+ products[:ror_bag].master => [
33
+ {
34
+ :attachment => image("ror_bag")
35
+ }
36
+ ],
37
+ products[:ror_baseball_jersey].master => [
38
+ {
39
+ :attachment => image("ror_baseball")
40
+ },
41
+ {
42
+ :attachment => image("ror_baseball_back")
43
+ }
44
+ ],
45
+ products[:ror_jr_spaghetti].master => [
46
+ {
47
+ :attachment => image("ror_jr_spaghetti")
48
+ }
49
+ ],
50
+ products[:ror_mug].master => [
51
+ {
52
+ :attachment => image("ror_mug")
53
+ },
54
+ {
55
+ :attachment => image("ror_mug_back")
56
+ }
57
+ ],
58
+ products[:ror_ringer].master => [
59
+ {
60
+ :attachment => image("ror_ringer")
61
+ },
62
+ {
63
+ :attachment => image("ror_ringer_back")
64
+ }
65
+ ],
66
+ products[:ror_stein].master => [
67
+ {
68
+ :attachment => image("ror_stein")
69
+ },
70
+ {
71
+ :attachment => image("ror_stein_back")
72
+ }
73
+ ],
74
+ products[:apache_baseball_jersey].master => [
75
+ {
76
+ :attachment => image("apache_baseball", "png")
77
+ },
78
+ ],
79
+ products[:ruby_baseball_jersey].master => [
80
+ {
81
+ :attachment => image("ruby_baseball", "png")
82
+ },
83
+ ]
84
+ }
85
+
86
+ products[:ror_baseball_jersey].variants.each do |variant|
87
+ color = variant.option_value("tshirt-color").downcase
88
+ main_image = image("ror_baseball_jersey_#{color}", "png")
89
+ variant.images.create!(:attachment => main_image)
90
+ back_image = image("ror_baseball_jersey_back_#{color}", "png")
91
+ if back_image
92
+ variant.images.create!(:attachment => back_image)
93
+ end
94
+ end
95
+
96
+ images.each do |variant, attachments|
97
+ puts "Loading images for #{variant.product.name}"
98
+ attachments.each do |attachment|
99
+ variant.images.create!(attachment)
100
+ end
101
+ end
102
+
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,12 @@
1
+ Spree::OptionType.create!([
2
+ {
3
+ :name => "tshirt-size",
4
+ :presentation => "Size",
5
+ :position => 1
6
+ },
7
+ {
8
+ :name => "tshirt-color",
9
+ :presentation => "Color",
10
+ :position => 2
11
+ }
12
+ ])
@@ -0,0 +1,49 @@
1
+ Spree::Sample.load_sample("option_types")
2
+
3
+ size = Spree::OptionType.find_by_presentation!("Size")
4
+ color = Spree::OptionType.find_by_presentation!("Color")
5
+
6
+ Spree::OptionValue.create!([
7
+ {
8
+ :name => "Small",
9
+ :presentation => "S",
10
+ :position => 1,
11
+ :option_type => size
12
+ },
13
+ {
14
+ :name => "Medium",
15
+ :presentation => "M",
16
+ :position => 2,
17
+ :option_type => size
18
+ },
19
+ {
20
+ :name => "Large",
21
+ :presentation => "L",
22
+ :position => 3,
23
+ :option_type => size
24
+ },
25
+ {
26
+ :name => "Extra Large",
27
+ :presentation => "XL",
28
+ :position => 4,
29
+ :option_type => size
30
+ },
31
+ {
32
+ :name => "Red",
33
+ :presentation => "Red",
34
+ :position => 1,
35
+ :option_type => color,
36
+ },
37
+ {
38
+ :name => "Green",
39
+ :presentation => "Green",
40
+ :position => 2,
41
+ :option_type => color,
42
+ },
43
+ {
44
+ :name => "Blue",
45
+ :presentation => "Blue",
46
+ :position => 3,
47
+ :option_type => color
48
+ }
49
+ ])
@@ -0,0 +1,39 @@
1
+ Spree::Sample.load_sample("addresses")
2
+
3
+ payment_method = Spree::PaymentMethod::Check.first!
4
+
5
+ orders = []
6
+ orders << Spree::Order.create!(
7
+ :number => "R123456789",
8
+ :email => "spree@example.com",
9
+ :item_total => 150.95,
10
+ :adjustment_total => 150.95,
11
+ :total => 301.90,
12
+ :shipping_address => Spree::Address.first,
13
+ :billing_address => Spree::Address.last)
14
+
15
+ orders << Spree::Order.create!(
16
+ :number => "R987654321",
17
+ :email => "spree@example.com",
18
+ :item_total => 15.95,
19
+ :adjustment_total => 15.95,
20
+ :total => 31.90,
21
+ :shipping_address => Spree::Address.first,
22
+ :billing_address => Spree::Address.last)
23
+
24
+ orders[0].line_items.create!(
25
+ :variant => Spree::Product.find_by_name!("Ruby on Rails Tote").master,
26
+ :quantity => 1,
27
+ :price => 15.99)
28
+
29
+ orders[1].line_items.create!(
30
+ :variant => Spree::Product.find_by_name!("Ruby on Rails Bag").master,
31
+ :quantity => 1,
32
+ :price => 22.99)
33
+
34
+ orders.each do |order|
35
+ order.payments.create!(payment_method: payment_method)
36
+
37
+ order.next! while !order.can_complete?
38
+ order.complete!
39
+ end
@@ -0,0 +1,43 @@
1
+ Spree::Gateway::Bogus.create!(
2
+ {
3
+ :name => "Credit Card",
4
+ :description => "Bogus payment gateway for development.",
5
+ :environment => "development",
6
+ :active => true
7
+ }
8
+ )
9
+
10
+ Spree::Gateway::Bogus.create!(
11
+ {
12
+ :name => "Credit Card",
13
+ :description => "Bogus payment gateway for production.",
14
+ :environment => "production",
15
+ :active => true
16
+ }
17
+ )
18
+
19
+ Spree::Gateway::Bogus.create!(
20
+ {
21
+ :name => "Credit Card",
22
+ :description => "Bogus payment gateway for staging.",
23
+ :environment => "staging",
24
+ :active => true
25
+ }
26
+ )
27
+
28
+ Spree::Gateway::Bogus.create!(
29
+ {
30
+ :name => "Credit Card",
31
+ :description => "Bogus payment gateway for test.",
32
+ :environment => "test",
33
+ :active => true
34
+ }
35
+ )
36
+
37
+ Spree::PaymentMethod::Check.create!(
38
+ {
39
+ :name => "Check",
40
+ :description => "Pay by check.",
41
+ :active => true
42
+ }
43
+ )
@@ -0,0 +1,22 @@
1
+ # create payments based on the totals since they can't be known in YAML (quantities are random)
2
+ method = Spree::PaymentMethod.where(:name => 'Credit Card', :active => true).first
3
+
4
+ # Hack the current method so we're able to return a gateway without a RAILS_ENV
5
+ Spree::Gateway.class_eval do
6
+ def self.current
7
+ Spree::Gateway::Bogus.new
8
+ end
9
+ end
10
+
11
+ # This table was previously called spree_creditcards, and older migrations
12
+ # reference it as such. Make it explicit here that this table has been renamed.
13
+ Spree::CreditCard.table_name = 'spree_credit_cards'
14
+
15
+ creditcard = Spree::CreditCard.create(:cc_type => 'visa', :month => 12, :year => 2.years.from_now.year, :last_digits => '1111',
16
+ :name => 'Sean Schofield', :gateway_customer_profile_id => 'BGS-1234')
17
+
18
+ Spree::Order.all.each_with_index do |order, index|
19
+ order.update!
20
+ payment = order.payments.create!(:amount => order.total, :source => creditcard.clone, :payment_method => method)
21
+ payment.update_columns(:state => 'pending', :response_code => '12345')
22
+ end
@@ -0,0 +1,9 @@
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
+
@@ -0,0 +1,65 @@
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
+ }
59
+
60
+ products.each do |name, properties|
61
+ product = Spree::Product.find_by_name(name)
62
+ properties.each do |prop_name, prop_value|
63
+ product.set_property(prop_name, prop_value)
64
+ end
65
+ end
@@ -0,0 +1,90 @@
1
+ Spree::Sample.load_sample("tax_categories")
2
+ Spree::Sample.load_sample("shipping_categories")
3
+
4
+ tax_category = Spree::TaxCategory.find_by_name!("Default")
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 => tax_category,
16
+ :shipping_category => shipping_category,
17
+ :price => 15.99,
18
+ :eur_price => 14,
19
+ },
20
+ {
21
+ :name => "Ruby on Rails Bag",
22
+ :tax_category => tax_category,
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 => tax_category,
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 => tax_category,
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 => tax_category,
46
+ :price => 19.99,
47
+ :eur_price => 16
48
+ },
49
+ {
50
+ :name => "Ruby Baseball Jersey",
51
+ :tax_category => tax_category,
52
+ :shipping_category => shipping_category,
53
+ :price => 19.99,
54
+ :eur_price => 16
55
+ },
56
+ {
57
+ :name => "Apache Baseball Jersey",
58
+ :tax_category => tax_category,
59
+ :shipping_category => shipping_category,
60
+ :price => 19.99,
61
+ :eur_price => 16
62
+ },
63
+ {
64
+ :name => "Ruby on Rails Mug",
65
+ :shipping_category => shipping_category,
66
+ :price => 13.99,
67
+ :eur_price => 12
68
+ },
69
+ {
70
+ :name => "Ruby on Rails Stein",
71
+ :shipping_category => shipping_category,
72
+ :price => 16.99,
73
+ :eur_price => 14
74
+ }
75
+ ]
76
+
77
+ products.each do |product_attrs|
78
+ eur_price = product_attrs.delete(:eur_price)
79
+ Spree::Config[:currency] = "USD"
80
+
81
+ default_shipping_category = Spree::ShippingCategory.find_by_name!("Default")
82
+ product = Spree::Product.create!(default_attrs.merge(product_attrs))
83
+ Spree::Config[:currency] = "EUR"
84
+ product.reload
85
+ product.price = eur_price
86
+ product.shipping_category = default_shipping_category
87
+ product.save!
88
+ end
89
+
90
+ 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.find_by_name!(property)
20
+ end
21
+ end
@@ -0,0 +1 @@
1
+ Spree::ShippingCategory.find_or_create_by!(:name => "Default")
@@ -0,0 +1,66 @@
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
+ tax_category = Spree::TaxCategory.find_by_name!("Default")
10
+ europe_vat = Spree::Zone.find_by_name!("EU_VAT")
11
+ shipping_category = Spree::ShippingCategory.find_or_create_by!(name: 'Default')
12
+
13
+ Spree::ShippingMethod.create!([
14
+ {
15
+ :name => "UPS Ground (USD)",
16
+ :zones => [north_america],
17
+ :calculator => Spree::Calculator::Shipping::FlatRate.create!,
18
+ :tax_category => tax_category,
19
+ :shipping_categories => [shipping_category]
20
+ },
21
+ {
22
+ :name => "UPS Two Day (USD)",
23
+ :zones => [north_america],
24
+ :calculator => Spree::Calculator::Shipping::FlatRate.create!,
25
+ :tax_category => tax_category,
26
+ :shipping_categories => [shipping_category]
27
+ },
28
+ {
29
+ :name => "UPS One Day (USD)",
30
+ :zones => [north_america],
31
+ :calculator => Spree::Calculator::Shipping::FlatRate.create!,
32
+ :tax_category => tax_category,
33
+ :shipping_categories => [shipping_category]
34
+ },
35
+ {
36
+ :name => "UPS Ground (EU)",
37
+ :zones => [europe_vat],
38
+ :calculator => Spree::Calculator::Shipping::FlatRate.create!,
39
+ :tax_category => tax_category,
40
+ :shipping_categories => [shipping_category]
41
+ },
42
+ {
43
+ :name => "UPS Ground (EUR)",
44
+ :zones => [europe_vat],
45
+ :calculator => Spree::Calculator::Shipping::FlatRate.create!,
46
+ :tax_category => tax_category,
47
+ :shipping_categories => [shipping_category]
48
+ }
49
+ ])
50
+
51
+ {
52
+ "UPS Ground (USD)" => [5, "USD"],
53
+ "UPS Ground (EU)" => [5, "USD"],
54
+ "UPS One Day (USD)" => [15, "USD"],
55
+ "UPS Two Day (USD)" => [10, "USD"],
56
+ "UPS Ground (EUR)" => [8, "EUR"]
57
+ }.each do |shipping_method_name, (price, currency)|
58
+ shipping_method = Spree::ShippingMethod.find_by_name!(shipping_method_name)
59
+ shipping_method.calculator.preferences = {
60
+ amount: price,
61
+ currency: currency
62
+ }
63
+ shipping_method.calculator.save!
64
+ shipping_method.save!
65
+ end
66
+
@@ -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::TaxCategory.create!(:name => "Default")
@@ -0,0 +1,9 @@
1
+ north_america = Spree::Zone.find_by_name!("North America")
2
+ clothing = Spree::TaxCategory.find_by_name!("Default")
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,117 @@
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
+ :apache_baseball_jersey => "Apache Baseball Jersey",
16
+ :ruby_baseball_jersey => "Ruby Baseball Jersey",
17
+ }
18
+
19
+
20
+ products.each do |key, name|
21
+ products[key] = Spree::Product.find_by_name!(name)
22
+ end
23
+
24
+ taxons = [
25
+ {
26
+ :name => "Categories",
27
+ :taxonomy => categories,
28
+ :position => 0
29
+ },
30
+ {
31
+ :name => "Bags",
32
+ :taxonomy => categories,
33
+ :parent => "Categories",
34
+ :position => 1,
35
+ :products => [
36
+ products[:ror_tote],
37
+ products[:ror_bag]
38
+ ]
39
+ },
40
+ {
41
+ :name => "Mugs",
42
+ :taxonomy => categories,
43
+ :parent => "Categories",
44
+ :position => 2,
45
+ :products => [
46
+ products[:ror_mug],
47
+ products[:ror_stein]
48
+ ]
49
+ },
50
+ {
51
+ :name => "Clothing",
52
+ :taxonomy => categories,
53
+ :parent => "Categories"
54
+ },
55
+ {
56
+ :name => "Shirts",
57
+ :taxonomy => categories,
58
+ :parent => "Clothing",
59
+ :position => 0,
60
+ :products => [
61
+ products[:ror_jr_spaghetti],
62
+ ]
63
+ },
64
+ {
65
+ :name => "T-Shirts",
66
+ :taxonomy => categories,
67
+ :parent => "Clothing" ,
68
+ :products => [
69
+ products[:ror_baseball_jersey],
70
+ products[:ror_ringer],
71
+ products[:apache_baseball_jersey],
72
+ products[:ruby_baseball_jersey]
73
+ ],
74
+ :position => 0
75
+ },
76
+ {
77
+ :name => "Brands",
78
+ :taxonomy => brands
79
+ },
80
+ {
81
+ :name => "Ruby",
82
+ :taxonomy => brands,
83
+ :parent => "Brand",
84
+ :products => [
85
+ products[:ruby_baseball_jersey]
86
+ ]
87
+ },
88
+ {
89
+ :name => "Apache",
90
+ :taxonomy => brands,
91
+ :parent => "Brand",
92
+ :products => [
93
+ products[:apache_baseball_jersey]
94
+ ]
95
+ },
96
+ {
97
+ :name => "Rails",
98
+ :taxonomy => brands,
99
+ :parent => "Brand",
100
+ :products => [
101
+ products[:ror_tote],
102
+ products[:ror_bag],
103
+ products[:ror_mug],
104
+ products[:ror_stein],
105
+ products[:ror_baseball_jersey],
106
+ products[:ror_jr_spaghetti],
107
+ products[:ror_ringer],
108
+ ]
109
+ },
110
+ ]
111
+
112
+ taxons.each do |taxon_attrs|
113
+ if taxon_attrs[:parent]
114
+ taxon_attrs[:parent] = Spree::Taxon.find_by_name!(taxon_attrs[:parent])
115
+ Spree::Taxon.create!(taxon_attrs)
116
+ end
117
+ end
@@ -0,0 +1,129 @@
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
+ ruby_baseball_jersey = Spree::Product.find_by_name!("Ruby Baseball Jersey")
12
+ apache_baseball_jersey = Spree::Product.find_by_name!("Apache Baseball Jersey")
13
+
14
+ small = Spree::OptionValue.find_by_name!("Small")
15
+ medium = Spree::OptionValue.find_by_name!("Medium")
16
+ large = Spree::OptionValue.find_by_name!("Large")
17
+ extra_large = Spree::OptionValue.find_by_name!("Extra Large")
18
+
19
+ red = Spree::OptionValue.find_by_name!("Red")
20
+ blue = Spree::OptionValue.find_by_name!("Blue")
21
+ green = Spree::OptionValue.find_by_name!("Green")
22
+
23
+ variants = [
24
+ {
25
+ :product => ror_baseball_jersey,
26
+ :option_values => [small, red],
27
+ :sku => "ROR-00001",
28
+ :cost_price => 17
29
+ },
30
+ {
31
+ :product => ror_baseball_jersey,
32
+ :option_values => [small, blue],
33
+ :sku => "ROR-00002",
34
+ :cost_price => 17
35
+ },
36
+ {
37
+ :product => ror_baseball_jersey,
38
+ :option_values => [small, green],
39
+ :sku => "ROR-00003",
40
+ :cost_price => 17
41
+ },
42
+ {
43
+ :product => ror_baseball_jersey,
44
+ :option_values => [medium, red],
45
+ :sku => "ROR-00004",
46
+ :cost_price => 17
47
+ },
48
+ {
49
+ :product => ror_baseball_jersey,
50
+ :option_values => [medium, blue],
51
+ :sku => "ROR-00005",
52
+ :cost_price => 17
53
+ },
54
+ {
55
+ :product => ror_baseball_jersey,
56
+ :option_values => [medium, green],
57
+ :sku => "ROR-00006",
58
+ :cost_price => 17
59
+ },
60
+ {
61
+ :product => ror_baseball_jersey,
62
+ :option_values => [large, red],
63
+ :sku => "ROR-00007",
64
+ :cost_price => 17
65
+ },
66
+ {
67
+ :product => ror_baseball_jersey,
68
+ :option_values => [large, blue],
69
+ :sku => "ROR-00008",
70
+ :cost_price => 17
71
+ },
72
+ {
73
+ :product => ror_baseball_jersey,
74
+ :option_values => [large, green],
75
+ :sku => "ROR-00009",
76
+ :cost_price => 17
77
+ },
78
+ {
79
+ :product => ror_baseball_jersey,
80
+ :option_values => [extra_large, green],
81
+ :sku => "ROR-00010",
82
+ :cost_price => 17
83
+ },
84
+ ]
85
+
86
+ masters = {
87
+ ror_baseball_jersey => {
88
+ :sku => "ROR-001",
89
+ :cost_price => 17,
90
+ },
91
+ ror_tote => {
92
+ :sku => "ROR-00011",
93
+ :cost_price => 17
94
+ },
95
+ ror_bag => {
96
+ :sku => "ROR-00012",
97
+ :cost_price => 21
98
+ },
99
+ ror_jr_spaghetti => {
100
+ :sku => "ROR-00013",
101
+ :cost_price => 17
102
+ },
103
+ ror_mug => {
104
+ :sku => "ROR-00014",
105
+ :cost_price => 11
106
+ },
107
+ ror_ringer => {
108
+ :sku => "ROR-00015",
109
+ :cost_price => 17
110
+ },
111
+ ror_stein => {
112
+ :sku => "ROR-00016",
113
+ :cost_price => 15
114
+ },
115
+ apache_baseball_jersey => {
116
+ :sku => "APC-00001",
117
+ :cost_price => 17
118
+ },
119
+ ruby_baseball_jersey => {
120
+ :sku => "RUB-00001",
121
+ :cost_price => 17
122
+ }
123
+ }
124
+
125
+ Spree::Variant.create!(variants)
126
+
127
+ masters.each do |product, variant_attrs|
128
+ product.master.update_attributes!(variant_attrs)
129
+ 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 @@
1
+ require 'spree_sample'
@@ -0,0 +1,24 @@
1
+ require 'spree_core'
2
+ module Spree
3
+ module Sample
4
+ def self.load_sample(file)
5
+ # If file is exists within application it takes precendence.
6
+ if File.exists?(File.join(Rails.root, 'db', 'samples', "#{file}.rb"))
7
+ path = File.expand_path(File.join(Rails.root, 'db', 'samples', "#{file}.rb"))
8
+ else
9
+ # Otherwise we will use this gems default file.
10
+ path = File.expand_path(samples_path + "#{file}.rb")
11
+ end
12
+ # Check to see if the specified file has been loaded before
13
+ if !$LOADED_FEATURES.include?(path)
14
+ require path
15
+ puts "Loaded #{file.titleize} samples"
16
+ end
17
+ end
18
+
19
+ private
20
+ def self.samples_path
21
+ Pathname.new(File.join(File.dirname(__FILE__), '..', '..', 'db', 'samples'))
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,30 @@
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("tax_categories")
12
+ Spree::Sample.load_sample("tax_rates")
13
+ Spree::Sample.load_sample("shipping_categories")
14
+ Spree::Sample.load_sample("shipping_methods")
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("payments")
28
+ end
29
+ end
30
+ 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
+
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: solidus_sample
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.pre
5
+ platform: ruby
6
+ authors:
7
+ - Solidus Team
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: solidus_core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0.pre
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0.pre
27
+ description: Required dependency for Spree
28
+ email: contact@solidus.io
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - LICENSE
34
+ - db/samples.rb
35
+ - db/samples/addresses.rb
36
+ - db/samples/assets.rb
37
+ - db/samples/images/apache_baseball.png
38
+ - db/samples/images/ror_bag.jpeg
39
+ - db/samples/images/ror_baseball.jpeg
40
+ - db/samples/images/ror_baseball_back.jpeg
41
+ - db/samples/images/ror_baseball_jersey_back_blue.png
42
+ - db/samples/images/ror_baseball_jersey_back_green.png
43
+ - db/samples/images/ror_baseball_jersey_back_red.png
44
+ - db/samples/images/ror_baseball_jersey_blue.png
45
+ - db/samples/images/ror_baseball_jersey_green.png
46
+ - db/samples/images/ror_baseball_jersey_red.png
47
+ - db/samples/images/ror_jr_spaghetti.jpeg
48
+ - db/samples/images/ror_mug.jpeg
49
+ - db/samples/images/ror_mug_back.jpeg
50
+ - db/samples/images/ror_ringer.jpeg
51
+ - db/samples/images/ror_ringer_back.jpeg
52
+ - db/samples/images/ror_stein.jpeg
53
+ - db/samples/images/ror_stein_back.jpeg
54
+ - db/samples/images/ror_tote.jpeg
55
+ - db/samples/images/ror_tote_back.jpeg
56
+ - db/samples/images/ruby_baseball.png
57
+ - db/samples/option_types.rb
58
+ - db/samples/option_values.rb
59
+ - db/samples/orders.rb
60
+ - db/samples/payment_methods.rb
61
+ - db/samples/payments.rb
62
+ - db/samples/product_option_types.rb
63
+ - db/samples/product_properties.rb
64
+ - db/samples/products.rb
65
+ - db/samples/prototypes.rb
66
+ - db/samples/shipping_categories.rb
67
+ - db/samples/shipping_methods.rb
68
+ - db/samples/stock.rb
69
+ - db/samples/tax_categories.rb
70
+ - db/samples/tax_rates.rb
71
+ - db/samples/taxonomies.rb
72
+ - db/samples/taxons.rb
73
+ - db/samples/variants.rb
74
+ - lib/solidus_sample.rb
75
+ - lib/spree/sample.rb
76
+ - lib/spree_sample.rb
77
+ - lib/tasks/sample.rake
78
+ homepage: http://solidus.io/
79
+ licenses:
80
+ - BSD-3
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 2.1.0
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">"
94
+ - !ruby/object:Gem::Version
95
+ version: 1.3.1
96
+ requirements:
97
+ - none
98
+ rubyforge_project:
99
+ rubygems_version: 2.2.0
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: Sample data (including images) for use with Spree.
103
+ test_files: []