solidus_core 1.3.2 → 1.4.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/app/helpers/spree/base_helper.rb +6 -2
- data/app/mailers/spree/base_mailer.rb +1 -1
- data/app/mailers/spree/carton_mailer.rb +1 -1
- data/app/mailers/spree/order_mailer.rb +2 -2
- data/app/mailers/spree/reimbursement_mailer.rb +7 -7
- data/app/mailers/spree/test_mailer.rb +3 -2
- data/app/models/concerns/spree/user_payment_source.rb +1 -1
- data/app/models/spree/address.rb +14 -4
- data/app/models/spree/adjustment.rb +11 -19
- data/app/models/spree/app_configuration.rb +23 -1
- data/app/models/spree/base.rb +9 -0
- data/app/models/spree/country.rb +2 -2
- data/app/models/spree/exchange.rb +1 -1
- data/app/models/spree/gateway.rb +1 -1
- data/app/models/spree/item_adjustments.rb +7 -0
- data/app/models/spree/line_item.rb +1 -13
- data/app/models/spree/order/checkout.rb +19 -16
- data/app/models/spree/order/payments.rb +0 -2
- data/app/models/spree/order.rb +7 -21
- data/app/models/spree/order_contents.rb +60 -4
- data/app/models/spree/order_merger.rb +2 -4
- data/app/models/spree/order_shipping.rb +1 -1
- data/app/models/spree/order_update_attributes.rb +0 -2
- data/app/models/spree/order_updater.rb +14 -11
- data/app/models/spree/payment.rb +2 -3
- data/app/models/spree/payment_create.rb +5 -2
- data/app/models/spree/payment_method/store_credit.rb +6 -5
- data/app/models/spree/product/scopes.rb +2 -1
- data/app/models/spree/product.rb +2 -5
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +5 -3
- data/app/models/spree/promotion/actions/free_shipping.rb +1 -1
- data/app/models/spree/promotion/rules/option_value.rb +2 -3
- data/app/models/spree/promotion/rules/product.rb +9 -3
- data/app/models/spree/promotion/rules/taxon.rb +33 -7
- data/app/models/spree/promotion/rules/user.rb +2 -3
- data/app/models/spree/promotion.rb +16 -6
- data/app/models/spree/promotion_handler/coupon.rb +1 -1
- data/app/models/spree/shipment.rb +12 -16
- data/app/models/spree/stock/estimator.rb +1 -1
- data/app/models/spree/stock/package.rb +0 -1
- data/app/models/spree/stock_item.rb +2 -6
- data/app/models/spree/store.rb +2 -1
- data/app/models/spree/tax_rate.rb +1 -1
- data/app/models/spree/wallet/add_payment_sources_to_wallet.rb +29 -0
- data/app/models/spree/wallet/default_payment_builder.rb +26 -0
- data/app/views/spree/reimbursement_mailer/reimbursement_email.html.erb +46 -0
- data/app/views/spree/reimbursement_mailer/reimbursement_email.text.erb +1 -1
- data/app/views/spree/shared/_base_mailer_footer.html.erb +1 -20
- data/app/views/spree/shared/_base_mailer_header.html.erb +1 -31
- data/config/initializers/spree_user.rb +1 -1
- data/config/locales/en.yml +58 -34
- data/db/migrate/20130414000512_update_name_fields_on_spree_credit_cards.rb +1 -1
- data/db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb +15 -3
- data/db/migrate/20160527070401_rename_shipment_address_field.rb +7 -0
- data/db/migrate/20160616232103_remove_user_id_from_promotion_rules.rb +11 -0
- data/db/migrate/20160718205341_add_payment_id_index_to_spree_refunds.rb +5 -0
- data/db/migrate/20160718205859_add_reimbursement_id_index_to_spree_refunds.rb +5 -0
- data/lib/generators/spree/dummy/dummy_generator.rb +1 -1
- data/lib/generators/spree/dummy/templates/rails/database.yml +3 -1
- data/lib/generators/spree/dummy/templates/rails/test.rb +4 -2
- data/lib/generators/spree/install/install_generator.rb +6 -16
- data/lib/spree/core/controller_helpers/auth.rb +1 -1
- data/lib/spree/core/controller_helpers/common.rb +1 -1
- data/lib/spree/core/controller_helpers/order.rb +2 -2
- data/lib/spree/core/current_store.rb +5 -1
- data/lib/spree/core/delegate_belongs_to.rb +1 -1
- data/lib/spree/core/routes.rb +6 -32
- data/lib/spree/core/search/base.rb +2 -2
- data/lib/spree/core/stock_configuration.rb +6 -0
- data/lib/spree/core/version.rb +2 -2
- data/lib/spree/core.rb +2 -1
- data/lib/spree/i18n.rb +7 -0
- data/lib/spree/mailer_previews/carton_preview.rb +2 -1
- data/lib/spree/mailer_previews/order_preview.rb +8 -3
- data/lib/spree/mailer_previews/reimbursement_preview.rb +11 -0
- data/lib/spree/migrations.rb +13 -7
- data/lib/spree/permitted_attributes.rb +1 -1
- data/lib/spree/testing_support/capybara_ext.rb +6 -1
- data/lib/spree/testing_support/common_rake.rb +3 -7
- data/lib/spree/testing_support/controller_requests.rb +8 -0
- data/lib/spree/testing_support/factories/order_factory.rb +30 -8
- data/lib/spree/testing_support/factories/payment_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_factory.rb +6 -0
- data/lib/spree/testing_support/factories/reimbursement_factory.rb +1 -0
- data/lib/tasks/migrations/copy_shipped_shipments_to_cartons.rake +3 -1
- data/solidus_core.gemspec +3 -3
- data/spec/helpers/base_helper_spec.rb +18 -2
- data/spec/lib/i18n_spec.rb +4 -0
- data/spec/lib/spree/core/controller_helpers/order_spec.rb +16 -4
- data/spec/lib/spree/core/controller_helpers/payment_parameters_spec.rb +75 -59
- data/spec/lib/spree/core/delegate_belongs_to_spec.rb +1 -1
- data/spec/lib/spree/core/importer/order_spec.rb +4 -2
- data/spec/lib/spree/core/stock_configuration_spec.rb +17 -0
- data/spec/lib/spree/core/testing_support/factories/order_factory_spec.rb +195 -0
- data/spec/lib/spree/core/testing_support/factories/payment_factory_spec.rb +6 -0
- data/spec/lib/spree/core/testing_support/factories/reimbursement_factory_spec.rb +6 -0
- data/spec/lib/spree/migrations_spec.rb +3 -9
- data/spec/lib/tasks/migrations/copy_shipped_shipments_to_cartons_spec.rb +1 -1
- data/spec/mailers/carton_mailer_spec.rb +1 -1
- data/spec/mailers/order_mailer_spec.rb +2 -2
- data/spec/mailers/reimbursement_mailer_spec.rb +1 -1
- data/spec/models/spree/address_spec.rb +22 -0
- data/spec/models/spree/adjustment_spec.rb +0 -10
- data/spec/models/spree/carton_spec.rb +1 -1
- data/spec/models/spree/country_spec.rb +9 -1
- data/spec/models/spree/gateway/bogus_spec.rb +1 -1
- data/spec/models/spree/item_adjustments_spec.rb +33 -0
- data/spec/models/spree/line_item_spec.rb +2 -21
- data/spec/models/spree/order/checkout_spec.rb +32 -45
- data/spec/models/spree/order/payment_spec.rb +1 -16
- data/spec/models/spree/order_cancellations_spec.rb +8 -3
- data/spec/models/spree/order_contents_spec.rb +48 -0
- data/spec/models/spree/order_merger_spec.rb +8 -5
- data/spec/models/spree/order_shipping_spec.rb +3 -4
- data/spec/models/spree/order_spec.rb +23 -59
- data/spec/models/spree/order_update_attributes_spec.rb +1 -5
- data/spec/models/spree/order_updater_spec.rb +39 -11
- data/spec/models/spree/payment_create_spec.rb +61 -0
- data/spec/models/spree/payment_method/store_credit_spec.rb +23 -10
- data/spec/models/spree/payment_spec.rb +17 -4
- data/spec/models/spree/product_spec.rb +1 -1
- data/spec/models/spree/promotion/actions/create_item_adjustments_spec.rb +8 -13
- data/spec/models/spree/promotion/rules/product_spec.rb +33 -0
- data/spec/models/spree/promotion/rules/taxon_spec.rb +52 -8
- data/spec/models/spree/promotion_spec.rb +18 -12
- data/spec/models/spree/return_authorization_spec.rb +0 -16
- data/spec/models/spree/shipment_spec.rb +57 -36
- data/spec/models/spree/stock/coordinator_spec.rb +0 -5
- data/spec/models/spree/stock/package_spec.rb +0 -1
- data/spec/models/spree/stock_item_spec.rb +35 -145
- data/spec/models/spree/store_spec.rb +24 -10
- data/spec/models/spree/tax_rate_spec.rb +2 -2
- data/spec/models/spree/user_spec.rb +1 -1
- data/spec/models/spree/validations/db_maximum_length_validator_spec.rb +20 -12
- data/spec/support/concerns/working_factories.rb +4 -0
- metadata +30 -10
- data/config/routes.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8aa4c3e58ebb0c1418f96f55061e429329292ed3
|
4
|
+
data.tar.gz: 90e3439877e5e1632c288d009a442a05bce4631d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc8e9cba50b0b5eb46b7305513e28e395194d01f4b8304d1929eff3bf2db019d8f6b683691df073890aaf955946a3fdd7bf57d5e935c91c403f2dd68d9dd4488
|
7
|
+
data.tar.gz: 4b98fa39ceb46b0ccf5c85163bf1fc778f6641eafe8d2e99dd8a249b0657d5232ff74fc025593e3cb14c1ff40b430dc666896d666fd60e7733d404444eac2d05
|
data/README.md
ADDED
@@ -66,7 +66,7 @@ module Spree
|
|
66
66
|
nil
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
69
|
+
def taxon_breadcrumbs(taxon, separator = " » ", breadcrumb_class = "inline")
|
70
70
|
return "" if current_page?("/") || taxon.nil?
|
71
71
|
|
72
72
|
crumbs = [[Spree.t(:home), spree.root_path]]
|
@@ -153,6 +153,10 @@ module Spree
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
+
def plural_resource_name(resource_class)
|
157
|
+
resource_class.model_name.human(count: Spree::I18N_GENERIC_PLURAL)
|
158
|
+
end
|
159
|
+
|
156
160
|
private
|
157
161
|
|
158
162
|
# Returns style of image or nil
|
@@ -170,7 +174,7 @@ module Spree
|
|
170
174
|
|
171
175
|
def define_image_method(style)
|
172
176
|
self.class.send :define_method, "#{style}_image" do |product, *options|
|
173
|
-
|
177
|
+
Spree::Deprecation.warn "Spree image helpers will be deprecated in the near future. Use the provided resource to access the intendend image directly.", caller
|
174
178
|
options = options.first || {}
|
175
179
|
if product.images.empty?
|
176
180
|
if !product.is_a?(Spree::Variant) && !product.variant_images.empty?
|
@@ -4,7 +4,7 @@ module Spree
|
|
4
4
|
if store
|
5
5
|
store.mail_from_address
|
6
6
|
else
|
7
|
-
|
7
|
+
Spree::Deprecation.warn "A Spree::Store should be provided to determine the from address.", caller
|
8
8
|
Spree::Config[:mails_from]
|
9
9
|
end
|
10
10
|
end
|
@@ -15,7 +15,7 @@ module Spree
|
|
15
15
|
# def shipped_email(carton:, order:, resend: false)
|
16
16
|
def shipped_email(options, deprecated_options = {})
|
17
17
|
if options.is_a?(Integer)
|
18
|
-
|
18
|
+
Spree::Deprecation.warn "Calling shipped_email with a carton_id is DEPRECATED. Instead use CartonMailer.shipped_email(order: order, carton: carton)"
|
19
19
|
@carton = Carton.find(options)
|
20
20
|
@order = @carton.orders.first # assume first order
|
21
21
|
@manifest = @carton.manifest # use the entire manifest, since we don't know the precise order
|
@@ -30,14 +30,14 @@ module Spree
|
|
30
30
|
if order.respond_to?(:id)
|
31
31
|
order
|
32
32
|
else
|
33
|
-
|
33
|
+
Spree::Deprecation.warn("Calling OrderMailer with an id is deprecated. Pass the Spree::Order object instead.")
|
34
34
|
Spree::Order.find(order)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
def build_subject(subject_text, resend)
|
39
39
|
resend_text = (resend ? "[#{Spree.t(:resend).upcase}] " : '')
|
40
|
-
"#{resend_text}#{
|
40
|
+
"#{resend_text}#{@order.store.name} #{subject_text} ##{@order.number}"
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Spree
|
2
2
|
class ReimbursementMailer < BaseMailer
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
def reimbursement_email(reimbursement, resend = false)
|
4
|
+
@reimbursement = reimbursement.respond_to?(:id) ? reimbursement : Spree::Reimbursement.find(reimbursement)
|
5
|
+
store = @reimbursement.order.store
|
6
|
+
subject = (resend ? "[#{Spree.t(:resend).upcase}] " : '')
|
7
|
+
subject += "#{store.name} #{Spree.t('reimbursement_mailer.reimbursement_email.subject')} ##{@reimbursement.order.number}"
|
8
|
+
mail(to: @reimbursement.order.email, from: from_address(store), subject: subject)
|
9
|
+
end
|
10
10
|
end
|
11
11
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
module Spree
|
2
2
|
class TestMailer < BaseMailer
|
3
3
|
def test_email(email)
|
4
|
-
|
5
|
-
|
4
|
+
store = Spree::Store.default
|
5
|
+
subject = "#{store.name} #{Spree.t('test_mailer.test_email.subject')}"
|
6
|
+
mail(to: email, from: from_address(store), subject: subject)
|
6
7
|
end
|
7
8
|
end
|
8
9
|
end
|
@@ -15,7 +15,7 @@ module Spree
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def drop_payment_source(source)
|
18
|
-
|
18
|
+
Spree::Deprecation.warn("User#drop_payment_source is deprecated", caller)
|
19
19
|
gateway = source.payment_method
|
20
20
|
gateway.disable_customer_profile(source)
|
21
21
|
end
|
data/app/models/spree/address.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
require 'twitter_cldr'
|
2
|
+
|
1
3
|
module Spree
|
2
4
|
class Address < Spree::Base
|
3
|
-
|
5
|
+
extend ActiveModel::ForbiddenAttributesProtection
|
4
6
|
|
5
7
|
belongs_to :country, class_name: "Spree::Country"
|
6
8
|
belongs_to :state, class_name: "Spree::State"
|
@@ -15,6 +17,7 @@ module Spree
|
|
15
17
|
alias_attribute :last_name, :lastname
|
16
18
|
|
17
19
|
DB_ONLY_ATTRS = %w(id updated_at created_at)
|
20
|
+
TAXATION_ATTRS = %w(state_id country_id zipcode)
|
18
21
|
|
19
22
|
self.whitelisted_ransackable_attributes = %w[firstname lastname]
|
20
23
|
|
@@ -27,7 +30,7 @@ module Spree
|
|
27
30
|
end
|
28
31
|
|
29
32
|
def self.default(user = nil, kind = "bill")
|
30
|
-
|
33
|
+
Spree::Deprecation.warn("Address.default is deprecated. Use User.default_address or Address.build_default", caller)
|
31
34
|
if user
|
32
35
|
user.send(:"#{kind}_address") || build_default
|
33
36
|
else
|
@@ -44,6 +47,9 @@ module Spree
|
|
44
47
|
# @return [Address] address from existing address plus new_attributes as diff
|
45
48
|
# @note, this may return existing_address if there are no changes to value equality
|
46
49
|
def self.immutable_merge(existing_address, new_attributes)
|
50
|
+
# Ensure new_attributes is a sanitized hash
|
51
|
+
new_attributes = sanitize_for_mass_assignment(new_attributes)
|
52
|
+
|
47
53
|
return factory(new_attributes) if existing_address.nil?
|
48
54
|
|
49
55
|
merged_attributes = value_attributes(existing_address.attributes, new_attributes)
|
@@ -78,6 +84,10 @@ module Spree
|
|
78
84
|
self.class.value_attributes(attributes)
|
79
85
|
end
|
80
86
|
|
87
|
+
def taxation_attributes
|
88
|
+
self.class.value_attributes(attributes.slice(*TAXATION_ATTRS))
|
89
|
+
end
|
90
|
+
|
81
91
|
# @return [String] the full name on this address
|
82
92
|
def full_name
|
83
93
|
"#{firstname} #{lastname}".strip
|
@@ -101,12 +111,12 @@ module Spree
|
|
101
111
|
end
|
102
112
|
|
103
113
|
def same_as?(other_address)
|
104
|
-
|
114
|
+
Spree::Deprecation.warn("Address.same_as? is deprecated. It's equivalent to Address.==", caller)
|
105
115
|
self == other_address
|
106
116
|
end
|
107
117
|
|
108
118
|
def same_as(other_address)
|
109
|
-
|
119
|
+
Spree::Deprecation.warn("Address.same_as is deprecated. It's equivalent to Address.==", caller)
|
110
120
|
self == other_address
|
111
121
|
end
|
112
122
|
|
@@ -26,17 +26,14 @@ module Spree
|
|
26
26
|
validates :amount, numericality: true
|
27
27
|
validates :promotion_code, presence: true, if: :require_promotion_code?
|
28
28
|
|
29
|
-
after_create :update_adjustable_adjustment_total
|
30
|
-
after_destroy :update_adjustable_adjustment_total
|
31
|
-
|
32
29
|
scope :not_finalized, -> { where(finalized: false) }
|
33
30
|
scope :open, -> do
|
34
|
-
|
31
|
+
Spree::Deprecation.warn "Adjustment.open is deprecated. Instead use Adjustment.not_finalized", caller
|
35
32
|
where(finalized: false)
|
36
33
|
end
|
37
34
|
scope :finalized, -> { where(finalized: true) }
|
38
35
|
scope :closed, -> do
|
39
|
-
|
36
|
+
Spree::Deprecation.warn "Adjustment.closed is deprecated. Instead use Adjustment.finalized", caller
|
40
37
|
where(finalized: true)
|
41
38
|
end
|
42
39
|
scope :cancellation, -> { where(source_type: 'Spree::UnitCancel') }
|
@@ -78,12 +75,12 @@ module Spree
|
|
78
75
|
|
79
76
|
# Deprecated methods
|
80
77
|
def state
|
81
|
-
|
78
|
+
Spree::Deprecation.warn "Adjustment#state is deprecated. Instead use Adjustment#finalized?", caller
|
82
79
|
finalized? ? "closed" : "open"
|
83
80
|
end
|
84
81
|
|
85
82
|
def state=(new_state)
|
86
|
-
|
83
|
+
Spree::Deprecation.warn "Adjustment#state= is deprecated. Instead use Adjustment#finalized=", caller
|
87
84
|
case new_state
|
88
85
|
when "open"
|
89
86
|
self.finalized = false
|
@@ -95,32 +92,32 @@ module Spree
|
|
95
92
|
end
|
96
93
|
|
97
94
|
def open?
|
98
|
-
|
95
|
+
Spree::Deprecation.warn "Adjustment#open? is deprecated. Instead use Adjustment#finalized?", caller
|
99
96
|
!closed?
|
100
97
|
end
|
101
98
|
|
102
99
|
def closed?
|
103
|
-
|
100
|
+
Spree::Deprecation.warn "Adjustment#closed? is deprecated. Instead use Adjustment#finalized?", caller
|
104
101
|
finalized?
|
105
102
|
end
|
106
103
|
|
107
104
|
def open
|
108
|
-
|
105
|
+
Spree::Deprecation.warn "Adjustment#open is deprecated. Instead use Adjustment#unfinalize", caller
|
109
106
|
unfinalize
|
110
107
|
end
|
111
108
|
|
112
109
|
def open!
|
113
|
-
|
110
|
+
Spree::Deprecation.warn "Adjustment#open! is deprecated. Instead use Adjustment#unfinalize!", caller
|
114
111
|
unfinalize!
|
115
112
|
end
|
116
113
|
|
117
114
|
def close
|
118
|
-
|
115
|
+
Spree::Deprecation.warn "Adjustment#close is deprecated. Instead use Adjustment#finalize", caller
|
119
116
|
finalize
|
120
117
|
end
|
121
118
|
|
122
119
|
def close!
|
123
|
-
|
120
|
+
Spree::Deprecation.warn "Adjustment#close! is deprecated. Instead use Adjustment#finalize!", caller
|
124
121
|
finalize!
|
125
122
|
end
|
126
123
|
# End deprecated methods
|
@@ -154,7 +151,7 @@ module Spree
|
|
154
151
|
# @return [BigDecimal] New amount of this adjustment
|
155
152
|
def update!(target = nil)
|
156
153
|
if target
|
157
|
-
|
154
|
+
Spree::Deprecation.warn("Passing a target to Adjustment#update! is deprecated. The adjustment will use the correct target from it's adjustable association.", caller)
|
158
155
|
end
|
159
156
|
return amount if finalized?
|
160
157
|
|
@@ -177,11 +174,6 @@ module Spree
|
|
177
174
|
|
178
175
|
private
|
179
176
|
|
180
|
-
def update_adjustable_adjustment_total
|
181
|
-
# Cause adjustable's total to be recalculated
|
182
|
-
ItemAdjustments.new(adjustable).update
|
183
|
-
end
|
184
|
-
|
185
177
|
def require_promotion_code?
|
186
178
|
promotion? && source.promotion.codes.any?
|
187
179
|
end
|
@@ -349,6 +349,28 @@ module Spree
|
|
349
349
|
@order_merger_class ||= Spree::OrderMerger
|
350
350
|
end
|
351
351
|
|
352
|
+
# Allows providing your own class for adding default payments to a user's
|
353
|
+
# order from their "wallet".
|
354
|
+
#
|
355
|
+
# @!attribute [rw] default_payment_builder_class
|
356
|
+
# @return [Class] a class with the same public interfaces as
|
357
|
+
# Spree::Wallet::DefaultPaymentBuilder.
|
358
|
+
attr_writer :default_payment_builder_class
|
359
|
+
def default_payment_builder_class
|
360
|
+
@default_payment_builder_class ||= Spree::Wallet::DefaultPaymentBuilder
|
361
|
+
end
|
362
|
+
|
363
|
+
# Allows providing your own class for adding payment sources to a user's
|
364
|
+
# "wallet" after an order moves to the complete state.
|
365
|
+
#
|
366
|
+
# @!attribute [rw] add_payment_sources_to_wallet_class
|
367
|
+
# @return [Class] a class with the same public interfaces
|
368
|
+
# as Spree::Wallet::AddPaymentSourcesToWallet.
|
369
|
+
attr_writer :add_payment_sources_to_wallet_class
|
370
|
+
def add_payment_sources_to_wallet_class
|
371
|
+
@add_payment_sources_to_wallet_class ||= Spree::Wallet::AddPaymentSourcesToWallet
|
372
|
+
end
|
373
|
+
|
352
374
|
def static_model_preferences
|
353
375
|
@static_model_preferences ||= Spree::Preferences::StaticModelPreferences.new
|
354
376
|
end
|
@@ -387,7 +409,7 @@ module Spree
|
|
387
409
|
|
388
410
|
# support all the old preference methods with a warning
|
389
411
|
define_method "preferred_#{old_preference_name}" do
|
390
|
-
|
412
|
+
Spree::Deprecation.warn("#{old_preference_name} is no longer supported on Spree::Config, please access it through #{store_method} on Spree::Store", bc.clean(caller))
|
391
413
|
Spree::Store.default.send(store_method)
|
392
414
|
end
|
393
415
|
end
|
data/app/models/spree/base.rb
CHANGED
@@ -26,4 +26,13 @@ class Spree::Base < ActiveRecord::Base
|
|
26
26
|
end
|
27
27
|
|
28
28
|
self.abstract_class = true
|
29
|
+
|
30
|
+
# Provides a scope that should be included any time products
|
31
|
+
# are fetched with the intention of displaying to the user.
|
32
|
+
#
|
33
|
+
# Allows individual stores to include any active record scopes or joins
|
34
|
+
# when products are displayed.
|
35
|
+
def self.display_includes
|
36
|
+
where(nil)
|
37
|
+
end
|
29
38
|
end
|
data/app/models/spree/country.rb
CHANGED
@@ -7,7 +7,7 @@ module Spree
|
|
7
7
|
validates :name, :iso_name, presence: true
|
8
8
|
|
9
9
|
def self.states_required_by_country_id
|
10
|
-
|
10
|
+
Spree::Deprecation.warn "Spree::Country.states_required_by_country_id is deprecated and will be removed from future releases, Implement it yourself.", caller
|
11
11
|
states_required = Hash.new(true)
|
12
12
|
all.each { |country| states_required[country.id.to_s] = country.states_required }
|
13
13
|
states_required
|
@@ -15,7 +15,7 @@ module Spree
|
|
15
15
|
|
16
16
|
def self.default
|
17
17
|
if Spree::Config.default_country_id
|
18
|
-
|
18
|
+
Spree::Deprecation.warn("Setting your default country via its ID is deprecated. Please set your default country via the `default_country_iso` setting.", caller)
|
19
19
|
find_by(id: Spree::Config.default_country_id) || find_by!(iso: Spree::Config.default_country_iso)
|
20
20
|
else
|
21
21
|
find_by!(iso: Spree::Config.default_country_iso)
|
@@ -20,7 +20,7 @@ module Spree
|
|
20
20
|
|
21
21
|
def perform!
|
22
22
|
begin
|
23
|
-
shipments = Spree::
|
23
|
+
shipments = Spree::Config.stock.coordinator_class.new(@order, @reimbursement_objects.map(&:build_exchange_inventory_unit)).shipments
|
24
24
|
rescue Spree::Order::InsufficientStock
|
25
25
|
raise UnableToCreateShipments.new("Could not generate shipments for all items. Out of stock?")
|
26
26
|
end
|
data/app/models/spree/gateway.rb
CHANGED
@@ -39,7 +39,7 @@ module Spree
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def disable_customer_profile(source)
|
42
|
-
|
42
|
+
Spree::Deprecation.warn("Gateway#disable_customer_profile is deprecated")
|
43
43
|
if source.is_a? CreditCard
|
44
44
|
source.update_column :gateway_customer_profile_id, nil
|
45
45
|
else
|
@@ -70,6 +70,13 @@ module Spree
|
|
70
70
|
updated_at: Time.current
|
71
71
|
) if @item.changed?
|
72
72
|
|
73
|
+
# In rails 4.2 update_columns isn't reflected in the changed_attributes hash,
|
74
|
+
# which means that multiple updates on the same in-memory model will
|
75
|
+
# behave incorrectly.
|
76
|
+
# In rails 5.0 changed_attributes works with update_columns and this is
|
77
|
+
# unnecessary.
|
78
|
+
item.attributes_changed_by_setter.except!(:promo_total, :included_tax_total, :additional_tax_total, :adjustment_total)
|
79
|
+
|
73
80
|
@item
|
74
81
|
end
|
75
82
|
|
@@ -26,7 +26,6 @@ module Spree
|
|
26
26
|
after_create :update_tax_charge
|
27
27
|
|
28
28
|
after_save :update_inventory
|
29
|
-
after_save :update_adjustments
|
30
29
|
|
31
30
|
before_destroy :update_inventory
|
32
31
|
before_destroy :destroy_inventory_units
|
@@ -151,7 +150,7 @@ module Spree
|
|
151
150
|
|
152
151
|
def handle_copy_price_override
|
153
152
|
copy_price
|
154
|
-
|
153
|
+
Spree::Deprecation.warn 'You have overridden Spree::LineItem#copy_price. ' \
|
155
154
|
'This method is now called Spree::LineItem#set_pricing_attributes. ' \
|
156
155
|
'Please adjust your override.',
|
157
156
|
caller
|
@@ -167,17 +166,6 @@ module Spree
|
|
167
166
|
inventory_units.destroy_all
|
168
167
|
end
|
169
168
|
|
170
|
-
def update_adjustments
|
171
|
-
if quantity_changed?
|
172
|
-
update_tax_charge # Called to ensure pre_tax_amount is updated.
|
173
|
-
recalculate_adjustments
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
def recalculate_adjustments
|
178
|
-
Spree::ItemAdjustments.new(self).update
|
179
|
-
end
|
180
|
-
|
181
169
|
def update_tax_charge
|
182
170
|
Spree::Tax::ItemAdjuster.new(self).adjust!
|
183
171
|
end
|
@@ -36,7 +36,7 @@ module Spree
|
|
36
36
|
# To avoid multiple occurrences of the same transition being defined
|
37
37
|
# On first definition, state_machines will not be defined
|
38
38
|
state_machines.clear if respond_to?(:state_machines)
|
39
|
-
state_machine :state, initial: :cart, use_transactions: false
|
39
|
+
state_machine :state, initial: :cart, use_transactions: false do
|
40
40
|
klass.next_event_transitions.each { |t| transition(t.merge(on: :next)) }
|
41
41
|
|
42
42
|
# Persist the state on the order
|
@@ -76,7 +76,7 @@ module Spree
|
|
76
76
|
transition to: :payment, from: :confirm
|
77
77
|
end
|
78
78
|
|
79
|
-
after_transition to: :complete, do: :
|
79
|
+
after_transition to: :complete, do: :add_payment_sources_to_wallet
|
80
80
|
before_transition to: :payment, do: :set_shipments_cost
|
81
81
|
before_transition to: :payment, do: :create_tax_charge!
|
82
82
|
before_transition to: :payment, do: :assign_default_credit_card
|
@@ -250,7 +250,7 @@ module Spree
|
|
250
250
|
|
251
251
|
# @deprecated Use {OrderUpdateAttributes} instead
|
252
252
|
def update_from_params(params, permitted_params, request_env = {})
|
253
|
-
|
253
|
+
Spree::Deprecation.warn "update_from_params is deprecated. Use the OrderUpdateAttributes class instead", caller
|
254
254
|
success = false
|
255
255
|
@updating_params = params
|
256
256
|
run_callbacks :updating_from_params do
|
@@ -309,22 +309,25 @@ module Spree
|
|
309
309
|
end
|
310
310
|
end
|
311
311
|
|
312
|
-
def
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
default_cc.user_id = user_id
|
317
|
-
default_cc.default = true
|
318
|
-
default_cc.save
|
319
|
-
end
|
312
|
+
def add_payment_sources_to_wallet
|
313
|
+
Spree::Config.
|
314
|
+
add_payment_sources_to_wallet_class.new(self).
|
315
|
+
add_to_wallet
|
320
316
|
end
|
317
|
+
alias_method :persist_user_credit_card, :add_payment_sources_to_wallet
|
318
|
+
deprecate :persist_user_credit_card
|
321
319
|
|
322
320
|
def assign_default_credit_card
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
321
|
+
builder = Spree::Config.default_payment_builder_class.new(self)
|
322
|
+
|
323
|
+
if payment = builder.build
|
324
|
+
payments << payment
|
325
|
+
|
326
|
+
if bill_address.nil?
|
327
|
+
# this is one of 2 places still using User#bill_address
|
328
|
+
self.bill_address = payment.source.try(:address) ||
|
329
|
+
user.bill_address
|
330
|
+
end
|
328
331
|
end
|
329
332
|
end
|
330
333
|
|
@@ -38,8 +38,6 @@ module Spree
|
|
38
38
|
def process_payments_with(method)
|
39
39
|
# Don't run if there is nothing to pay.
|
40
40
|
return true if payment_total >= total
|
41
|
-
# Prevent orders from transitioning to complete without a successfully processed payment.
|
42
|
-
raise Core::GatewayError.new(Spree.t(:no_payment_found)) if unprocessed_payments.empty?
|
43
41
|
|
44
42
|
unprocessed_payments.each do |payment|
|
45
43
|
break if payment_total >= total
|
data/app/models/spree/order.rb
CHANGED
@@ -27,7 +27,7 @@ module Spree
|
|
27
27
|
end
|
28
28
|
|
29
29
|
self.whitelisted_ransackable_associations = %w[shipments user promotions bill_address ship_address line_items]
|
30
|
-
self.whitelisted_ransackable_attributes = %w[completed_at created_at email number state payment_state shipment_state total]
|
30
|
+
self.whitelisted_ransackable_attributes = %w[completed_at created_at email number state payment_state shipment_state total store_id]
|
31
31
|
|
32
32
|
attr_reader :coupon_code
|
33
33
|
attr_accessor :temporary_address, :temporary_credit_card
|
@@ -505,7 +505,7 @@ module Spree
|
|
505
505
|
else
|
506
506
|
adjustments.shipping.destroy_all
|
507
507
|
shipments.destroy_all
|
508
|
-
self.shipments = Spree::
|
508
|
+
self.shipments = Spree::Config.stock.coordinator_class.new(self).shipments
|
509
509
|
end
|
510
510
|
end
|
511
511
|
|
@@ -590,7 +590,7 @@ module Spree
|
|
590
590
|
end
|
591
591
|
|
592
592
|
def token
|
593
|
-
|
593
|
+
Spree::Deprecation.warn("Spree::Order#token is DEPRECATED, please use #guest_token instead.", caller)
|
594
594
|
guest_token
|
595
595
|
end
|
596
596
|
|
@@ -618,6 +618,9 @@ module Spree
|
|
618
618
|
end
|
619
619
|
|
620
620
|
def add_store_credit_payments
|
621
|
+
return if user.nil?
|
622
|
+
return if payments.store_credits.checkout.empty? && user.total_available_store_credit.zero?
|
623
|
+
|
621
624
|
payments.store_credits.checkout.each(&:invalidate!)
|
622
625
|
|
623
626
|
# this can happen when multiple payments are present, auto_capture is
|
@@ -627,7 +630,7 @@ module Spree
|
|
627
630
|
|
628
631
|
remaining_total = outstanding_balance - authorized_total
|
629
632
|
|
630
|
-
if user
|
633
|
+
if user.store_credits.any?
|
631
634
|
payment_method = Spree::PaymentMethod::StoreCredit.first
|
632
635
|
|
633
636
|
user.store_credits.order_by_priority.each do |credit|
|
@@ -689,23 +692,6 @@ module Spree
|
|
689
692
|
Spree::Money.new(total_available_store_credit - total_applicable_store_credit, { currency: currency })
|
690
693
|
end
|
691
694
|
|
692
|
-
def payments_attributes=(attributes)
|
693
|
-
validate_payments_attributes(attributes)
|
694
|
-
super(attributes)
|
695
|
-
end
|
696
|
-
|
697
|
-
def validate_payments_attributes(attributes)
|
698
|
-
attributes = Array.wrap(attributes)
|
699
|
-
# Ensure the payment methods specified are allowed for this user
|
700
|
-
payment_methods = Spree::PaymentMethod.where(id: available_payment_methods)
|
701
|
-
attributes.each do |payment_attributes|
|
702
|
-
payment_method_id = payment_attributes[:payment_method_id]
|
703
|
-
|
704
|
-
# raise RecordNotFound unless it is an allowed payment method
|
705
|
-
payment_methods.find(payment_method_id) if payment_method_id
|
706
|
-
end
|
707
|
-
end
|
708
|
-
|
709
695
|
private
|
710
696
|
|
711
697
|
def associate_store
|