solidus_sample_devise_token_auth 2.8.0.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +26 -0
  3. data/README.md +20 -0
  4. data/Rakefile +16 -0
  5. data/db/samples/addresses.rb +41 -0
  6. data/db/samples/assets.rb +107 -0
  7. data/db/samples/images/apache_baseball.png +0 -0
  8. data/db/samples/images/ror_bag.jpeg +0 -0
  9. data/db/samples/images/ror_baseball.jpeg +0 -0
  10. data/db/samples/images/ror_baseball_back.jpeg +0 -0
  11. data/db/samples/images/ror_baseball_jersey_back_blue.png +0 -0
  12. data/db/samples/images/ror_baseball_jersey_back_green.png +0 -0
  13. data/db/samples/images/ror_baseball_jersey_back_red.png +0 -0
  14. data/db/samples/images/ror_baseball_jersey_blue.png +0 -0
  15. data/db/samples/images/ror_baseball_jersey_green.png +0 -0
  16. data/db/samples/images/ror_baseball_jersey_red.png +0 -0
  17. data/db/samples/images/ror_jr_spaghetti.jpeg +0 -0
  18. data/db/samples/images/ror_mug.jpeg +0 -0
  19. data/db/samples/images/ror_mug_back.jpeg +0 -0
  20. data/db/samples/images/ror_ringer.jpeg +0 -0
  21. data/db/samples/images/ror_ringer_back.jpeg +0 -0
  22. data/db/samples/images/ror_stein.jpeg +0 -0
  23. data/db/samples/images/ror_stein_back.jpeg +0 -0
  24. data/db/samples/images/ror_tote.jpeg +0 -0
  25. data/db/samples/images/ror_tote_back.jpeg +0 -0
  26. data/db/samples/images/ruby_baseball.png +0 -0
  27. data/db/samples/option_types.rb +14 -0
  28. data/db/samples/option_values.rb +51 -0
  29. data/db/samples/orders.rb +48 -0
  30. data/db/samples/payment_methods.rb +17 -0
  31. data/db/samples/payments.rb +17 -0
  32. data/db/samples/product_option_types.rb +10 -0
  33. data/db/samples/product_properties.rb +67 -0
  34. data/db/samples/products.rb +100 -0
  35. data/db/samples/reimbursements.rb +23 -0
  36. data/db/samples/shipping_categories.rb +3 -0
  37. data/db/samples/shipping_methods.rb +67 -0
  38. data/db/samples/stock.rb +14 -0
  39. data/db/samples/stores.rb +10 -0
  40. data/db/samples/tax_categories.rb +3 -0
  41. data/db/samples/tax_rates.rb +15 -0
  42. data/db/samples/taxonomies.rb +10 -0
  43. data/db/samples/taxons.rb +118 -0
  44. data/db/samples/variants.rb +131 -0
  45. data/db/samples.rb +4 -0
  46. data/lib/solidus_sample.rb +3 -0
  47. data/lib/spree/sample.rb +29 -0
  48. data/lib/spree_sample.rb +32 -0
  49. data/lib/tasks/sample.rake +23 -0
  50. data/solidus_sample.gemspec +25 -0
  51. data/spec/lib/load_sample_spec.rb +12 -0
  52. data/spec/spec_helper.rb +41 -0
  53. metadata +111 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 850dd85549fa72baf0cecea78185d1a1a05c9caaca59edfbe81835561c8af462
