solidus_core 2.11.1 → 2.11.6
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.
Potentially problematic release.
This version of solidus_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/models/spree/address.rb +28 -5
- data/app/models/spree/base.rb +9 -2
- data/app/models/spree/calculator.rb +4 -4
- data/app/models/spree/calculator/free_shipping.rb +1 -0
- data/app/models/spree/calculator/percent_per_item.rb +2 -0
- data/app/models/spree/calculator/price_sack.rb +1 -0
- data/app/models/spree/order/payments.rb +2 -2
- data/app/models/spree/order_merger.rb +1 -1
- data/app/models/spree/payment.rb +10 -3
- data/app/models/spree/payment/cancellation.rb +3 -22
- data/app/models/spree/payment_source.rb +2 -2
- data/app/models/spree/product.rb +8 -2
- data/app/models/spree/product/scopes.rb +0 -1
- data/app/models/spree/refund.rb +7 -1
- data/app/models/spree/shipping_method.rb +1 -1
- data/app/models/spree/stock/availability_validator.rb +2 -2
- data/app/models/spree/stock/inventory_validator.rb +2 -2
- data/app/models/spree/taxon/active_storage_attachment.rb +1 -2
- data/app/models/spree/taxon/paperclip_attachment.rb +1 -0
- data/db/migrate/20180416083007_add_apply_to_all_to_variant_property_rule.rb +1 -1
- data/db/migrate/20210122110141_add_name_to_spree_addresses.rb +13 -0
- data/lib/generators/spree/dummy/templates/rails/test.rb +4 -1
- data/lib/spree/app_configuration.rb +1 -1
- data/lib/spree/core.rb +1 -4
- data/lib/spree/core/engine.rb +7 -8
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/permitted_attributes.rb +5 -5
- data/lib/spree/testing_support.rb +31 -0
- data/lib/spree/testing_support/dummy_app.rb +4 -2
- data/lib/spree/testing_support/dummy_app/mailer_previews/test_mailer_preview.rb +4 -0
- data/lib/spree/testing_support/factories.rb +8 -4
- data/lib/spree/testing_support/factories/address_factory.rb +6 -2
- data/lib/spree/testing_support/factories/adjustment_factory.rb +10 -5
- data/lib/spree/testing_support/factories/adjustment_reason_factory.rb +5 -0
- data/lib/spree/testing_support/factories/calculator_factory.rb +5 -0
- data/lib/spree/testing_support/factories/carton_factory.rb +7 -2
- data/lib/spree/testing_support/factories/country_factory.rb +5 -0
- data/lib/spree/testing_support/factories/credit_card_factory.rb +5 -0
- data/lib/spree/testing_support/factories/customer_return_factory.rb +8 -3
- data/lib/spree/testing_support/factories/image_factory.rb +5 -0
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +9 -4
- data/lib/spree/testing_support/factories/line_item_factory.rb +7 -2
- data/lib/spree/testing_support/factories/option_type_factory.rb +8 -0
- data/lib/spree/testing_support/factories/option_value_factory.rb +5 -0
- data/lib/spree/testing_support/factories/order_factory.rb +11 -6
- data/lib/spree/testing_support/factories/order_promotion_factory.rb +7 -2
- data/lib/spree/testing_support/factories/payment_factory.rb +9 -4
- data/lib/spree/testing_support/factories/payment_method_factory.rb +5 -0
- data/lib/spree/testing_support/factories/price_factory.rb +6 -1
- data/lib/spree/testing_support/factories/product_factory.rb +10 -5
- data/lib/spree/testing_support/factories/product_option_type_factory.rb +7 -2
- data/lib/spree/testing_support/factories/product_property_factory.rb +7 -2
- data/lib/spree/testing_support/factories/promotion_category_factory.rb +5 -0
- data/lib/spree/testing_support/factories/promotion_code_factory.rb +7 -2
- data/lib/spree/testing_support/factories/promotion_factory.rb +7 -2
- data/lib/spree/testing_support/factories/property_factory.rb +5 -0
- data/lib/spree/testing_support/factories/refund_factory.rb +7 -2
- data/lib/spree/testing_support/factories/refund_reason_factory.rb +5 -0
- data/lib/spree/testing_support/factories/reimbursement_factory.rb +6 -1
- data/lib/spree/testing_support/factories/reimbursement_type_factory.rb +5 -0
- data/lib/spree/testing_support/factories/return_authorization_factory.rb +8 -3
- data/lib/spree/testing_support/factories/return_item_factory.rb +8 -3
- data/lib/spree/testing_support/factories/return_reason_factory.rb +5 -0
- data/lib/spree/testing_support/factories/role_factory.rb +5 -0
- data/lib/spree/testing_support/factories/shipment_factory.rb +9 -3
- data/lib/spree/testing_support/factories/shipping_category_factory.rb +5 -0
- data/lib/spree/testing_support/factories/shipping_method_factory.rb +8 -3
- data/lib/spree/testing_support/factories/shipping_rate_factory.rb +7 -2
- data/lib/spree/testing_support/factories/state_factory.rb +7 -1
- data/lib/spree/testing_support/factories/stock_item_factory.rb +7 -2
- data/lib/spree/testing_support/factories/stock_location_factory.rb +8 -3
- data/lib/spree/testing_support/factories/stock_movement_factory.rb +6 -1
- data/lib/spree/testing_support/factories/stock_package_factory.rb +7 -2
- data/lib/spree/testing_support/factories/store_credit_category_factory.rb +5 -0
- data/lib/spree/testing_support/factories/store_credit_event_factory.rb +7 -2
- data/lib/spree/testing_support/factories/store_credit_factory.rb +8 -3
- data/lib/spree/testing_support/factories/store_credit_reason_factory.rb +5 -0
- data/lib/spree/testing_support/factories/store_credit_type_factory.rb +5 -0
- data/lib/spree/testing_support/factories/store_factory.rb +6 -1
- data/lib/spree/testing_support/factories/tax_category_factory.rb +7 -1
- data/lib/spree/testing_support/factories/tax_rate_factory.rb +8 -3
- data/lib/spree/testing_support/factories/taxon_factory.rb +6 -1
- data/lib/spree/testing_support/factories/taxonomy_factory.rb +5 -0
- data/lib/spree/testing_support/factories/user_factory.rb +8 -3
- data/lib/spree/testing_support/factories/variant_factory.rb +9 -4
- data/lib/spree/testing_support/factories/variant_property_rule_condition_factory.rb +7 -2
- data/lib/spree/testing_support/factories/variant_property_rule_factory.rb +8 -3
- data/lib/spree/testing_support/factories/variant_property_rule_value_factory.rb +7 -2
- data/lib/spree/testing_support/factories/zone_factory.rb +7 -2
- data/lib/spree/testing_support/factory_bot.rb +68 -0
- data/lib/spree/testing_support/order_walkthrough.rb +10 -10
- data/lib/spree/testing_support/sequences.rb +4 -1
- data/{app/models → lib}/spree/user_class_handle.rb +0 -0
- data/lib/tasks/email.rake +3 -2
- data/lib/tasks/migrations/migrate_address_names.rake +158 -0
- data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +38 -0
- data/lib/tasks/upgrade.rake +13 -0
- data/solidus_core.gemspec +24 -2
- metadata +48 -23
- data/lib/spree/awesome_nested_set_override.rb +0 -44
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: d027dc2e99b1a25b1217cd8625f0e375a54fe6c63649080d2b3199360965886b
         | 
