Merge pull request #7138 from luisramos0/rails52commits

Rails52commits
This commit is contained in:
Andy Brett
2021-03-22 18:13:01 -07:00
committed by GitHub
8 changed files with 20 additions and 14 deletions

View File

@@ -16,8 +16,8 @@ class OrderCycle < ActiveRecord::Base
has_many :suppliers, -> { distinct }, source: :sender, through: :cached_incoming_exchanges
has_many :distributors, -> { distinct }, source: :receiver, through: :cached_outgoing_exchanges
has_many :schedules, through: :order_cycle_schedules
has_many :order_cycle_schedules
has_many :schedules, through: :order_cycle_schedules
has_paper_trail meta: { custom_data: proc { |order_cycle| order_cycle.schedule_ids.to_s } }
attr_accessor :incoming_exchanges, :outgoing_exchanges

View File

@@ -1,9 +1,8 @@
class Schedule < ActiveRecord::Base
has_paper_trail meta: { custom_data: proc { |schedule| schedule.order_cycle_ids.to_s } }
has_many :order_cycles, through: :order_cycle_schedules
has_many :order_cycle_schedules, dependent: :destroy
has_many :order_cycles, through: :order_cycle_schedules
has_many :coordinators, -> { uniq }, through: :order_cycles
scope :with_coordinator, lambda { |enterprise| joins(:order_cycles).where('coordinator_id = ?', enterprise.id).select('DISTINCT schedules.*') }

View File

@@ -152,7 +152,9 @@ module Spree
end
def touch_enterprise
enterprise.andand.touch
return unless enterprise&.persisted?
enterprise.touch
end
def render_address(parts)

View File

@@ -42,16 +42,16 @@ module Spree
as: :adjustable,
dependent: :destroy
has_many :line_item_adjustments, through: :line_items, source: :adjustments
has_many :shipment_adjustments, through: :shipments, source: :adjustments
has_many :all_adjustments, class_name: 'Spree::Adjustment', dependent: :destroy
has_many :shipments, dependent: :destroy do
def states
pluck(:state).uniq
end
end
has_many :line_item_adjustments, through: :line_items, source: :adjustments
has_many :shipment_adjustments, through: :shipments, source: :adjustments
has_many :all_adjustments, class_name: 'Spree::Adjustment', dependent: :destroy
belongs_to :order_cycle
belongs_to :distributor, class_name: 'Enterprise'
belongs_to :customer

View File

@@ -90,7 +90,8 @@ module Spree
validates :supplier, presence: true
validates :primary_taxon, presence: true
validates :tax_category_id, presence: true, if: proc { Spree::Config[:products_require_tax_category] }
validates :tax_category_id, presence: true,
if: proc { Spree::Config[:products_require_tax_category] }
validates :variant_unit, presence: true
validates :unit_value, presence: { if: ->(p) { %w(weight volume).include? p.variant_unit } }

View File

@@ -10,10 +10,10 @@ module Spree
default_scope -> { where(deleted_at: nil) }
has_many :shipping_rates, inverse_of: :shipping_method
has_many :shipments, through: :shipping_rates
has_many :shipping_method_categories
has_many :shipping_categories, through: :shipping_method_categories
has_many :shipping_rates, inverse_of: :shipping_method
has_many :distributor_shipping_methods
has_many :distributors, through: :distributor_shipping_methods,
class_name: 'Enterprise',

View File

@@ -1,3 +1,7 @@
# frozen_string_literal: true
require 'spree/localized_number'
class VariantOverride < ActiveRecord::Base
extend Spree::LocalizedNumber
include StockSettingsOverrideValidation

View File

@@ -47,9 +47,9 @@ module ControllerRequestsHelper
def process_action_with_route(action, params = {}, session = nil, flash = nil, method = "GET")
process(action,
method,
params.reverse_merge!(use_route: :main_app),
session,
flash)
method: method,
params: params.reverse_merge!(use_route: :main_app),
session: session,
flash: flash)
end
end