spree_core 3.3.6 → 3.4.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/spree/base_helper.rb +17 -18
- data/app/helpers/spree/products_helper.rb +5 -5
- data/app/models/concerns/spree/calculated_adjustments.rb +4 -3
- data/app/models/concerns/spree/default_price.rb +4 -5
- data/app/models/concerns/spree/display_money.rb +1 -1
- data/app/models/concerns/spree/named_type.rb +1 -1
- data/app/models/concerns/spree/ransackable_attributes.rb +5 -6
- data/app/models/concerns/spree/user_address.rb +6 -6
- data/app/models/concerns/spree/user_methods.rb +3 -3
- data/app/models/concerns/spree/user_payment_source.rb +4 -2
- data/app/models/concerns/spree/user_reporting.rb +1 -1
- data/app/models/spree/ability.rb +3 -3
- data/app/models/spree/address.rb +13 -9
- data/app/models/spree/adjustable/adjuster/promotion.rb +1 -1
- data/app/models/spree/adjustable/adjustments_updater.rb +2 -2
- data/app/models/spree/adjustable/promotion_accumulator.rb +6 -4
- data/app/models/spree/adjustment.rb +2 -3
- data/app/models/spree/app_configuration.rb +5 -6
- data/app/models/spree/base.rb +1 -1
- data/app/models/spree/calculator/default_tax.rb +4 -5
- data/app/models/spree/calculator/flat_percent_item_total.rb +1 -1
- data/app/models/spree/calculator/flat_rate.rb +3 -3
- data/app/models/spree/calculator/flexi_rate.rb +5 -5
- data/app/models/spree/calculator/price_sack.rb +9 -9
- data/app/models/spree/calculator/shipping/flat_percent_item_total.rb +1 -1
- data/app/models/spree/calculator/shipping/flat_rate.rb +3 -3
- data/app/models/spree/calculator/shipping/flexi_rate.rb +7 -7
- data/app/models/spree/calculator/shipping/per_item.rb +2 -2
- data/app/models/spree/calculator/shipping/price_sack.rb +4 -4
- data/app/models/spree/calculator/tiered_flat_rate.rb +3 -2
- data/app/models/spree/calculator/tiered_percent.rb +4 -3
- data/app/models/spree/calculator.rb +4 -4
- data/app/models/spree/classification.rb +2 -2
- data/app/models/spree/credit_card.rb +1 -1
- data/app/models/spree/exchange.rb +4 -5
- data/app/models/spree/gateway/bogus.rb +20 -20
- data/app/models/spree/gateway/bogus_simple.rb +2 -4
- data/app/models/spree/gateway.rb +4 -4
- data/app/models/spree/image.rb +3 -3
- data/app/models/spree/inventory_unit.rb +30 -30
- data/app/models/spree/line_item.rb +7 -9
- data/app/models/spree/option_type.rb +1 -1
- data/app/models/spree/order/checkout.rb +5 -5
- data/app/models/spree/order/currency_updater.rb +1 -4
- data/app/models/spree/order/payments.rb +4 -4
- data/app/models/spree/order/store_credit.rb +2 -2
- data/app/models/spree/order.rb +11 -29
- data/app/models/spree/order_contents.rb +6 -5
- data/app/models/spree/order_inventory.rb +3 -4
- data/app/models/spree/order_updater.rb +13 -14
- data/app/models/spree/payment/processing.rb +25 -26
- data/app/models/spree/payment.rb +72 -79
- data/app/models/spree/payment_capture_event.rb +1 -1
- data/app/models/spree/payment_method/check.rb +1 -1
- data/app/models/spree/payment_method/store_credit.rb +5 -5
- data/app/models/spree/payment_method.rb +7 -7
- data/app/models/spree/preferences/configuration.rb +6 -9
- data/app/models/spree/preferences/preferable.rb +11 -11
- data/app/models/spree/preferences/preferable_class_methods.rb +2 -3
- data/app/models/spree/preferences/scoped_store.rb +6 -5
- data/app/models/spree/preferences/store.rb +9 -14
- data/app/models/spree/price.rb +1 -1
- data/app/models/spree/product/scopes.rb +49 -49
- data/app/models/spree/product.rb +16 -16
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +2 -1
- data/app/models/spree/promotion/actions/free_shipping.rb +1 -1
- data/app/models/spree/promotion/rules/first_order.rb +7 -6
- data/app/models/spree/promotion/rules/item_total.rb +3 -5
- data/app/models/spree/promotion/rules/one_use_per_user.rb +1 -2
- data/app/models/spree/promotion/rules/option_value.rb +14 -6
- data/app/models/spree/promotion/rules/product.rb +4 -4
- data/app/models/spree/promotion/rules/taxon.rb +6 -6
- data/app/models/spree/promotion/rules/user.rb +3 -3
- data/app/models/spree/promotion/rules/user_logged_in.rb +1 -1
- data/app/models/spree/promotion.rb +15 -16
- data/app/models/spree/promotion_action.rb +1 -1
- data/app/models/spree/promotion_handler/cart.rb +3 -2
- data/app/models/spree/promotion_handler/free_shipping.rb +1 -3
- data/app/models/spree/promotion_handler/page.rb +3 -3
- data/app/models/spree/promotion_rule.rb +5 -4
- data/app/models/spree/refund.rb +8 -8
- data/app/models/spree/reimbursement/credit.rb +1 -1
- data/app/models/spree/reimbursement/reimbursement_type_engine.rb +1 -3
- data/app/models/spree/reimbursement.rb +4 -8
- data/app/models/spree/reimbursement_performer.rb +0 -5
- data/app/models/spree/reimbursement_tax_calculator.rb +5 -12
- data/app/models/spree/reimbursement_type.rb +2 -2
- data/app/models/spree/return_authorization.rb +22 -26
- data/app/models/spree/return_item/eligibility_validator/default.rb +3 -3
- data/app/models/spree/return_item/eligibility_validator/inventory_shipped.rb +2 -2
- data/app/models/spree/return_item/eligibility_validator/no_reimbursements.rb +2 -2
- data/app/models/spree/return_item/eligibility_validator/order_completed.rb +2 -2
- data/app/models/spree/return_item/eligibility_validator/rma_required.rb +2 -3
- data/app/models/spree/return_item/eligibility_validator/time_since_purchase.rb +2 -2
- data/app/models/spree/return_item.rb +15 -19
- data/app/models/spree/returns_calculator.rb +1 -2
- data/app/models/spree/shipment.rb +14 -35
- data/app/models/spree/shipment_handler.rb +10 -12
- data/app/models/spree/shipping_calculator.rb +5 -6
- data/app/models/spree/shipping_method.rb +3 -3
- data/app/models/spree/shipping_rate.rb +2 -2
- data/app/models/spree/state.rb +2 -2
- data/app/models/spree/stock/availability_validator.rb +1 -1
- data/app/models/spree/stock/content_item.rb +2 -3
- data/app/models/spree/stock/coordinator.rb +3 -2
- data/app/models/spree/stock/differentiator.rb +3 -2
- data/app/models/spree/stock/estimator.rb +7 -5
- data/app/models/spree/stock/package.rb +5 -5
- data/app/models/spree/stock/packer.rb +1 -1
- data/app/models/spree/stock/prioritizer.rb +5 -7
- data/app/models/spree/stock/quantifier.rb +0 -1
- data/app/models/spree/stock/splitter/backordered.rb +2 -4
- data/app/models/spree/stock/splitter/base.rb +3 -2
- data/app/models/spree/stock/splitter/shipping_category.rb +2 -1
- data/app/models/spree/stock_item.rb +1 -1
- data/app/models/spree/stock_location.rb +12 -11
- data/app/models/spree/stock_movement.rb +1 -3
- data/app/models/spree/stock_transfer.rb +1 -1
- data/app/models/spree/store.rb +4 -4
- data/app/models/spree/store_credit.rb +3 -3
- data/app/models/spree/tax_category.rb +1 -1
- data/app/models/spree/tax_rate.rb +10 -10
- data/app/models/spree/taxon.rb +13 -13
- data/app/models/spree/taxonomy.rb +9 -8
- data/app/models/spree/validations/db_maximum_length_validator.rb +2 -3
- data/app/models/spree/variant.rb +30 -41
- data/app/models/spree/zone.rb +10 -10
- data/app/validators/db_maximum_length_validator.rb +5 -5
- data/config/initializers/acts_as_taggable_on.rb +3 -3
- data/config/initializers/assets.rb +1 -1
- data/config/initializers/friendly_id.rb +1 -1
- data/config/initializers/premailer_assets.rb +1 -1
- data/config/locales/en.yml +8 -2
- data/db/default/spree/states.rb +1 -0
- data/lib/generators/spree/custom_user/custom_user_generator.rb +12 -15
- data/lib/generators/spree/install/install_generator.rb +45 -32
- data/lib/spree/core/components.rb +3 -3
- data/lib/spree/core/controller_helpers/auth.rb +5 -10
- data/lib/spree/core/controller_helpers/common.rb +2 -3
- data/lib/spree/core/controller_helpers/order.rb +3 -7
- data/lib/spree/core/controller_helpers/respond_with.rb +4 -4
- data/lib/spree/core/engine.rb +3 -3
- data/lib/spree/core/environment/calculators.rb +0 -1
- data/lib/spree/core/environment_extension.rb +8 -8
- data/lib/spree/core/importer/order.rb +64 -67
- data/lib/spree/core/importer/product.rb +10 -9
- data/lib/spree/core/product_filters.rb +17 -18
- data/lib/spree/core/routes.rb +2 -6
- data/lib/spree/core/search/base.rb +62 -59
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +4 -6
- data/lib/spree/i18n.rb +3 -5
- data/lib/spree/localized_number.rb +0 -2
- data/lib/spree/migrations.rb +8 -7
- data/lib/spree/money.rb +3 -7
- data/lib/spree/permitted_attributes.rb +2 -2
- data/lib/spree/responder.rb +4 -5
- data/lib/spree/testing_support/authorization_helpers.rb +3 -3
- data/lib/spree/testing_support/caching.rb +5 -5
- data/lib/spree/testing_support/capybara_ext.rb +16 -18
- data/lib/spree/testing_support/common_rake.rb +8 -9
- data/lib/spree/testing_support/controller_requests.rb +6 -6
- data/lib/spree/testing_support/extension_rake.rb +2 -3
- data/lib/spree/testing_support/factories/address_factory.rb +1 -1
- data/lib/spree/testing_support/factories/adjustment_factory.rb +1 -1
- data/lib/spree/testing_support/factories/calculator_factory.rb +1 -1
- data/lib/spree/testing_support/factories/country_factory.rb +1 -1
- data/lib/spree/testing_support/factories/credit_card_factory.rb +1 -1
- data/lib/spree/testing_support/factories/customer_return_factory.rb +1 -3
- data/lib/spree/testing_support/factories/image_factory.rb +2 -2
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +1 -1
- data/lib/spree/testing_support/factories/line_item_factory.rb +2 -2
- data/lib/spree/testing_support/factories/options_factory.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +1 -1
- data/lib/spree/testing_support/factories/payment_factory.rb +1 -1
- data/lib/spree/testing_support/factories/payment_method_factory.rb +4 -4
- data/lib/spree/testing_support/factories/price_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_option_type_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_property_factory.rb +1 -1
- data/lib/spree/testing_support/factories/promotion_category_factory.rb +1 -2
- data/lib/spree/testing_support/factories/promotion_factory.rb +1 -2
- data/lib/spree/testing_support/factories/promotion_rule_factory.rb +1 -1
- data/lib/spree/testing_support/factories/property_factory.rb +1 -1
- data/lib/spree/testing_support/factories/prototype_factory.rb +1 -1
- data/lib/spree/testing_support/factories/refund_factory.rb +1 -1
- data/lib/spree/testing_support/factories/reimbursement_factory.rb +2 -2
- data/lib/spree/testing_support/factories/reimbursement_type_factory.rb +1 -1
- data/lib/spree/testing_support/factories/return_authorization_factory.rb +1 -1
- data/lib/spree/testing_support/factories/return_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/role_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipment_factory.rb +2 -2
- data/lib/spree/testing_support/factories/shipping_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipping_method_factory.rb +3 -3
- data/lib/spree/testing_support/factories/state_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_location_factory.rb +2 -2
- data/lib/spree/testing_support/factories/stock_movement_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_category_factory.rb +2 -2
- data/lib/spree/testing_support/factories/store_credit_event_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_type_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_factory.rb +1 -1
- data/lib/spree/testing_support/factories/tag_factory.rb +1 -1
- data/lib/spree/testing_support/factories/tax_category_factory.rb +2 -2
- data/lib/spree/testing_support/factories/tax_rate_factory.rb +1 -1
- data/lib/spree/testing_support/factories/taxon_factory.rb +1 -1
- data/lib/spree/testing_support/factories/taxonomy_factory.rb +1 -1
- data/lib/spree/testing_support/factories/tracker_factory.rb +1 -1
- data/lib/spree/testing_support/factories/user_factory.rb +1 -1
- data/lib/spree/testing_support/factories/variant_factory.rb +1 -2
- data/lib/spree/testing_support/factories/zone_factory.rb +1 -1
- data/lib/spree/testing_support/factories/zone_member_factory.rb +1 -1
- data/lib/spree/testing_support/factories.rb +3 -3
- data/lib/spree/testing_support/flash.rb +1 -3
- data/lib/spree/testing_support/i18n.rb +5 -6
- data/lib/spree/testing_support/kernel.rb +1 -2
- data/lib/spree/testing_support/order_walkthrough.rb +12 -15
- data/lib/spree/testing_support/preferences.rb +0 -1
- data/lib/tasks/core.rake +47 -56
- data/lib/tasks/email.rake +2 -2
- data/lib/tasks/exchanges.rake +5 -5
- data/spree_core.gemspec +1 -1
- metadata +5 -9
- data/app/models/spree/calculator/percent_per_item.rb +0 -51
- data/config/initializers/premailer_rails.rb +0 -3
- data/lib/spree/core/delegate_belongs_to.rb +0 -99
- data/lib/spree/testing_support/microdata.rb +0 -192
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
FactoryGirl.define do
|
2
2
|
factory :stock_location, class: Spree::StockLocation do
|
3
3
|
name 'NY Warehouse'
|
4
4
|
address1 '1600 Pennsylvania Ave NW'
|
@@ -14,7 +14,7 @@ FactoryBot.define do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
factory :stock_location_with_items do
|
17
|
-
after(:create) do |stock_location,
|
17
|
+
after(:create) do |stock_location, _evaluator|
|
18
18
|
# variant will add itself to all stock_locations in an after_create
|
19
19
|
# creating a product will automatically create a master variant
|
20
20
|
product_1 = create(:product)
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'factory_girl'
|
2
2
|
|
3
3
|
Spree::Zone.class_eval do
|
4
4
|
def self.global
|
5
|
-
find_by(name: 'GlobalZone') ||
|
5
|
+
find_by(name: 'GlobalZone') || FactoryGirl.create(:global_zone)
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
@@ -10,7 +10,7 @@ Dir["#{File.dirname(__FILE__)}/factories/**"].each do |f|
|
|
10
10
|
load File.expand_path(f)
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
FactoryGirl.define do
|
14
14
|
sequence(:random_string) { FFaker::Lorem.sentence }
|
15
15
|
sequence(:random_description) { FFaker::Lorem.paragraphs(1 + Kernel.rand(5)).join("\n") }
|
16
16
|
sequence(:random_email) { FFaker::Internet.email }
|
@@ -11,7 +11,7 @@ module Spree
|
|
11
11
|
class << self
|
12
12
|
attr_accessor :used_translations, :missing_translation_messages,
|
13
13
|
:unused_translations, :unused_translation_messages
|
14
|
-
|
14
|
+
alias normal_t t
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.t(*args)
|
@@ -49,7 +49,7 @@ module Spree
|
|
49
49
|
self.used_translations ||= []
|
50
50
|
self.unused_translation_messages = []
|
51
51
|
self.unused_translations = []
|
52
|
-
|
52
|
+
load_translations(translations)
|
53
53
|
translation_diff = unused_translations - used_translations
|
54
54
|
translation_diff.each do |translation|
|
55
55
|
Spree.unused_translation_messages << "#{translation} (#{I18n.locale})"
|
@@ -58,13 +58,13 @@ module Spree
|
|
58
58
|
|
59
59
|
private
|
60
60
|
|
61
|
-
def self.load_translations(hash, root=[])
|
62
|
-
hash.each do |k,v|
|
61
|
+
def self.load_translations(hash, root = [])
|
62
|
+
hash.each do |k, v|
|
63
63
|
if v.is_a?(Hash)
|
64
64
|
load_translations(v, root.dup << k)
|
65
65
|
else
|
66
66
|
key = (root + [k]).join('.')
|
67
|
-
|
67
|
+
unused_translations << key
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
@@ -94,4 +94,3 @@ RSpec.configure do |config|
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
end
|
97
|
-
|
@@ -1,31 +1,29 @@
|
|
1
1
|
class OrderWalkthrough
|
2
2
|
def self.up_to(state)
|
3
3
|
# A default store must exist to provide store settings
|
4
|
-
unless Spree::Store.exists?
|
5
|
-
FactoryBot.create(:store)
|
6
|
-
end
|
4
|
+
FactoryGirl.create(:store) unless Spree::Store.exists?
|
7
5
|
|
8
6
|
# A payment method must exist for an order to proceed through the Address state
|
9
7
|
unless Spree::PaymentMethod.exists?
|
10
|
-
|
8
|
+
FactoryGirl.create(:check_payment_method)
|
11
9
|
end
|
12
10
|
|
13
11
|
# Need to create a valid zone too...
|
14
|
-
zone =
|
15
|
-
country =
|
12
|
+
zone = FactoryGirl.create(:zone)
|
13
|
+
country = FactoryGirl.create(:country)
|
16
14
|
zone.members << Spree::ZoneMember.create(zoneable: country)
|
17
|
-
country.states <<
|
15
|
+
country.states << FactoryGirl.create(:state, country: country)
|
18
16
|
|
19
17
|
# A shipping method must exist for rates to be displayed on checkout page
|
20
18
|
unless Spree::ShippingMethod.exists?
|
21
|
-
|
19
|
+
FactoryGirl.create(:shipping_method).tap do |sm|
|
22
20
|
sm.calculator.preferred_amount = 10
|
23
21
|
sm.calculator.preferred_currency = Spree::Config[:currency]
|
24
22
|
sm.calculator.save
|
25
23
|
end
|
26
24
|
end
|
27
25
|
|
28
|
-
order = Spree::Order.create!(email:
|
26
|
+
order = Spree::Order.create!(email: 'spree@example.com')
|
29
27
|
add_line_item!(order)
|
30
28
|
order.next!
|
31
29
|
|
@@ -40,13 +38,13 @@ class OrderWalkthrough
|
|
40
38
|
private
|
41
39
|
|
42
40
|
def self.add_line_item!(order)
|
43
|
-
|
41
|
+
FactoryGirl.create(:line_item, order: order)
|
44
42
|
order.reload
|
45
43
|
end
|
46
44
|
|
47
45
|
def self.address(order)
|
48
|
-
order.bill_address =
|
49
|
-
order.ship_address =
|
46
|
+
order.bill_address = FactoryGirl.create(:address, country_id: Spree::Zone.global.members.first.zoneable.id)
|
47
|
+
order.ship_address = FactoryGirl.create(:address, country_id: Spree::Zone.global.members.first.zoneable.id)
|
50
48
|
order.next!
|
51
49
|
end
|
52
50
|
|
@@ -61,12 +59,11 @@ class OrderWalkthrough
|
|
61
59
|
order.next!
|
62
60
|
end
|
63
61
|
|
64
|
-
def self.complete(
|
65
|
-
#noop?
|
62
|
+
def self.complete(_order)
|
63
|
+
# noop?
|
66
64
|
end
|
67
65
|
|
68
66
|
def self.states
|
69
67
|
[:address, :delivery, :payment, :complete]
|
70
68
|
end
|
71
|
-
|
72
69
|
end
|
data/lib/tasks/core.rake
CHANGED
@@ -4,86 +4,82 @@ namespace :db do
|
|
4
4
|
desc %q{Loads a specified fixture file:
|
5
5
|
use rake db:load_file[/absolute/path/to/sample/filename.rb]}
|
6
6
|
|
7
|
-
task :load_file
|
7
|
+
task :load_file, [:file, :dir] => :environment do |_t, args|
|
8
8
|
file = Pathname.new(args.file)
|
9
9
|
|
10
10
|
puts "loading ruby #{file}"
|
11
11
|
require file
|
12
12
|
end
|
13
13
|
|
14
|
-
desc
|
15
|
-
task :load_dir
|
14
|
+
desc 'Loads fixtures from the the dir you specify using rake db:load_dir[loadfrom]'
|
15
|
+
task :load_dir, [:dir] => :environment do |_t, args|
|
16
16
|
dir = args.dir
|
17
|
-
dir = File.join(Rails.root,
|
17
|
+
dir = File.join(Rails.root, 'db', dir) if Pathname.new(dir).relative?
|
18
18
|
|
19
19
|
ruby_files = {}
|
20
|
-
Dir.glob(File.join(dir
|
20
|
+
Dir.glob(File.join(dir, '**/*.{rb}')).each do |fixture_file|
|
21
21
|
ext = File.extname fixture_file
|
22
22
|
ruby_files[File.basename(fixture_file, '.*')] = fixture_file
|
23
23
|
end
|
24
|
-
ruby_files.sort.each do |fixture
|
24
|
+
ruby_files.sort.each do |fixture, ruby_file|
|
25
25
|
# If file exists within application it takes precendence.
|
26
|
-
if File.
|
27
|
-
ruby_file = File.expand_path(File.join(Rails.root,
|
26
|
+
if File.exist?(File.join(Rails.root, 'db/default/spree', "#{fixture}.rb"))
|
27
|
+
ruby_file = File.expand_path(File.join(Rails.root, 'db/default/spree', "#{fixture}.rb"))
|
28
28
|
end
|
29
29
|
# an invoke will only execute the task once
|
30
|
-
Rake::Task[
|
30
|
+
Rake::Task['db:load_file'].execute(Rake::TaskArguments.new([:file], [ruby_file]))
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
desc
|
34
|
+
desc 'Migrate schema to version 0 and back up again. WARNING: Destroys all data in tables!!'
|
35
35
|
task remigrate: :environment do
|
36
36
|
require 'highline/import'
|
37
37
|
|
38
|
-
if ENV['SKIP_NAG']
|
38
|
+
if ENV['SKIP_NAG'] || ENV['OVERWRITE'].to_s.casecmp('true').zero? || agree("This task will destroy any data in the database. Are you sure you want to \ncontinue? [y/n] ")
|
39
39
|
|
40
40
|
# Drop all tables
|
41
41
|
ActiveRecord::Base.connection.tables.each { |t| ActiveRecord::Base.connection.drop_table t }
|
42
42
|
|
43
43
|
# Migrate upward
|
44
|
-
Rake::Task[
|
44
|
+
Rake::Task['db:migrate'].invoke
|
45
45
|
|
46
46
|
# Dump the schema
|
47
|
-
Rake::Task[
|
47
|
+
Rake::Task['db:schema:dump'].invoke
|
48
48
|
else
|
49
|
-
say
|
49
|
+
say 'Task cancelled.'
|
50
50
|
exit
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
desc
|
55
|
-
task :bootstrap
|
54
|
+
desc 'Bootstrap is: migrating, loading defaults, sample data and seeding (for all extensions) and load_products tasks'
|
55
|
+
task :bootstrap do
|
56
56
|
require 'highline/import'
|
57
57
|
|
58
58
|
# remigrate unless production mode (as saftey check)
|
59
59
|
if %w[demo development test].include? Rails.env
|
60
|
-
if ENV['AUTO_ACCEPT']
|
60
|
+
if ENV['AUTO_ACCEPT'] || agree("This task will destroy any data in the database. Are you sure you want to \ncontinue? [y/n] ")
|
61
61
|
ENV['SKIP_NAG'] = 'yes'
|
62
|
-
Rake::Task[
|
63
|
-
Rake::Task[
|
62
|
+
Rake::Task['db:create'].invoke
|
63
|
+
Rake::Task['db:remigrate'].invoke
|
64
64
|
else
|
65
|
-
say
|
65
|
+
say 'Task cancelled, exiting.'
|
66
66
|
exit
|
67
67
|
end
|
68
68
|
else
|
69
|
-
say
|
70
|
-
Rake::Task[
|
69
|
+
say 'NOTE: Bootstrap in production mode will not drop database before migration'
|
70
|
+
Rake::Task['db:migrate'].invoke
|
71
71
|
end
|
72
72
|
|
73
|
-
ActiveRecord::Base.send(:subclasses).each
|
74
|
-
model.reset_column_information
|
75
|
-
end
|
73
|
+
ActiveRecord::Base.send(:subclasses).each(&:reset_column_information)
|
76
74
|
|
77
|
-
load_defaults
|
78
|
-
unless load_defaults
|
75
|
+
load_defaults = Spree::Country.count == 0
|
76
|
+
unless load_defaults # ask if there are already Countries => default data hass been loaded
|
79
77
|
load_defaults = agree('Countries present, load sample data anyways? [y/n]: ')
|
80
78
|
end
|
81
|
-
if load_defaults
|
82
|
-
Rake::Task["db:seed"].invoke
|
83
|
-
end
|
79
|
+
Rake::Task['db:seed'].invoke if load_defaults
|
84
80
|
|
85
|
-
if Rails.env.production?
|
86
|
-
load_sample = agree(
|
81
|
+
if Rails.env.production? && Spree::Product.count > 0
|
82
|
+
load_sample = agree('WARNING: In Production and products exist in database, load sample data anyways? [y/n]:')
|
87
83
|
else
|
88
84
|
load_sample = true if ENV['AUTO_ACCEPT']
|
89
85
|
load_sample = agree('Load Sample Data? [y/n]: ') unless load_sample
|
@@ -92,36 +88,34 @@ use rake db:load_file[/absolute/path/to/sample/filename.rb]}
|
|
92
88
|
if load_sample
|
93
89
|
# Reload models' attributes in case they were loaded in old migrations with wrong attributes
|
94
90
|
ActiveRecord::Base.descendants.each(&:reset_column_information)
|
95
|
-
Rake::Task[
|
91
|
+
Rake::Task['spree_sample:load'].invoke
|
96
92
|
end
|
97
93
|
|
98
94
|
puts "Bootstrap Complete.\n\n"
|
99
95
|
end
|
100
96
|
|
101
|
-
|
102
|
-
|
103
|
-
desc "Fix orphan line items after upgrading to Spree 3.1: only needed if you have line items attached to deleted records with Slug (product) and SKU (variant) duplicates of non-deleted records."
|
104
|
-
task fix_orphan_line_items: :environment do |t, args|
|
97
|
+
desc 'Fix orphan line items after upgrading to Spree 3.1: only needed if you have line items attached to deleted records with Slug (product) and SKU (variant) duplicates of non-deleted records.'
|
98
|
+
task fix_orphan_line_items: :environment do |_t, _args|
|
105
99
|
def get_input
|
106
100
|
STDOUT.flush
|
107
101
|
input = STDIN.gets.chomp
|
108
102
|
case input.upcase
|
109
|
-
|
110
|
-
|
103
|
+
when 'Y'
|
104
|
+
return true
|
111
105
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
106
|
+
when 'N'
|
107
|
+
puts 'aborting .....'
|
108
|
+
return false
|
109
|
+
else
|
110
|
+
return true
|
117
111
|
end
|
118
112
|
end
|
119
113
|
|
120
|
-
puts
|
121
|
-
puts
|
114
|
+
puts 'WARNING: This task will re-associate any line_items associated with deleted variants to non-deleted variants with matching SKUs. Because other attributes and product associations may switch during the re-association, this may have unintended side-effects. If this task finishes successfully, line items for old order should no longer be orphaned from their varaints. You should run this task after you have already run the db migratoin AddDiscontinuedToProductsAndVariants. If the db migration did not warn you that it was leaving deleted records in place because of duplicate SKUs, then you do not need to run this rake task.'
|
115
|
+
puts 'Are you sure you want to continue? (Y/n):'
|
122
116
|
|
123
117
|
if get_input
|
124
|
-
puts
|
118
|
+
puts 'looping through all your deleted variants ...'
|
125
119
|
|
126
120
|
# first verify that I can really fix all of your line items
|
127
121
|
|
@@ -130,9 +124,7 @@ use rake db:load_file[/absolute/path/to/sample/filename.rb]}
|
|
130
124
|
|
131
125
|
Spree::Variant.deleted.each do |variant|
|
132
126
|
# check if this variant has any line items at all
|
133
|
-
if
|
134
|
-
next
|
135
|
-
end
|
127
|
+
next if variant.line_items.none?
|
136
128
|
|
137
129
|
variants_to_fix << variant
|
138
130
|
dup_variant = Spree::Variant.find_by(sku: variant.sku)
|
@@ -143,8 +135,8 @@ use rake db:load_file[/absolute/path/to/sample/filename.rb]}
|
|
143
135
|
end
|
144
136
|
end
|
145
137
|
|
146
|
-
if
|
147
|
-
abort(
|
138
|
+
if variants_to_fix.none?
|
139
|
+
abort('ABORT: You have no deleted variants that are associated to line items. You do not need to run this raks task.')
|
148
140
|
end
|
149
141
|
|
150
142
|
if no_live_variants_found.any?
|
@@ -152,18 +144,17 @@ use rake db:load_file[/absolute/path/to/sample/filename.rb]}
|
|
152
144
|
no_live_variants_found.each do |deleted_variant|
|
153
145
|
puts "variant id #{deleted_variant.id} (sku is '#{deleted_variant.sku}') ... no match found"
|
154
146
|
end
|
155
|
-
abort
|
147
|
+
abort
|
156
148
|
end
|
157
149
|
|
158
|
-
|
159
|
-
puts "Ready to fix..."
|
150
|
+
puts 'Ready to fix...'
|
160
151
|
variants_to_fix.each do |variant|
|
161
152
|
dup_variant = Spree::Variant.find_by(sku: variant.sku)
|
162
153
|
puts "Changing all line items for #{variant.sku} variant id #{variant.id} (deleted) to variant id #{dup_variant.id} (not deleted) ..."
|
163
154
|
Spree::LineItem.unscoped.where(variant_id: variant.id).update_all(variant_id: dup_variant.id)
|
164
155
|
end
|
165
156
|
|
166
|
-
puts
|
157
|
+
puts 'DONE ! Your database should no longer have line items that are associated with deleted variants.'
|
167
158
|
end
|
168
159
|
end
|
169
160
|
end
|
data/lib/tasks/email.rake
CHANGED
@@ -2,8 +2,8 @@ namespace :email do
|
|
2
2
|
desc 'Sends test email to specified address - Example: EMAIL=spree@example.com bundle exec rake email:test'
|
3
3
|
task test: :environment do
|
4
4
|
unless ENV['EMAIL'].present?
|
5
|
-
raise ArgumentError,
|
6
|
-
|
5
|
+
raise ArgumentError, 'Must pass EMAIL environment variable. ' \
|
6
|
+
'Example: EMAIL=spree@example.com bundle exec rake email:test'
|
7
7
|
end
|
8
8
|
Spree::TestMailer.test_email(ENV['EMAIL']).deliver_now
|
9
9
|
end
|
data/lib/tasks/exchanges.rake
CHANGED
@@ -4,8 +4,8 @@ namespace :exchanges do
|
|
4
4
|
task charge_unreturned_items: :environment do
|
5
5
|
unreturned_return_items_scope = Spree::ReturnItem.awaiting_return.exchange_processed
|
6
6
|
unreturned_return_items = unreturned_return_items_scope.joins(:exchange_inventory_units).where([
|
7
|
-
|
8
|
-
days_ago: Spree::Config[:expedited_exchanges_days_window].days.ago, iu_state:
|
7
|
+
'spree_inventory_units.created_at < :days_ago AND spree_inventory_units.state = :iu_state',
|
8
|
+
days_ago: Spree::Config[:expedited_exchanges_days_window].days.ago, iu_state: 'shipped'
|
9
9
|
]).distinct.to_a
|
10
10
|
|
11
11
|
# Determine that a return item has already been deemed unreturned and therefore charged
|
@@ -49,7 +49,7 @@ namespace :exchanges do
|
|
49
49
|
# the original exchange shipment, not the built one
|
50
50
|
order.shipments.destroy_all
|
51
51
|
shipments.each { |shipment| shipment.update_attributes!(order_id: order.id) }
|
52
|
-
order.update_attributes!(state:
|
52
|
+
order.update_attributes!(state: 'confirm')
|
53
53
|
|
54
54
|
order.reload.next!
|
55
55
|
order.update_with_updater!
|
@@ -60,8 +60,8 @@ namespace :exchanges do
|
|
60
60
|
failed_orders << order
|
61
61
|
end
|
62
62
|
end
|
63
|
-
failure_message = failed_orders.map { |o| "#{o.number} - #{o.errors.full_messages}" }.join(
|
64
|
-
raise UnableToChargeForUnreturnedItems
|
63
|
+
failure_message = failed_orders.map { |o| "#{o.number} - #{o.errors.full_messages}" }.join(', ')
|
64
|
+
raise UnableToChargeForUnreturnedItems, failure_message if failed_orders.present?
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
data/spree_core.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.add_dependency 'highline', '~> 1.6.18' # Necessary for the install generator
|
32
32
|
s.add_dependency 'kaminari', '~> 1.0.1'
|
33
33
|
s.add_dependency 'monetize', '~> 1.1'
|
34
|
-
s.add_dependency 'paperclip', '~> 5.
|
34
|
+
s.add_dependency 'paperclip', '~> 5.1.0'
|
35
35
|
s.add_dependency 'paranoia', '~> 2.3.0'
|
36
36
|
s.add_dependency 'premailer-rails'
|
37
37
|
s.add_dependency 'acts-as-taggable-on', '~> 5.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 5.
|
173
|
+
version: 5.1.0
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 5.
|
180
|
+
version: 5.1.0
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: paranoia
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -386,7 +386,6 @@ files:
|
|
386
386
|
- app/models/spree/calculator/flat_rate.rb
|
387
387
|
- app/models/spree/calculator/flexi_rate.rb
|
388
388
|
- app/models/spree/calculator/percent_on_line_item.rb
|
389
|
-
- app/models/spree/calculator/percent_per_item.rb
|
390
389
|
- app/models/spree/calculator/price_sack.rb
|
391
390
|
- app/models/spree/calculator/returns/default_refund_amount.rb
|
392
391
|
- app/models/spree/calculator/shipping/flat_percent_item_total.rb
|
@@ -568,7 +567,6 @@ files:
|
|
568
567
|
- config/initializers/assets.rb
|
569
568
|
- config/initializers/friendly_id.rb
|
570
569
|
- config/initializers/premailer_assets.rb
|
571
|
-
- config/initializers/premailer_rails.rb
|
572
570
|
- config/locales/en.yml
|
573
571
|
- config/routes.rb
|
574
572
|
- db/default/spree/countries.rb
|
@@ -865,7 +863,6 @@ files:
|
|
865
863
|
- lib/spree/core/controller_helpers/search.rb
|
866
864
|
- lib/spree/core/controller_helpers/store.rb
|
867
865
|
- lib/spree/core/controller_helpers/strong_parameters.rb
|
868
|
-
- lib/spree/core/delegate_belongs_to.rb
|
869
866
|
- lib/spree/core/engine.rb
|
870
867
|
- lib/spree/core/environment.rb
|
871
868
|
- lib/spree/core/environment/calculators.rb
|
@@ -953,7 +950,6 @@ files:
|
|
953
950
|
- lib/spree/testing_support/flash.rb
|
954
951
|
- lib/spree/testing_support/i18n.rb
|
955
952
|
- lib/spree/testing_support/kernel.rb
|
956
|
-
- lib/spree/testing_support/microdata.rb
|
957
953
|
- lib/spree/testing_support/order_walkthrough.rb
|
958
954
|
- lib/spree/testing_support/preferences.rb
|
959
955
|
- lib/spree/testing_support/url_helpers.rb
|
@@ -986,7 +982,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
986
982
|
version: 1.8.23
|
987
983
|
requirements: []
|
988
984
|
rubyforge_project:
|
989
|
-
rubygems_version: 2.6.
|
985
|
+
rubygems_version: 2.6.12
|
990
986
|
signing_key:
|
991
987
|
specification_version: 4
|
992
988
|
summary: The bare bones necessary for Spree.
|