| 4 | 
            +
              data.tar.gz: 6c6dd38a8b9a117ca95b9608c6b5a1b367fe263b8cd0d152f84dda94c337ac55
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 6402bc69d1af4cb7fc0f7b41af1086238249a49a9ded3bc2f70471766820a8950c748f416bf795a7f43d5852727981d15d1bd6af9051226f4159f57f69946fc8
         | 
| 7 | 
            +
              data.tar.gz: a79e25b3f90d223545db55b96adefc1ac6474bfdce50d738e6d16a621deb69f5ed1f5a46b7f466b7f58d138a9930a9a466680eb181dedf84e8c6278ceaa532cf
         | 
    
        data/app/models/spree/address.rb
    CHANGED
    
    | @@ -92,6 +92,12 @@ module Spree | |
| 92 92 | 
             
                  if base['lastname'].presence || base['last_name'].presence
         | 
| 93 93 | 
             
                    base['lastname'] = name_from_attributes.last_name
         | 
| 94 94 | 
             
                  end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                  virtual_name = name_from_attributes.value
         | 
| 97 | 
            +
                  if base['name'].blank? && virtual_name.present?
         | 
| 98 | 
            +
                    base['name'] = virtual_name
         | 
| 99 | 
            +
                  end
         | 
| 100 | 
            +
             | 
