spree_core 2.1.7 → 2.1.8

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
  SHA1:
3
- metadata.gz: ee66832489cf763d21c38a512e8b99392c104dba
4
- data.tar.gz: 9e34bc2957303933d3b7ba62d043d27daac480c4
3
+ metadata.gz: 43818b70db72f063df0a2ca6ec5a814bbee08e32
4
+ data.tar.gz: f8cc6b3a6c23d6f8cef08b16a11cda8ef76041f6
5
5
  SHA512:
6
- metadata.gz: 9afb43b63ff91f6293536c6c3ab9bb451d8fefb01ab318e7efb401e1934b3e814a8796f53463271ad9a8f5d9588e53c748adce20ce89012dcbf1b4e8be0c2ec2
7
- data.tar.gz: a845cd6990e60b712c0fa99e630ebe2b5c46d6abe7181e9e8f5508b4d8feb7f0f7c13736ff717fd258ecb749cfe8e5761bd963a3b3d5d1b3ef5881e9c740388a
6
+ metadata.gz: 7ca9edf26cea41ea8f52c020206da785cc243c808f2b1c6647310b2f44d23d661f9c18380b3eb4804162852bd5bdc6faec6bbb1c1bc751cc103dbef34bae5c89
7
+ data.tar.gz: a7da9a9569a87f7a6025d1ca7c837a3bb2bfb7c458daccfdce8ca5c914c0e6b5f3e480c09e9cc574b3ce5ecfb54512f590b9eb129ded0a4f15298bcbf4aa8021
@@ -120,7 +120,7 @@ module Spree
120
120
  countries.collect do |country|
121
121
  country.name = Spree.t(country.iso, scope: 'country_names', default: country.name)
122
122
  country
123
- end.sort { |a, b| a.name.parameterize <=> b.name.parameterize }
123
+ end.sort_by { |c| c.name.parameterize }
124
124
  end
125
125
 
126
126
  def seo_url(taxon)
@@ -34,9 +34,10 @@ module Spree
34
34
  elsif match = expiry.match(/(\d{2})(\d{2,4})/) # will match mmyy and mmyyyy
35
35
  [match[1], match[2]]
36
36
  end
37
-
38
- self[:year] = "20" + self[:year] if self[:year].length == 2
39
- self[:year] = self[:year].to_i
37
+ if self[:year]
38
+ self[:year] = "20" + self[:year] if self[:year].length == 2
39
+ self[:year] = self[:year].to_i
40
+ end
40
41
  self[:month] = self[:month].to_i
41
42
  end
42
43
 
@@ -125,9 +126,13 @@ module Spree
125
126
 
126
127
  def expiry_not_in_the_past
127
128
  if year.present? && month.present?
128
- time = "#{year}-#{month}-1".to_time
129
- if time < Time.zone.now.to_time.beginning_of_month
130
- errors.add(:base, :card_expired)
129
+ if month.to_i < 1 || month.to_i > 12
130
+ errors.add(:base, :expiry_invalid)
131
+ else
132
+ time = Time.zone.parse("#{year}-#{month}-1")
133
+ if time < Time.zone.now.to_time.beginning_of_month
134
+ errors.add(:base, :card_expired)
135
+ end
131
136
  end
132
137
  end
133
138
  end
@@ -67,6 +67,7 @@ module Spree
67
67
 
68
68
  validates :email, presence: true, if: :require_email
69
69
  validates :email, email: true, if: :require_email, allow_blank: true
70
+ validates :number, uniqueness: true
70
71
  validate :has_available_shipment
71
72
  validate :has_available_payment
72
73
 
@@ -257,15 +258,11 @@ module Spree
257
258
  end
258
259
  end
259
260
 
260
- # FIXME refactor this method and implement validation using validates_* utilities
261
261
  def generate_order_number
262
- record = true
263
- while record
262
+ self.number ||= loop do
264
263
  random = "R#{Array.new(9){rand(9)}.join}"
265
- record = self.class.where(number: random).first
264
+ break random unless self.class.exists?(number: random)
266
265
  end
267
- self.number = random if self.number.blank?
268
- self.number
269
266
  end
270
267
 
271
268
  def shipped_shipments
@@ -83,7 +83,7 @@ module Spree
83
83
  case amount
84
84
  when String
85
85
  separator = I18n.t('number.currency.format.separator')