4
+ data.tar.gz: 219944ee9881c3cfd242a3abfa57b45b725c1a09136d124db25f7a3d6443be45
5
+ SHA512:
6
+ metadata.gz: 5306cb0c49e8a688cbf7c41f33e727673bd29ef510d03b3c567264b4c2b5b553f6df1de27e418ee24d2638cfe869fc6adab0c77f8a30a3915bd96fd0907e072a
7
+ data.tar.gz: ebbbab5e925d92380950859700b0d87779929574edf6b32e15605a474e3a2cb94d36cd0040a05c51462e675a6de533ab48c3ef2be89d6912f2b41be6ea3e04f4
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.
data/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # solidus\_sample
2
+
3
+ Sample contains a set of test data which is used to generate the sandbox can be
4
+ used to test stores.
5
+
6
+ Applications including the `solidus_sample` gem are provided a rake task to
7
+ load the sample data:
8
+
9
+ ```bash
10
+ bundle exec rake spree_sample:load
11
+ ```
12
+
13
+
14
+ ## Testing
15
+
16
+ Run the tests:
17
+
18
+ ```bash
19
+ bundle exec rspec
20
+ ```
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+ require 'rspec/core/rake_task'
6
+ require 'spree/testing_support/dummy_app/rake_tasks'
7
+
8
+ RSpec::Core::RakeTask.new
9
+ task default: :spec
10
+
11
+ DummyApp::RakeTasks.new(
12
+ gem_root: File.expand_path(__dir__),
13
+ lib_name: 'solidus_sample'
14
+ )
15
+
16
+ task test_app: 'db:reset'
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ united_states = Spree::Country.find_by!(iso: "US")
4
+ new_york = Spree::State.find_by!(name: "New York")
5
+
6
+ first_names = ["Sterling", "Jennette", "Salome", "Lyla", "Lola", "Cheree",
7
+ "Hettie", "Barbie", "Amelia", "Marceline", "Keeley", "Mi",
8
+ "Karon", "Jessika", "Emmy"]
9
+ last_names = ["Torp", "Vandervort", "Stroman", "Lang", "Zulauf", "Bruen",
10
+ "Torp", "Gutmann", "Renner", "Bergstrom", "Sauer", "Gaylord",
11
+ "Mills", "Daugherty", "Stark"]
12
+ street_addresses = ["7377 Jacobi Passage", "4725 Serena Ridges",
13
+ "79832 Hamill Creek", "0746 Genoveva Villages",
14
+ "86717 D'Amore Hollow", "8529 Delena Well",
15
+ "959 Lockman Ferry", "67016 Murphy Fork",
16
+ "193 Larkin Divide", "80697 Cole Parks"]
17
+ secondary_addresses = ["Suite 918", "Suite 374", "Apt. 714", "Apt. 351",
18
+ "Suite 274", "Suite 240", "Suite 892", "Apt. 176",
19
+ "Apt. 986", "Apt. 583"]
20
+ cities = ["Lake Laurenceview", "Lucilefurt", "South Jannetteport",
21
+ "Leannonport", "Legrosburgh", "Willmsberg", "Karoleside",
22
+ "Lake German", "Keeblerfort", "Lemkehaven"]
23
+ phone_numbers = ["(392)859-7319 x670", "738-831-3210 x6047",
24
+ "(441)881-8127 x030", "1-744-701-0536 x30504",
25
+ "(992)432-8273 x97676", "482.249.0178 x532",
26
+ "(855)317-6523", "1-529-214-7315 x90865",
27
+ "(662)877-7894 x703", "689.578.8564 x72399"]
28
+
29
+ 2.times do
30
+ Spree::Address.create!(
31
+ firstname: first_names.sample,
32
+ lastname: last_names.sample,
33
+ address1: street_addresses.sample,
34
+ address2: secondary_addresses.sample,
35
+ city: cities.sample,
36
+ state: new_york,
37
+ zipcode: 16_804,
38
+ country: united_states,
39
+ phone: phone_numbers.sample
40
+ )
41
+ end
@@ -0,0 +1,107 @@
1
+ # frozen_string_literal: true
2
+
3
+ Spree::Sample.load_sample("products")
4
+ Spree::Sample.load_sample("variants")
5
+
6
+ products = {}
7
+ products[:ror_baseball_jersey] = Spree::Product.find_by!(name: "Ruby on Rails Baseball Jersey")
8
+ products[:ror_tote] = Spree::Product.find_by!(name: "Ruby on Rails Tote")
9
+ products[:ror_bag] = Spree::Product.find_by!(name: "Ruby on Rails Bag")
10
+ products[:ror_jr_spaghetti] = Spree::Product.find_by!(name: "Ruby on Rails Jr. Spaghetti")
11
+ products[:ror_mug] = Spree::Product.find_by!(name: "Ruby on Rails Mug")
12
+ products[:ror_ringer] = Spree::Product.find_by!(name: "Ruby on Rails Ringer T-Shirt")
13
+ products[:ror_stein] = Spree::Product.find_by!(name: "Ruby on Rails Stein")
14
+ products[:ruby_baseball_jersey] = Spree::Product.find_by!(name: "Ruby Baseball Jersey")
15
+ products[:apache_baseball_jersey] = Spree::Product.find_by!(name: "Apache Baseball Jersey")
16
+
17
+ def image(name, type = "jpeg")
18
+ images_path = Pathname.new(File.dirname(__FILE__)) + "images"
19
+ path = images_path + "#{name}.#{type}"
20
+ return false if !File.exist?(path)
21
+ path
22
+ end
23
+
24
+ images = {
25
+ products[:ror_tote].master => [
26
+ {
27
+ attachment: image("ror_tote")
28
+ },
29
+ {
30
+ attachment: image("ror_tote_back")
31
+ }
32
+ ],
33
+ products[:ror_bag].master => [
34
+ {
35
+ attachment: image("ror_bag")
36
+ }
37
+ ],
38
+ products[:ror_baseball_jersey].master => [
39
+ {
40
+ attachment: image("ror_baseball")
41
+ },
42
+ {
43
+ attachment: image("ror_baseball_back")
44
+ }
45
+ ],
46
+ products[:ror_jr_spaghetti].master => [
47
+ {
48
+ attachment: image("ror_jr_spaghetti")
49
+ }
50
+ ],
51
+ products[:ror_mug].master => [
52
+ {
53
+ attachment: image("ror_mug")
54
+ },
55
+ {
56
+ attachment: image("ror_mug_back")
57
+ }
58
+ ],
59
+ products[:ror_ringer].master => [
60
+ {
61
+ attachment: image("ror_ringer")
62
+ },
63
+ {
64
+ attachment: image("ror_ringer_back")
65
+ }
66
+ ],
67
+ products[:ror_stein].master => [
68
+ {
69
+ attachment: image("ror_stein")
70
+ },
71
+ {
72
+ attachment: image("ror_stein_back")
73
+ }
74
+ ],
75
+ products[:apache_baseball_jersey].master => [
76
+ {
77
+ attachment: image("apache_baseball", "png")
78
+ }
79
+ ],
80
+ products[:ruby_baseball_jersey].master => [
81
+ {
82
+ attachment: image("ruby_baseball", "png")
83
+ }
84
+ ]
85
+ }
86
+
87
+ products[:ror_baseball_jersey].variants.each do |variant|
88
+ color = variant.option_value("tshirt-color").downcase
89
+ main_image = image("ror_baseball_jersey_#{color}", "png")
90
+ File.open(main_image) do |f|
91
+ variant.images.create!(attachment: f)
92
+ end
93
+ back_image = image("ror_baseball_jersey_back_#{color}", "png")
94
+ next unless back_image
95
+ File.open(back_image) do |f|
96
+ variant.images.create!(attachment: f)
97
+ end
98
+ end
99
+
100
+ images.each do |variant, attachments|
101
+ puts "Loading images for #{variant.product.name}"
102
+ attachments.each do |attachment|
103
+ File.open(attachment[:attachment]) do |f|
104
+ variant.images.create!(attachment: f)
105
+ end
106
+ end
107
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ Spree::OptionType.create!([
4
+ {
5
+ name: "tshirt-size",
6
+ presentation: "Size",
7
+ position: 1
8
+ },
9
+ {
10
+ name: "tshirt-color",
11
+ presentation: "Color",
12
+ position: 2
13
+ }
14
+ ])
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ Spree::Sample.load_sample("option_types")
4
+
5
+ size = Spree::OptionType.find_by!(presentation: "Size")
6
+ color = Spree::OptionType.find_by!(presentation: "Color")
7
+
8
+ Spree::OptionValue.create!([
9
+ {
10
+ name: "Small",
11
+ presentation: "S",
12
+ position: 1,
13
+ option_type: size
14
+ },
15
+ {
16
+ name: "Medium",
17
+ presentation: "M",
18
+ position: 2,
19
+ option_type: size
20
+ },
21
+ {
22
+ name: "Large",
23
+ presentation: "L",
24
+ position: 3,
25
+ option_type: size
26
+ },
27
+ {
28
+ name: "Extra Large",
29
+ presentation: "XL",
30
+ position: 4,
31
+ option_type: size
32
+ },
33
+ {
34
+ name: "Red",
35
+ presentation: "Red",
36
+ position: 1,
37
+ option_type: color
38
+ },
39
+ {
40
+ name: "Green",
41
+ presentation: "Green",
42
+ position: 2,
43
+ option_type: color
44
+ },
45
+ {
46
+ name: "Blue",
47
+ presentation: "Blue",
48
+ position: 3,
49
+ option_type: color
50
+ }
51
+ ])
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ Spree::Sample.load_sample("addresses")
4
+ Spree::Sample.load_sample("stores")
5
+
6
+ payment_method = Spree::PaymentMethod::Check.first!
7
+ store = Spree::Store.first!
8
+
9
+ orders = []
10
+ orders << Spree::Order.create!(
11
+ number: "R123456789",
12
+ email: "spree@example.com",
13
+ item_total: 150.95,
14
+ adjustment_total: 150.95,
15
+ total: 301.90,
16
+ shipping_address: Spree::Address.first,
17
+ billing_address: Spree::Address.last
18
+ )
19
+
20
+ orders << Spree::Order.create!(
21
+ number: "R987654321",
22
+ email: "spree@example.com",
23
+ item_total: 15.95,
24
+ adjustment_total: 15.95,
25
+ total: 31.90,
26
+ shipping_address: Spree::Address.first,
27
+ billing_address: Spree::Address.last
28
+ )
29
+
30
+ orders[0].line_items.create!(
31
+ variant: Spree::Product.find_by!(name: "Ruby on Rails Tote").master,
32
+ quantity: 1,
33
+ price: 15.99
34
+ )
35
+
36
+ orders[1].line_items.create!(
37
+ variant: Spree::Product.find_by!(name: "Ruby on Rails Bag").master,
38
+ quantity: 1,
39
+ price: 22.99
40
+ )
41
+
42
+ orders.each do |order|
43
+ order.payments.create!(payment_method: payment_method)
44
+ order.update_attributes(store: store)
45
+
46
+ order.next! while !order.can_complete?
47
+ order.complete!
48
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ Spree::PaymentMethod::BogusCreditCard.create!(
4
+ {
5
+ name: "Credit Card",
6
+ description: "Bogus payment gateway",
7
+ active: true
8
+ }
9
+ )
10
+
11
+ Spree::PaymentMethod::Check.create!(
12
+ {
13
+ name: "Check",
14
+ description: "Pay by check.",
15
+ active: true
16
+ }
17
+ )
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ # create payments based on the totals since they can't be known in YAML (quantities are random)
4
+ method = Spree::PaymentMethod.where(name: 'Credit Card', active: true).first
5
+
6
+ # This table was previously called spree_creditcards, and older migrations
7
+ # reference it as such. Make it explicit here that this table has been renamed.
8
+ Spree::CreditCard.table_name = 'spree_credit_cards'
9
+
10
+ creditcard = Spree::CreditCard.create(cc_type: 'visa', month: 12, year: 2.years.from_now.year, last_digits: '1111',
11
+ name: 'Sean Schofield', gateway_customer_profile_id: 'BGS-1234')
12
+
13
+ Spree::Order.all.each_with_index do |order, _index|
14
+ order.recalculate
15
+ payment = order.payments.create!(amount: order.total, source: creditcard.clone, payment_method: method)
16
+ payment.update_columns(state: 'pending', response_code: '12345')
17
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ Spree::Sample.load_sample("products")
4
+
5
+ size = Spree::OptionType.find_by!(presentation: "Size")
6
+ color = Spree::OptionType.find_by!(presentation: "Color")
7
+
8
+ ror_baseball_jersey = Spree::Product.find_by!(name: "Ruby on Rails Baseball Jersey")
9
+ ror_baseball_jersey.option_types = [size, color]
10
+ ror_baseball_jersey.save!
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ products =
4
+ {
5
+ "Ruby on Rails Baseball Jersey" =>
6
+ {
7
+ "Manufacturer" => "Wilson",
8
+ "Brand" => "Wannabe Sports",
9
+ "Model" => "JK1002",
10
+ "Shirt Type" => "Baseball Jersey",
11
+ "Sleeve Type" => "Long",
12
+ "Made from" => "100% cotton",
13
+ "Fit" => "Loose",
14
+ "Gender" => "Men's"
15
+ },
16
+ "Ruby on Rails Jr. Spaghetti" =>
17
+ {
18
+ "Manufacturer" => "Jerseys",
19
+ "Brand" => "Resiliance",
20
+ "Model" => "TL174",
21
+ "Shirt Type" => "Jr. Spaghetti T",
22
+ "Sleeve Type" => "None",
23
+ "Made from" => "90% Cotton, 10% Nylon",
24
+ "Fit" => "Form",
25
+ "Gender" => "Women's"
26
+ },
27
+ "Ruby on Rails Ringer T-Shirt" =>
28
+ {
29
+ "Manufacturer" => "Jerseys",
30
+ "Brand" => "Conditioned",
31
+ "Model" => "TL9002",
32
+ "Shirt Type" => "Ringer T",
33
+ "Sleeve Type" => "Short",
34
+ "Made from" => "100% Vellum",
35
+ "Fit" => "Loose",
36
+ "Gender" => "Men's"
37
+ },
38
+ "Ruby on Rails Tote" =>
39
+ {
40
+ "Type" => "Tote",
41
+ "Size" => %{15" x 18" x 6"},
42
+ "Material" => "Canvas"
43
+ },
44
+ "Ruby on Rails Bag" =>
45
+ {
46
+ "Type" => "Messenger",
47
+ "Size" => %{14 1/2" x 12" x 5"},
48
+ "Material" => "600 Denier Polyester"
49
+ },
50
+ "Ruby on Rails Mug" =>
51
+ {
52
+ "Type" => "Mug",
53
+ "Size" => %{4.5" tall, 3.25" dia.}
54
+ },
55
+ "Ruby on Rails Stein" =>
56
+ {
57
+ "Type" => "Stein",
58
+ "Size" => %{6.75" tall, 3.75" dia. base, 3" dia. rim}
59
+ }
60
+ }
61
+
62
+ products.each do |name, properties|
63
+ product = Spree::Product.find_by(name: name)
64
+ properties.each do |prop_name, prop_value|
65
+ product.set_property(prop_name, prop_value)
66
+ end
67
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ Spree::Sample.load_sample("tax_categories")
4
+ Spree::Sample.load_sample("shipping_categories")
5
+
6
+ tax_category = Spree::TaxCategory.find_by!(name: "Default")
7
+ shipping_category = Spree::ShippingCategory.find_by!(name: "Default")
8
+
9
+ descriptions = [
10
+ "Occaecati repellendus soluta perspiciatis ea ea voluptatum alias. Dolorem possimus sunt ipsam eos aliquam voluptates. Voluptate est nemo ullam cumque ea ut molestiae iste.",
11
+ "Nisi dolor explicabo est fugiat alias. Asperiores sunt rerum quisquam perspiciatis quis doloremque. Autem est harum eum dolorem voluptas nihil. Nulla omnis voluptas sint cumque ad ut dignissimos reiciendis. Mollitia culpa iure libero labore nulla autem non eum.",
12
+ "Perferendis sed voluptatem error ipsam voluptatem esse ipsa incidunt. Doloremque quos ratione quia voluptas consequatur mollitia optio. Optio sed iure aut aliquid voluptatum facilis mollitia cum. Dignissimos in saepe consequatur et consequatur dolorem blanditiis.",
13
+ "Necessitatibus optio quod ullam itaque quis corporis occaecati. Saepe harum voluptates consectetur rerum dolorum. Corrupti officiis reprehenderit quo excepturi cumque. Soluta eos perspiciatis aut et ea nulla amet dolores. Dolores distinctio nesciunt libero voluptas molestiae consequatur aut veritatis.",
14
+ "Soluta sed error debitis repellendus et. Voluptates unde enim qui velit. Libero earum tenetur nulla similique temporibus quod repellendus quibusdam.",
15
+ "Recusandae animi deserunt provident dignissimos ullam harum alias et. Itaque dicta maxime consectetur ut nemo non voluptatem. Voluptatem ipsum ut culpa eaque dolores.",
16
+ ]
17
+
18
+ default_attrs = {
19
+ description: descriptions.sample,
20
+ available_on: Time.current
21
+ }
22
+
23
+ products = [
24
+ {
25
+ name: "Ruby on Rails Tote",
26
+ tax_category: tax_category,
27
+ shipping_category: shipping_category,
28
+ price: 15.99,
29
+ eur_price: 14
30
+ },
31
+ {
32
+ name: "Ruby on Rails Bag",
33
+ tax_category: tax_category,
34
+ shipping_category: shipping_category,
35
+ price: 22.99,
36
+ eur_price: 19
37
+ },
38
+ {
39
+ name: "Ruby on Rails Baseball Jersey",
40
+ tax_category: tax_category,
41
+ shipping_category: shipping_category,
42
+ price: 19.99,
43
+ eur_price: 16
44
+ },
45
+ {
46
+ name: "Ruby on Rails Jr. Spaghetti",
47
+ tax_category: tax_category,
48
+ shipping_category: shipping_category,
49
+ price: 19.99,
50
+ eur_price: 16
51
+
52
+ },
53
+ {
54
+ name: "Ruby on Rails Ringer T-Shirt",
55
+ shipping_category: shipping_category,
56
+ tax_category: tax_category,
57
+ price: 19.99,
58
+ eur_price: 16
59
+ },
60
+ {
61
+ name: "Ruby Baseball Jersey",
62
+ tax_category: tax_category,
63
+ shipping_category: shipping_category,
64
+ price: 19.99,
65
+ eur_price: 16
66
+ },
67
+ {
68
+ name: "Apache Baseball Jersey",
69
+ tax_category: tax_category,
70
+ shipping_category: shipping_category,
71
+ price: 19.99,
72
+ eur_price: 16
73
+ },
74
+ {
75
+ name: "Ruby on Rails Mug",
76
+ shipping_category: shipping_category,
77
+ price: 13.99,
78
+ eur_price: 12
79
+ },
80
+ {
81
+ name: "Ruby on Rails Stein",
82
+ shipping_category: shipping_category,
83
+ price: 16.99,
84
+ eur_price: 14
85
+ }
86
+ ]
87
+
88
+ products.each do |product_attrs|
89
+ eur_price = product_attrs.delete(:eur_price)
90
+ Spree::Config[:currency] = "USD"
91
+
92
+ product = Spree::Product.create!(default_attrs.merge(product_attrs))
93
+ Spree::Config[:currency] = "EUR"
94
+ product.reload
95
+ product.price = eur_price
96
+ product.shipping_category = shipping_category
97
+ product.save!
98
+ end
99
+
100
+ Spree::Config[:currency] = "USD"
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ Spree::Sample.load_sample("orders")
4
+
5
+ order = Spree::Order.last
6
+ inventory_unit = order.inventory_units.first
7
+ stock_location = inventory_unit.find_stock_item.stock_location
8
+
9
+ return_item = Spree::ReturnItem.create(inventory_unit: inventory_unit)
10
+
11
+ return_item.exchange_variant = return_item.eligible_exchange_variants.last
12
+ return_item.build_exchange_inventory_unit
13
+ return_item.accept!
14
+
15
+ customer_return = Spree::CustomerReturn.create(
16
+ stock_location: stock_location,
17
+ return_items: [return_item]
18
+ )
19
+
20
+ order.reimbursements.create(
21
+ customer_return: customer_return,
22
+ return_items: [return_item]
23
+ )
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ Spree::ShippingCategory.find_or_create_by!(name: "Default")