| 95 101 | 
             
                  excluded_attributes = DB_ONLY_ATTRS + %w(first_name last_name)
         | 
| 96 102 |  | 
| 97 103 | 
             
                  base.except(*excluded_attributes)
         | 
| @@ -120,7 +126,11 @@ module Spree | |
| 120 126 | 
             
                # @return [Boolean] true if the two addresses have the same address fields
         | 
| 121 127 | 
             
                def ==(other_address)
         | 
| 122 128 | 
             
                  return false unless other_address && other_address.respond_to?(:value_attributes)
         | 
| 123 | 
            -
                   | 
| 129 | 
            +
                  if Spree::Config.use_combined_first_and_last_name_in_address
         | 
| 130 | 
            +
                    value_attributes.except(*LEGACY_NAME_ATTRS) == other_address.value_attributes.except(*LEGACY_NAME_ATTRS)
         | 
| 131 | 
            +
                  else
         | 
| 132 | 
            +
                    value_attributes == other_address.value_attributes
         | 
| 133 | 
            +
                  end
         | 
| 124 134 | 
             
                end
         | 
| 125 135 |  | 
| 126 136 | 
             
                # @deprecated Do not use this. Use Address.== instead.
         | 
| @@ -193,17 +203,30 @@ module Spree | |
| 193 203 | 
             
                  country && country.iso
         | 
| 194 204 | 
             
                end
         | 
| 195 205 |  | 
| 206 | 
            +
                before_save :set_name_from_firstname_and_lastname
         | 
| 207 | 
            +
             | 
| 208 | 
            +
                def set_name_from_firstname_and_lastname
         | 
| 209 | 
            +
                  name_from_firstname_and_lastname = Spree::Address::Name.from_attributes(attributes.except(:name, 'name'))
         | 
| 210 | 
            +
             | 
| 211 | 
            +
                  if read_attribute(:name).blank? && name_from_firstname_and_lastname.present?
         | 
| 212 | 
            +
                    write_attribute(:name, name_from_firstname_and_lastname)
         | 
| 213 | 
            +
                  end
         | 
| 214 | 
            +
                end
         | 
| 215 | 
            +
             | 
| 196 216 | 
             
                # @return [String] the full name on this address
         | 
| 197 217 | 
             
                def name
         | 
| 198 | 
            -
                   | 
| 199 | 
            -
                     | 
| 200 | 
            -
             | 
| 201 | 
            -
             | 
| 218 | 
            +
                  self[:name] || begin
         | 
| 219 | 
            +
                    Spree::Address::Name.new(
         | 
| 220 | 
            +
                      read_attribute(:firstname),
         | 
| 221 | 
            +
                      read_attribute(:lastname)
         | 
| 222 | 
            +
                    ).value
         | 
| 223 | 
            +
                  end
         | 
| 202 224 | 
             
                end
         | 
| 203 225 |  | 
| 204 226 | 
             
                def name=(value)
         | 
| 205 227 | 
             
                  return if value.nil?
         | 
| 206 228 |  | 
| 229 | 
            +
                  write_attribute(:name, value)
         | 
| 207 230 | 
             
                  name_from_value = Spree::Address::Name.new(value)
         | 
| 208 231 | 
             
                  write_attribute(:firstname, name_from_value.first_name)
         | 
| 209 232 | 
             
                  write_attribute(:lastname, name_from_value.last_name)
         | 
    
        data/app/models/spree/base.rb
    CHANGED
    
    | @@ -3,10 +3,12 @@ | |
| 3 3 | 
             
            class Spree::Base < ActiveRecord::Base
         | 
| 4 4 | 
             
              include Spree::Preferences::Preferable
         | 
| 5 5 | 
             
              include Spree::Core::Permalinks
         | 
| 6 | 
            -
              serialize :preferences, Hash
         | 
| 7 | 
            -
             | 
| 8 6 | 
             
              include Spree::RansackableAttributes
         | 
| 9 7 |  | 
| 8 | 
            +
              def preferences
         | 
| 9 | 
            +
                read_attribute(:preferences) || self.class.preferences_coder_class.new
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 10 12 | 
             
              def initialize_preference_defaults
         | 
| 11 13 | 
             
                if has_attribute?(:preferences)
         | 
| 12 14 | 
             
                  self.preferences = default_preferences.merge(preferences)
         | 
