Merge pull request #7147 from Matt-Yorkley/deprecations-2

Deprecations 2
This commit is contained in:
Andy Brett
2021-03-22 17:28:11 -07:00
committed by GitHub
4 changed files with 9 additions and 8 deletions

View File

@@ -52,11 +52,11 @@ module Spree
dependent: :destroy
has_many :variants, -> {
where(is_master: false).order("#{::Spree::Variant.quoted_table_name}.position ASC")
where(is_master: false).order("spree_variants.position ASC")
}, class_name: 'Spree::Variant'
has_many :variants_including_master,
-> { order("#{::Spree::Variant.quoted_table_name}.position ASC") },
-> { order("spree_variants.position ASC") },
class_name: 'Spree::Variant',
dependent: :destroy
@@ -90,7 +90,7 @@ module Spree
validates :supplier, presence: true
validates :primary_taxon, presence: true
validates :tax_category_id, presence: true, if: "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

@@ -109,12 +109,13 @@ module Spree
}
scope :not_hidden_for, lambda { |enterprise|
return where("1=0") if enterprise.blank?
enterprise_id = enterprise&.id.to_i
return none if enterprise_id < 1
joins("
LEFT OUTER JOIN (SELECT *
FROM inventory_items
WHERE enterprise_id = #{sanitize enterprise.andand.id})
WHERE enterprise_id = #{enterprise_id})
AS o_inventory_items
ON o_inventory_items.variant_id = spree_variants.id")
.where("o_inventory_items.id IS NULL OR o_inventory_items.visible = (?)", true)

View File

@@ -222,7 +222,7 @@ describe Spree::Preferences::Preferable do
describe "persisted preferables" do
before(:all) do
class CreatePrefTest < ActiveRecord::Migration
class CreatePrefTest < ActiveRecord::Migration[4.2]
def self.up
create_table :pref_tests do |t|
t.string :col

View File

@@ -88,13 +88,13 @@ module Spree
describe 'Variants sorting' do
context 'without master variant' do
it 'sorts variants by position' do
expect(product.variants.to_sql).to match(/ORDER BY (\`|\")spree_variants(\`|\").position ASC/)
expect(product.variants.to_sql).to match(/ORDER BY spree_variants.position ASC/)
end
end
context 'with master variant' do
it 'sorts variants by position' do
expect(product.variants_including_master.to_sql).to match(/ORDER BY (\`|\")spree_variants(\`|\").position ASC/)
expect(product.variants_including_master.to_sql).to match(/ORDER BY spree_variants.position ASC/)
end
end
end