Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fcaffed

Browse files
huoxitoJeff Dutil
authored andcommitted
Fix load_sample
Broke after 7a5e436 which requires product to have a shipping category Add build for spree/sample load data task
1 parent 13116d6 commit fcaffed

File tree

5 files changed

+60
-1
lines changed

5 files changed

+60
-1
lines changed

core/lib/spree/testing_support/common_rake.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,17 @@
3232
puts 'Skipping installation no generator to run...'
3333
end
3434
end
35+
36+
task :seed do |t, args|
37+
puts "Seeding ..."
38+
cmd = "bundle exec rake db:seed RAILS_ENV=test"
39+
40+
if RUBY_PLATFORM =~ /mswin/ #windows
41+
cmd += " >nul"
42+
else
43+
cmd += " >/dev/null"
44+
end
45+
46+
system(cmd)
47+
end
3548
end

sample/Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ desc "Generates a dummy app for testing"
2020
task :test_app do
2121
ENV['LIB_NAME'] = 'spree/core'
2222
Rake::Task['common:test_app'].invoke
23+
Rake::Task['common:seed'].invoke
2324
end
24-

sample/db/samples/products.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Spree::Sample.load_sample("tax_categories")
2+
Spree::Sample.load_sample("shipping_categories")
23

34
clothing = Spree::TaxCategory.find_by_name!("Clothing")
5+
shipping_category = Spree::ShippingCategory.find_by_name!("Default Shipping")
46

57
default_attrs = {
68
:description => Faker::Lorem.paragraph,
@@ -11,93 +13,109 @@
1113
{
1214
:name => "Ruby on Rails Tote",
1315
:tax_category => clothing,
16+
:shipping_category => shipping_category,
1417
:price => 15.99,
1518
:eur_price => 14,
1619
},
1720
{
1821
:name => "Ruby on Rails Bag",
1922
:tax_category => clothing,
23+
:shipping_category => shipping_category,
2024
:price => 22.99,
2125
:eur_price => 19,
2226
},
2327
{
2428
:name => "Ruby on Rails Baseball Jersey",
2529
:tax_category => clothing,
30+
:shipping_category => shipping_category,
2631
:price => 19.99,
2732
:eur_price => 16
2833
},
2934
{
3035
:name => "Ruby on Rails Jr. Spaghetti",
3136
:tax_category => clothing,
37+
:shipping_category => shipping_category,
3238
:price => 19.99,
3339
:eur_price => 16
3440

3541
},
3642
{
3743
:name => "Ruby on Rails Ringer T-Shirt",
44+
:shipping_category => shipping_category,
3845
:tax_category => clothing,
3946
:price => 19.99,
4047
:eur_price => 16
4148
},
4249
{
4350
:name => "Ruby Baseball Jersey",
4451
:tax_category => clothing,
52+
:shipping_category => shipping_category,
4553
:price => 19.99,
4654
:eur_price => 16
4755
},
4856
{
4957
:name => "Apache Baseball Jersey",
5058
:tax_category => clothing,
59+
:shipping_category => shipping_category,
5160
:price => 19.99,
5261
:eur_price => 16
5362
},
5463
{
5564
:name => "Spree Baseball Jersey",
5665
:tax_category => clothing,
66+
:shipping_category => shipping_category,
5767
:price => 19.99,
5868
:eur_price => 16
5969
},
6070
{
6171
:name => "Spree Jr. Spaghetti",
6272
:tax_category => clothing,
73+
:shipping_category => shipping_category,
6374
:price => 19.99,
6475
:eur_price => 16
6576
},
6677
{
6778
:name => "Spree Ringer T-Shirt",
6879
:tax_category => clothing,
80+
:shipping_category => shipping_category,
6981
:price => 19.99,
7082
:eur_price => 16
7183
},
7284
{
7385
:name => "Spree Tote",
7486
:tax_category => clothing,
87+
:shipping_category => shipping_category,
7588
:price => 15.99,
7689
:eur_price => 14,
7790
},
7891
{
7992
:name => "Spree Bag",
8093
:tax_category => clothing,
94+
:shipping_category => shipping_category,
8195
:price => 22.99,
8296
:eur_price => 19
8397
},
8498
{
8599
:name => "Ruby on Rails Mug",
100+
:shipping_category => shipping_category,
86101
:price => 13.99,
87102
:eur_price => 12
88103
},
89104
{
90105
:name => "Ruby on Rails Stein",
106+
:shipping_category => shipping_category,
91107
:price => 16.99,
92108
:eur_price => 14
93109
},
94110
{
95111
:name => "Spree Stein",
112+
:shipping_category => shipping_category,
96113
:price => 16.99,
97114
:eur_price => 14,
98115
},
99116
{
100117
:name => "Spree Mug",
118+
:shipping_category => shipping_category,
101119
:price => 13.99,
102120
:eur_price => 12
103121
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require 'spec_helper'
2+
3+
describe "Load samples" do
4+
it "doesn't raise any error" do
5+
expect {
6+
SpreeSample::Engine.load_samples
7+
}.to_not raise_error
8+
end
9+
end

sample/spec/spec_helper.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
2+
# from the project root directory.
3+
ENV["RAILS_ENV"] ||= 'test'
4+
require File.expand_path("../dummy/config/environment", __FILE__)
5+
require 'rspec/rails'
6+
require 'ffaker'
7+
8+
RSpec.configure do |config|
9+
config.color = true
10+
config.mock_with :rspec
11+
12+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
13+
# examples within a transaction, comment the following line or assign false
14+
# instead of true.
15+
config.use_transactional_fixtures = true
16+
17+
config.include FactoryGirl::Syntax::Methods
18+
config.fail_fast = ENV['FAIL_FAST'] || false
19+
end

0 commit comments

Comments
 (0)