| @@ -18,6 +20,7 @@ class Spree::Base < ActiveRecord::Base | |
| 18 20 | 
             
              def self.preference(*args)
         | 
| 19 21 | 
             
                # after_initialize can be called multiple times with the same symbol, it
         | 
| 20 22 | 
             
                # will only be called once on initialization.
         | 
| 23 | 
            +
                serialize :preferences, preferences_coder_class
         | 
| 21 24 | 
             
                after_initialize :initialize_preference_defaults
         | 
| 22 25 | 
             
                super
         | 
| 23 26 | 
             
              end
         | 
| @@ -32,6 +35,10 @@ class Spree::Base < ActiveRecord::Base | |
| 32 35 | 
             
                end
         | 
| 33 36 | 
             
              end
         | 
| 34 37 |  | 
| 38 | 
            +
              def self.preferences_coder_class
         | 
| 39 | 
            +
                Hash
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
             | 
| 35 42 | 
             
              self.abstract_class = true
         | 
| 36 43 |  | 
| 37 44 | 
             
              # Provides a scope that should be included any time products
         | 
| @@ -10,12 +10,12 @@ module Spree | |
| 10 10 | 
             
                def compute(computable)
         | 
| 11 11 | 
             
                  # Spree::LineItem -> :compute_line_item
         | 
| 12 12 | 
             
                  computable_name = computable.class.name.demodulize.underscore
         | 
| 13 | 
            -
                   | 
| 13 | 
            +
                  method_name = "compute_#{computable_name}".to_sym
         | 
| 14 14 | 
             
                  calculator_class = self.class
         | 
