spree_core 4.1.3 → 4.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cba2996dac2e758ba562efcfc4e1bf1f99c873bcb0af1e878ce372339c86263e
4
- data.tar.gz: 1404bec2819dc8872517d3d19a5f5faa2683e5b7c3265e4afeeaad6ff7f8476c
3
+ metadata.gz: 14259887630a60331633df140cfe4f7b9e94b9ecdf95342c5e8a31011dbfb807
4
+ data.tar.gz: 2801ca34a2ad369726b829ea9e3decf00ae64c9fcc4cc673cf04e0dc0aa826c5
5
5
  SHA512:
6
- metadata.gz: 628cdea24cd029809e4e1d1861ffa5ac90e2de240f5b779d1cfa02e9d9c3728a8f251092ae345e741bd56d060aeecc71d9a8716e0c276a488065dc7169cb04af
7
- data.tar.gz: 38ff19725ca382a75cc8735285be96d7f786832c86f36db0f8b1164b3914a280c57502df22db8c8e82f1fb84039b5f574454934a1596182a4a312f7355877118
6
+ metadata.gz: f644cd935bca9d371a3a558ffe76994143bc8af738ac9ff8621a778eef743d79339b3f5bda697e84a287c51e12e235bac989c500dd4923ca08f52a89ba8d80ac
7
+ data.tar.gz: 62203be51964aa4ccd9ea69a5e5fd47ea7408c6028e257a5c30a7769de7178127aecef002305731f58d5e676bd209c15b776d182246f23dc07a4a0679801d5d3
@@ -8,7 +8,7 @@ module Spree
8
8
  @skus = String(params.dig(:filter, :skus)).split(',')
9
9
  @price = String(params.dig(:filter, :price)).split(',').map(&:to_f)
10
10
  @currency = params[:currency] || current_currency
11
- @taxons = String(params.dig(:filter, :taxons)).split(',')
11
+ @taxons = taxon_ids(params.dig(:filter, :taxons))
12
12
  @name = params.dig(:filter, :name)
13
13
  @options = params.dig(:filter, :options).try(:to_unsafe_hash)
14
14
  @option_value_ids = params.dig(:filter, :option_value_ids)
@@ -159,6 +159,12 @@ module Spree
159
159
  def include_discontinued(products)
160
160
  discontinued ? products : products.available
161
161
  end
162
+
163
+ def taxon_ids(taxon_id)
164
+ return unless (taxon = Spree::Taxon.find_by(id: taxon_id))
165
+
166
+ taxon.self_and_descendants.ids.map(&:to_s)
167
+ end
162
168
  end
163
169
  end
164
170
  end
@@ -136,6 +136,10 @@ module Spree
136
136
  [I18n.locale, current_currency]
137
137
  end
138
138
 
139
+ def maximum_quantity
140
+ Spree::DatabaseTypeUtilities.maximum_value_for(:integer)
141
+ end
142
+
139
143
  private
140
144
 
141
145
  def create_product_image_tag(image, product, options, style)
@@ -17,7 +17,14 @@ module Spree
17
17
  before_validation :copy_tax_category
18
18
 
19
19
  validates :variant, :order, presence: true
20
- validates :quantity, numericality: { only_integer: true, message: Spree.t('validation.must_be_int') }
20
+
21
+ # numericality: :less_than_or_equal_to validation is due to the restriction at the database level
22
+ # https://github.com/spree/spree/issues/2695#issuecomment-143314161
23
+ validates :quantity, numericality: {
24
+ less_than_or_equal_to: DatabaseTypeUtilities.maximum_value_for(:integer),
25
+ only_integer: true, message: Spree.t('validation.must_be_int')
26
+ }
27
+
21
28
  validates :price, numericality: true
22
29
 
23
30
  validates_with Spree::Stock::AvailabilityValidator
@@ -71,8 +71,8 @@ module Spree
71
71
  end
72
72
 
73
73
  def kind
74
- if kind?
75
- super
74
+ if self[:kind].present?
75
+ self[:kind]
76
76
  else
77
77
  not_nil_scope = members.where.not(zoneable_type: nil)
78
78
  zone_type = not_nil_scope.order('created_at ASC').pluck(:zoneable_type).last
@@ -93,6 +93,7 @@ require 'spree/money'
93
93
  require 'spree/permitted_attributes'
94
94
  require 'spree/service_module'
95
95
  require 'spree/dependencies_helper'
96
+ require 'spree/database_type_utilities'
96
97
 
97
98
  require 'spree/core/importer'
98
99
  require 'spree/core/query_filters'
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- '4.1.3'
3
+ '4.1.4'
4
4
  end
5
5
  end
@@ -0,0 +1,12 @@
1
+ module Spree
2
+ module DatabaseTypeUtilities
3
+ def self.maximum_value_for(data_type)
4
+ case data_type
5
+ when :integer
6
+ ActiveModel::Type::Integer.new.instance_eval { range.max }
7
+ else
8
+ raise ArgumentError, 'Currently only :integer argument is acceptable'
9
+ end
10
+ end
11
+ end
12
+ end
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: 4.1.3
4
+ version: 4.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-31 00:00:00.000000000 Z
11
+ date: 2020-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -997,6 +997,7 @@ files:
997
997
  - lib/spree/core/search/base.rb
998
998
  - lib/spree/core/token_generator.rb
999
999
  - lib/spree/core/version.rb
1000
+ - lib/spree/database_type_utilities.rb
1000
1001
  - lib/spree/dependencies_helper.rb
1001
1002
  - lib/spree/i18n.rb
1002
1003
  - lib/spree/i18n/base.rb