86
- number = amount.delete("^0-9-#{separator}").tr(separator, '.')
86
+ number = amount.delete("^0-9-#{separator}\.").tr(separator, '.')
87
87
  number.to_d if number.present?
88
88
  end || amount
89
89
  end
@@ -67,12 +67,12 @@ module Spree
67
67
  # All zoneables belonging to the zone members. Will be a collection of either
68
68
  # countries or states depending on the zone type.
69
69
  def zoneables
70
- members.collect(&:zoneable)
70
+ members.includes(:zoneable).collect(&:zoneable)
71
71
  end
72
72
 
73
73
  def country_ids
74
74
  if kind == 'country'
75
- members.collect(&:zoneable_id)
75
+ members.pluck(:zoneable_id)
76
76
  else
77
77
  []
78
78
  end
@@ -80,7 +80,7 @@ module Spree
80
80
 
81
81
  def state_ids
82
82
  if kind == 'state'
83
- members.collect(&:zoneable_id)
83
+ members.pluck(:zoneable_id)
84
84
  else
85
85
  []
86
86
  end
@@ -117,9 +117,9 @@ module Spree
117
117
  return false if zone_members.empty? || target.zone_members.empty?
118
118
 
119
119
  if kind == target.kind
120
- return false if target.zoneables.any? { |target_zoneable| zoneables.exclude?(target_zoneable) }
120
+ return false if (target.zoneables.collect(&:id) - zoneables.collect(&:id)).present?
121
121
  else
122
- return false if target.zoneables.any? { |target_state| zoneables.exclude?(target_state.country) }
122
+ return false if (target.zoneables.collect(&:country).collect(&:id) - zoneables.collect(&:id)).present?
123
123
  end
124
124
  true
125
125
  end
@@ -225,6 +225,7 @@ en:
225
225
  attributes:
226
226
  base:
227
227
  card_expired: "Card has expired"
228
+ expiry_invalid: "Card expiration is invalid"
228
229
  devise:
229
230
  confirmations:
230
231
  confirmed: Your account was successfully confirmed. You are now signed in.
@@ -383,6 +384,7 @@ en:
383
384
  back_to_prototypes_list: Back To Prototypes List
384
385
  back_to_reports_list: Back To Reports List
385
386
  back_to_shipping_categories: Back To Shipping Categories
387
+ back_to_shipping_categories_list: Back To Shipping Categories List
386
388
  back_to_shipping_methods_list: Back To Shipping Methods List
387
389
  back_to_states_list: Back To States List
388
390
  back_to_stock_locations_list: Back to Stock Locations List
@@ -2,8 +2,12 @@ module Spree
2
2
  class ProductDuplicator
3
3
  attr_accessor :product
4
4
 
5
- def initialize(product)
5
+ @@clone_images_default = true
6
+ mattr_accessor :clone_images_default
7
+
8
+ def initialize(product, include_images = @@clone_images_default)
6
9
  @product = product
10
+ @include_images = include_images
7
11
  end
8
12
 
9
13
  def duplicate
@@ -39,7 +43,7 @@ module Spree
39
43
  master.dup.tap do |new_master|
40
44
  new_master.sku = "COPY OF #{master.sku}"
41
45
  new_master.deleted_at = nil
42
- new_master.images = master.images.map { |image| duplicate_image image }
46
+ new_master.images = master.images.map { |image| duplicate_image image } if @include_images
43
47
  new_master.price = master.price
44
48
  new_master.currency = master.currency
45
49
  end
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- "2.1.7"
3
+ "2.1.8"
4
4
  end
5
5
  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: 2.1.7
4
+ version: 2.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-15 00:00:00.000000000 Z
11
+ date: 2014-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.42.3
19
+ version: 1.43.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.42.3
26
+ version: 1.43.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: acts_as_list
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -212,14 +212,14 @@ dependencies:
212
212
  requirements:
213
213
  - - "~>"
214
214
  - !ruby/object:Gem::Version
215
- version: 4.0.3
215
+ version: 4.0.5
216
216
  type: :runtime
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
- version: 4.0.3
222
+ version: 4.0.5
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: ransack
225
225
  requirement: !ruby/object:Gem::Requirement
@@ -678,7 +678,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
678
678
  version: '0'
679
679
  requirements: []
680
680
  rubyforge_project:
681
- rubygems_version: 2.2.0
681
+ rubygems_version: 2.2.2
682
682
  signing_key:
683
683
  specification_version: 4
684
684
  summary: The bare bones necessary for Spree.