| 15 | 
            -
                  if respond_to?( | 
| 16 | 
            -
                    send( | 
| 15 | 
            +
                  if respond_to?(method_name)
         | 
| 16 | 
            +
                    send(method_name, computable)
         | 
| 17 17 | 
             
                  else
         | 
| 18 | 
            -
                    raise NotImplementedError, "Please implement '#{ | 
| 18 | 
            +
                    raise NotImplementedError, "Please implement '#{method_name}(#{computable_name})' in your calculator: #{calculator_class.name}"
         | 
| 19 19 | 
             
                  end
         | 
| 20 20 | 
             
                end
         | 
| 21 21 |  | 
| @@ -8,6 +8,7 @@ module Spree | |
| 8 8 | 
             
              #   now a Promotion Action which deals with these types of promotions instead.
         | 
| 9 9 | 
             
              class Calculator::FreeShipping < Calculator
         | 
| 10 10 | 
             
                def compute(object)
         | 
| 11 | 
            +
                  Spree::Deprecation.warn('This method is deprecated, because it is no longer used')
         | 
| 11 12 | 
             
                  if object.is_a?(Array)
         | 
| 12 13 | 
             
                    return if object.empty?
         | 
| 13 14 | 
             
                    order = object.first.order
         | 
| @@ -15,6 +15,8 @@ module Spree | |
| 15 15 | 
             
                preference :percent, :decimal, default: 0
         | 
| 16 16 |  | 
| 17 17 | 
             
                def compute(object = nil)
         | 
| 18 | 
            +
                  Spree::Deprecation.warn('This method is deprecated, please use adjustments at line item level')
         | 
| 19 | 
            +
             | 
| 18 20 | 
             
                  return 0 if object.nil?
         | 
| 19 21 | 
             
                  object.line_items.sum { |line_item|
         | 
| 20 22 | 
             
                    value_for_line_item(line_item)
         | 
| @@ -11,6 +11,7 @@ module Spree | |
| 11 11 |  | 
| 12 12 | 
             
                # as object we always get line items, as calculable we have Coupon, ShippingMethod
         | 
| 13 13 | 
             
                def compute(object)
         | 
| 14 | 
            +
                  Spree::Deprecation.warn('This method is deprecated, please use adjustments at line item level')
         | 
| 14 15 | 
             
                  if object.is_a?(Array)
         | 
| 15 16 | 
             
                    base = object.sum { |element| element.respond_to?(:amount) ? element.amount : BigDecimal(element.to_s) }
         | 
| 16 17 | 
             
                  else
         | 
| @@ -37,14 +37,14 @@ module Spree | |
| 37 37 |  | 
| 38 38 | 
             
                  private
         | 
| 39 39 |  | 
| 40 | 
            -
                  def process_payments_with( | 
| 40 | 
            +
                  def process_payments_with(method_name)
         | 
| 41 41 | 
             
                    # Don't run if there is nothing to pay.
         | 
| 42 42 | 
             
                    return true if payment_total >= total
         | 
| 43 43 |  | 
| 44 44 | 
             
                    unprocessed_payments.each do |payment|
         | 
| 45 45 | 
             
                      break if payment_total >= total
         | 
| 46 46 |  | 
| 47 | 
            -
                      payment.public_send( | 
| 47 | 
            +
                      payment.public_send(method_name)
         | 
| 48 48 | 
             
                    end
         | 
| 49 49 | 
             
                  rescue Core::GatewayError => error
         | 
| 50 50 | 
             
                    result = !!Spree::Config[:allow_checkout_on_gateway_error]
         | 
| @@ -128,7 +128,7 @@ module Spree | |
| 128 128 | 
             
                # @param [Spree::LineItem] line_item The line item which could not be saved
         | 
| 129 129 | 
             
                # @return [void]
         | 
| 130 130 | 
             
                def handle_error(line_item)
         | 
| 131 | 
            -
                  order.errors | 
| 131 | 
            +
                  order.errors.add(:base, line_item.errors.full_messages)
         | 
| 132 132 | 
             
                end
         | 
| 133 133 |  | 
| 134 134 | 
             
                # Save the order totals after merge
         | 
    
        data/app/models/spree/payment.rb
    CHANGED
    
    | @@ -168,9 +168,16 @@ module Spree | |
| 168 168 |  | 
| 169 169 | 
             
                def validate_source
         | 
| 170 170 | 
             
                  if source && !source.valid?
         | 
| 171 | 
            -
                     | 
| 172 | 
            -
                       | 
| 173 | 
            -
             | 
| 171 | 
            +
                    if Gem::Requirement.new(">= 6.1").satisfied_by?(Rails.gem_version)
         | 
| 172 | 
            +
                      source.errors.each do |error|
         | 
| 173 | 
            +
                        field_name = I18n.t("activerecord.attributes.#{source.class.to_s.underscore}.#{error.attribute}")
         | 
| 174 | 
            +
                        errors.add(I18n.t(source.class.to_s.demodulize.underscore, scope: 'spree'), "#{field_name} #{error.message}")
         | 
| 175 | 
            +
                      end
         | 
| 176 | 
            +
                    else
         | 
| 177 | 
            +
                      source.errors.each do |field, error|
         | 
| 178 | 
            +
                        field_name = I18n.t("activerecord.attributes.#{source.class.to_s.underscore}.#{field}")
         | 
| 179 | 
            +
                        errors.add(I18n.t(source.class.to_s.demodulize.underscore, scope: 'spree'), "#{field_name} #{error}")
         | 
| 180 | 
            +
                      end
         | 
| 174 181 | 
             
                    end
         | 
| 175 182 | 
             
                  end
         | 
| 176 183 | 
             
                  if errors.any?
         | 
| @@ -26,16 +26,10 @@ module Spree | |
| 26 26 | 
             
                  # @param payment [Spree::Payment] - the payment that should be canceled
         | 
| 27 27 | 
             
                  #
         | 
| 28 28 | 
             
                  def cancel(payment)
         | 
| 29 | 
            -
                     | 
| 30 | 
            -
             | 
| 31 | 
            -
                      if response = payment.payment_method.try_void(payment)
         | 
| 32 | 
            -
                        payment.handle_void_response(response)
         | 
| 33 | 
            -
                      else
         | 
| 34 | 
            -
                        payment.refunds.create!(amount: payment.credit_allowed, reason: refund_reason, perform_after_create: false).perform!
         | 
| 35 | 
            -
                      end
         | 
| 29 | 
            +
                    if response = payment.payment_method.try_void(payment)
         | 
| 30 | 
            +
                      payment.handle_void_response(response)
         | 
| 36 31 | 
             
                    else
         | 
| 37 | 
            -
                       | 
| 38 | 
            -
                      deprecated_behavior(payment)
         | 
| 32 | 
            +
                      payment.refunds.create!(amount: payment.credit_allowed, reason: refund_reason, perform_after_create: false).perform!
         | 
| 39 33 | 
             
                    end
         | 
| 40 34 | 
             
                  end
         | 
| 41 35 |  | 
| @@ -44,19 +38,6 @@ module Spree | |
| 44 38 | 
             
                  def refund_reason
         | 
| 45 39 | 
             
                    Spree::RefundReason.where(name: reason).first_or_create
         | 
| 46 40 | 
             
                  end
         | 
| 47 | 
            -
             | 
| 48 | 
            -
                  def try_void_available?(payment_method)
         | 
| 49 | 
            -
                    payment_method.respond_to?(:try_void) &&
         | 
| 50 | 
            -
                      payment_method.method(:try_void).owner != Spree::PaymentMethod
         | 
| 51 | 
            -
                  end
         | 
| 52 | 
            -
             | 
| 53 | 
            -
                  def deprecated_behavior(payment)
         | 
| 54 | 
            -
                    Spree::Deprecation.warn "#{payment.payment_method.class.name}#cancel is deprecated and will be removed. " \
         | 
| 55 | 
            -
                      'Please implement a `try_void` method instead that returns a response object if void succeeds ' \
         | 
| 56 | 
            -
                      'or `false|nil` if not. Solidus will refund the payment then.'
         | 
| 57 | 
            -
                    response = payment.payment_method.cancel(payment.response_code)
         | 
| 58 | 
            -
                    payment.handle_void_response(response)
         | 
| 59 | 
            -
                  end
         | 
| 60 41 | 
             
                end
         | 
| 61 42 | 
             
              end
         | 
| 62 43 | 
             
            end
         | 
| @@ -23,9 +23,9 @@ module Spree | |
| 23 23 | 
             
                end
         | 
| 24 24 |  | 
| 25 25 | 
             
                # @param payment [Spree::Payment] the payment we want to know if can be voided
         | 
| 26 | 
            -
                # @return [Boolean] true when the payment is not failed or  | 
| 26 | 
            +
                # @return [Boolean] true when the payment is not failed, voided or invalid
         | 
| 27 27 | 
             
                def can_void?(payment)
         | 
| 28 | 
            -
                   | 
| 28 | 
            +
                  payment.can_void?
         | 
| 29 29 | 
             
                end
         | 
| 30 30 |  | 
| 31 31 | 
             
                # Indicates whether its possible to credit the payment.  Note that most
         | 
    
        data/app/models/spree/product.rb
    CHANGED
    
    | @@ -366,8 +366,14 @@ module Spree | |
| 366 366 | 
             
                # If the master is invalid, the Product object will be assigned its errors
         | 
| 367 367 | 
             
                def validate_master
         | 
| 368 368 | 
             
                  unless master.valid?
         | 
| 369 | 
            -
                     | 
| 370 | 
            -
                      errors. | 
| 369 | 
            +
                    if Gem::Requirement.new(">= 6.1").satisfied_by?(Rails.gem_version)
         | 
| 370 | 
            +
                      master.errors.each do |error|
         | 
| 371 | 
            +
                        errors.add(error.attribute, error.message)
         | 
| 372 | 
            +
                      end
         | 
| 373 | 
            +
                    else
         | 
| 374 | 
            +
                      master.errors.each do |att, error|
         | 
| 375 | 
            +
                        errors.add(att, error)
         | 
| 376 | 
            +
                      end
         | 
| 371 377 | 
             
                    end
         | 
| 372 378 | 
             
                  end
         | 
| 373 379 | 
             
                end
         | 
| @@ -70,7 +70,6 @@ module Spree | |
| 70 70 | 
             
                      add_search_scope :in_taxon do |taxon|
         | 
| 71 71 | 
             
                        includes(:classifications)
         | 
| 72 72 | 
             
                          .where('spree_products_taxons.taxon_id' => taxon.self_and_descendants.pluck(:id))
         | 
| 73 | 
            -
                          .select(Spree::Classification.arel_table[:position])
         | 
| 74 73 | 
             
                          .order(Spree::Classification.arel_table[:position].asc)
         | 
| 75 74 | 
             
                      end
         | 
| 76 75 |  | 
    
        data/app/models/spree/refund.rb
    CHANGED
    
    | @@ -61,7 +61,13 @@ module Spree | |
| 61 61 | 
             
                  )
         | 
| 62 62 |  | 
| 63 63 | 
             
                  log_entries.build(details: perform_response.to_yaml)
         | 
| 64 | 
            -
             | 
| 64 | 
            +
             | 
| 65 | 
            +
                  self.transaction_id = perform_response.authorization
         | 
| 66 | 
            +
                  # This is needed otherwise set_perform_after_create_default callback
         | 
| 67 | 
            +
                  # will print a deprecation warning when save! creates a record.
         | 
| 68 | 
            +
                  self.perform_after_create = false unless persisted?
         | 
| 69 | 
            +
                  save!
         | 
| 70 | 
            +
             | 
| 65 71 | 
             
                  update_order
         | 
| 66 72 | 
             
                end
         | 
| 67 73 |  | 
| @@ -119,7 +119,7 @@ module Spree | |
| 119 119 |  | 
| 120 120 | 
             
                def at_least_one_shipping_category
         | 
| 121 121 | 
             
                  if shipping_categories.empty?
         | 
| 122 | 
            -
                    errors | 
| 122 | 
            +
                    errors.add(:base, "You need to select at least one shipping category")
         | 
| 123 123 | 
             
                  end
         | 
| 124 124 | 
             
                end
         | 
| 125 125 | 
             
              end
         | 
| @@ -11,10 +11,10 @@ module Spree | |
| 11 11 | 
             
                      display_name = variant.name.to_s
         | 
| 12 12 | 
             
                      display_name += %{ (#{variant.options_text})} unless variant.options_text.blank?
         | 
| 13 13 |  | 
| 14 | 
            -
                      line_item.errors | 
| 14 | 
            +
                      line_item.errors.add(:quantity, I18n.t(
         | 
| 15 15 | 
             
                        'spree.selected_quantity_not_available',
         | 
| 16 16 | 
             
                        item: display_name.inspect
         | 
| 17 | 
            -
                      )
         | 
| 17 | 
            +
                      ))
         | 
| 18 18 | 
             
                      false
         | 
| 19 19 | 
             
                    end
         | 
| 20 20 | 
             
                  end
         | 
| @@ -5,10 +5,10 @@ module Spree | |
| 5 5 | 
             
                class InventoryValidator < ActiveModel::Validator
         | 
| 6 6 | 
             
                  def validate(line_item)
         | 
| 7 7 | 
             
                    if line_item.inventory_units.count != line_item.quantity
         | 
| 8 | 
            -
                      line_item.errors | 
| 8 | 
            +
                      line_item.errors.add(:inventory, I18n.t(
         | 
| 9 9 | 
             
                        'spree.inventory_not_available',
         | 
| 10 10 | 
             
                        item: line_item.variant.name
         | 
| 11 | 
            -
                      )
         | 
| 11 | 
            +
                      ))
         | 
| 12 12 | 
             
                    end
         | 
| 13 13 | 
             
                  end
         | 
| 14 14 | 
             
                end
         | 
| @@ -9,11 +9,10 @@ module Spree::Taxon::ActiveStorageAttachment | |
| 9 9 | 
             
                               styles: { mini: '32x32>', normal: '128x128>' },
         | 
| 10 10 | 
             
                               default_style: :mini
         | 
| 11 11 | 
             
                validate :icon_is_an_image
         | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 12 | 
             
              end
         | 
| 15 13 |  | 
| 16 14 | 
             
              def attachment_partial_name
         | 
| 15 | 
            +
                Spree::Deprecation.warn("calling #attachment_partial_name on Spree::Taxon is deprecated without replacement.")
         | 
| 17 16 | 
             
                'paperclip'
         | 
| 18 17 | 
             
              end
         | 
| 19 18 | 
             
            end
         | 
| @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            class AddApplyToAllToVariantPropertyRule < ActiveRecord::Migration[5.1]
         | 
| 4 | 
            -
              def  | 
| 4 | 
            +
              def up
         | 
| 5 5 | 
             
                add_column :spree_variant_property_rules, :apply_to_all, :boolean, default: false, null: false
         | 
| 6 6 | 
             
                change_column :spree_variant_property_rules, :apply_to_all, :boolean, default: true
         | 
| 7 7 | 
             
              end
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class AddNameToSpreeAddresses < ActiveRecord::Migration[5.2]
         | 
| 4 | 
            +
              def up
         | 
| 5 | 
            +
                add_column :spree_addresses, :name, :string
         | 
| 6 | 
            +
                add_index :spree_addresses, :name
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              def down
         | 
| 10 | 
            +
                remove_index :spree_addresses, :name
         | 
| 11 | 
            +
                remove_column :spree_addresses, :name
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
| @@ -20,11 +20,14 @@ Dummy::Application.configure do | |
| 20 20 | 
             
              # Raise exceptions instead of rendering exception templates
         | 
| 21 21 | 
             
              config.action_dispatch.show_exceptions = false
         | 
| 22 22 |  | 
| 23 | 
            +
              # Disable request forgery protection in test environment
         | 
| 24 | 
            +
              config.action_controller.allow_forgery_protection = false
         | 
| 25 | 
            +
             | 
| 23 26 | 
             
              # Tell Action Mailer not to deliver emails to the real world.
         | 
| 24 27 | 
             
              # The :test delivery method accumulates sent emails in the
         | 
| 25 28 | 
             
              # ActionMailer::Base.deliveries array.
         | 
| 26 29 | 
             
              config.action_mailer.delivery_method = :test
         | 
| 27 | 
            -
              ActionMailer::Base.default from: " | 
| 30 | 
            +
              ActionMailer::Base.default from: "solidus@example.com"
         | 
| 28 31 |  | 
| 29 32 | 
             
              # Raise on deprecation warnings
         | 
| 30 33 | 
             
              if ENV['SOLIDUS_RAISE_DEPRECATIONS'].present?
         | 
| @@ -190,7 +190,7 @@ module Spree | |
| 190 190 |  | 
| 191 191 | 
             
                # @!attribute [rw] mails_from
         | 
| 192 192 | 
             
                #   @return [String] Email address used as +From:+ field in transactional emails.
         | 
| 193 | 
            -
                preference :mails_from, :string, default: ' | 
| 193 | 
            +
                preference :mails_from, :string, default: 'solidus@example.com'
         | 
| 194 194 |  | 
| 195 195 | 
             
                # @!attribute [rw] max_level_in_taxons_menu
         | 
| 196 196 | 
             
                #   @return [Integer] maximum nesting level in taxons menu (default: +1+)
         | 
    
        data/lib/spree/core.rb
    CHANGED
    
    | @@ -90,11 +90,8 @@ require 'spree/core/state_machines' | |
| 90 90 | 
             
            require 'spree/core/stock_configuration'
         | 
| 91 91 | 
             
            require 'spree/core/validators/email'
         | 
| 92 92 | 
             
            require 'spree/permission_sets'
         | 
| 93 | 
            +
            require 'spree/user_class_handle'
         | 
| 93 94 |  | 
| 94 95 | 
             
            require 'spree/preferences/store'
         | 
| 95 96 | 
             
            require 'spree/preferences/static_model_preferences'
         | 
| 96 97 | 
             
            require 'spree/preferences/scoped_store'
         | 
| 97 | 
            -
             | 
| 98 | 
            -
            if Rails.gem_version >= Gem::Version.new('6.1.0.alpha')
         | 
| 99 | 
            -
              require 'spree/awesome_nested_set_override'
         | 
| 100 | 
            -
            end
         | 
    
        data/lib/spree/core/engine.rb
    CHANGED
    
    | @@ -86,19 +86,18 @@ module Spree | |
| 86 86 | 
             
                        Spree::Config.use_legacy_address_state_validator set to true has been
         | 
| 87 87 | 
             
                        deprecated and will be removed in Solidus 3.0. The Spree::Address state
         | 
| 88 88 | 
             
                        validation has been extracted into a configurable external class.
         | 
| 89 | 
            -
                        Switch Spree::Config.use_legacy_address_state_validator to  | 
| 89 | 
            +
                        Switch Spree::Config.use_legacy_address_state_validator to false to start
         | 
| 90 90 | 
             
                        using the external validation class.
         | 
| 91 91 | 
             
                      DEPRECATION
         | 
| 92 92 | 
             
                    end
         | 
| 93 | 
            -
                  end
         | 
| 94 93 |  | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
                    initializer "spree.mailer_previews" do
         | 
| 94 | 
            +
                    # Load in mailer previews for apps to use in development.
         | 
| 95 | 
            +
                    # We need to make sure we call `Preview.all` before requiring our
         | 
| 96 | 
            +
                    # previews, otherwise any previews the app attempts to add need to be
         | 
| 97 | 
            +
                    # manually required.
         | 
| 98 | 
            +
                    if Rails.env.development? || Rails.env.test?
         | 
| 101 99 | 
             
                      ActionMailer::Preview.all
         | 
| 100 | 
            +
             | 
| 102 101 | 
             
                      Dir[root.join("lib/spree/mailer_previews/**/*_preview.rb")].each do |file|
         | 
| 103 102 | 
             
                        require_dependency file
         | 
| 104 103 | 
             
                      end
         |