spree_core 2.1.5 → 2.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 729f9d4f394bb9bbd17cf7dbb7142ae574a9183e
4
- data.tar.gz: ae2d1dcd731873c1ae6523bf46a1eb6a63db882e
3
+ metadata.gz: b4c8f9444abee12730e46a75f58276b4a89a54ce
4
+ data.tar.gz: 02d28150421a8deb02c47a16a514ceea6e6775ce
5
5
  SHA512:
6
- metadata.gz: d3527af7dec8d2acdf7736713929387e3c099fa6776227640bd9089d2a5814da0c0f41eb54a822e5b80662f9f41126aeea5f155b82c2bfbe8d3b6ba331737b2a
7
- data.tar.gz: 238f664949e01954bf25eb9cf8cb14f1a5236b615100c8961d0ee445d9e712022e1527e19ce3ce27c1082751128d2b9f99cf2d6ee8108b5b6452108fedeab6d3
6
+ metadata.gz: 94c500d3cba6d3c9388d64f5304dd43391ecd9fc8aabf0c694cec4f3678f7e808039e7dd082aa932623ddfbf200c1e3ca525e34861fc82a2302650f09c0db57e
7
+ data.tar.gz: 81aa93fc583a3eefaeea0804812ad174ecd359b4a1445f030a1ab40e54fb1290c8c9c570099b2e5ad5f8e12d46a0c91fda2a0682a07735a1883051a5c5da0276
@@ -4,12 +4,12 @@ module Spree
4
4
  # that we can use configurations as well as make it easier for end users to override this determination. One idea is
5
5
  # to show the most popular products for a particular taxon (that is an exercise left to the developer.)
6
6
  def taxon_preview(taxon, max=4)
7
- products = taxon.active_products.limit(max)
7
+ products = taxon.active_products.limit(max).uniq
8
8
  if (products.size < max)
9
+ products_arel = Spree::Product.arel_table
9
10
  taxon.descendants.each do |taxon|
10
11
  to_get = max - products.length
11
- products += taxon.active_products.limit(to_get)
12
- products = products.uniq
12
+ products += taxon.active_products.where(products_arel[:id].not_in(products.map(&:id))).limit(to_get).uniq
13
13
  break if products.size >= max
14
14
  end
15
15
  end
@@ -508,7 +508,7 @@ module Spree
508
508
  # to delivery again so that proper updated shipments are created.
509
509
  # e.g. customer goes back from payment step and changes order items
510
510
  def ensure_updated_shipments
511
- if shipments.any?
511
+ if shipments.any? && !self.completed?
512
512
  self.shipments.destroy_all
513
513
  restart_checkout_flow
514
514
  end
@@ -93,7 +93,7 @@ module Spree
93
93
  end
94
94
 
95
95
  def credit_allowed
96
- amount - offsets_total
96
+ amount - offsets_total.abs
97
97
  end
98
98
 
99
99
  def can_credit?
@@ -131,8 +131,11 @@ module Spree
131
131
  !!deleted_at
132
132
  end
133
133
 
134
+ # determine if product is available.
135
+ # deleted products and products with nil or future available_on date
136
+ # are not available
134
137
  def available?
135
- !(available_on.nil? || available_on.future?)
138
+ !(available_on.nil? || available_on.future?) && !deleted?
136
139
  end
137
140
 
138
141
  # split variants list into hash which shows mapping of opt value onto matching variants
@@ -83,7 +83,7 @@ module Spree
83
83
 
84
84
  def adjusted_credits_count(order)
85
85
  return credits_count if order.nil?
86
- credits_count - (order.promotion_credit_exists?(self) ? 1 : 0)
86
+ credits_count - (exists_on_order?(order) ? 1 : 0)
87
87
  end
88
88
 
89
89
  def credits
@@ -97,5 +97,9 @@ module Spree
97
97
  def code=(coupon_code)
98
98
  write_attribute(:code, (coupon_code.downcase.strip rescue nil))
99
99
  end
100
+
101
+ def exists_on_order?(order)
102
+ actions.any? { |a| a.credit_exists_on_order?(order) }
103
+ end
100
104
  end
101
105
  end
@@ -17,7 +17,7 @@ module Spree
17
17
  # through options hash
18
18
  def perform(options = {})
19
19
  order = options[:order]
20
- return if order.promotion_credit_exists?(self)
20
+ return if credit_exists_on_order?(order)
21
21
 
22
22
  self.create_adjustment("#{Spree.t(:promotion)} (#{promotion.name})", order, order)
23
23
  end
@@ -13,5 +13,9 @@ module Spree
13
13
  def perform(options = {})
14
14
  raise 'perform should be implemented in a sub-class of PromotionAction'
15
15
  end
16
+
17
+ def credit_exists_on_order?(order)
18
+ !!order.promotion_credit_exists?(self)
19
+ end
16
20
  end
17
21
  end
@@ -1,14 +1,15 @@
1
1
  module Spree
2
2
  class ShippingMethod < ActiveRecord::Base
3
+ acts_as_paranoid
3
4
  include Spree::Core::CalculatedAdjustments
4
5
  DISPLAY = [:both, :front_end, :back_end]
5
6
 
6
7
  default_scope -> { where(deleted_at: nil) }
7
8
 
8
- has_many :shipments
9
9
  has_many :shipping_method_categories, :dependent => :destroy
10
10
  has_many :shipping_categories, through: :shipping_method_categories
11
11
  has_many :shipping_rates, inverse_of: :shipping_method
12
+ has_many :shipments, :through => :shipping_rates
12
13
 
13
14
  has_and_belongs_to_many :zones, :join_table => 'spree_shipping_methods_zones',
14
15
  :class_name => 'Spree::Zone',
@@ -3,11 +3,6 @@ module Spree
3
3
  belongs_to :shipment, class_name: 'Spree::Shipment'
4
4
  belongs_to :shipping_method, class_name: 'Spree::ShippingMethod', inverse_of: :shipping_rates
5
5
 
6
- scope :with_shipping_method,
7
- -> { includes(:shipping_method).
8
- references(:shipping_method).
9
- order("cost ASC") }
10
-
11
6
  delegate :order, :currency, to: :shipment
12
7
  delegate :name, to: :shipping_method
13
8
 
@@ -182,6 +182,9 @@ en:
182
182
  spree/state:
183
183
  one: State
184
184
  other: States
185
+ spree/stock_movement:
186
+ one: Stock Movement
187
+ other: Stock Movements
185
188
  spree/stock_location:
186
189
  one: Stock Location
187
190
  other: Stock Locations
@@ -5,11 +5,11 @@ class CreateDefaultStock < ActiveRecord::Migration
5
5
  location = Spree::StockLocation.new(name: 'default')
6
6
  location.save(validate: false)
7
7
 
8
- Spree::Variant.all.each do |variant|
8
+ Spree::Variant.find_each do |variant|
9
9
  stock_item = Spree::StockItem.unscoped.build(stock_location: location, variant: variant)
10
10
  stock_item.send(:count_on_hand=, variant.count_on_hand)
11
11
  # Avoid running default_scope defined by acts_as_paranoid, related to #3805,
12
- # validations would run a query with a delete_at column tha might not be present yet
12
+ # validations would run a query with a delete_at column that might not be present yet
13
13
  stock_item.save! validate: false
14
14
  end
15
15
 
@@ -19,7 +19,7 @@ class CreateDefaultStock < ActiveRecord::Migration
19
19
  def down
20
20
  add_column :spree_variants, :count_on_hand, :integer
21
21
 
22
- Spree::StockItem.all.each do |stock_item|
22
+ Spree::StockItem.find_each do |stock_item|
23
23
  stock_item.variant.update_column :count_on_hand, stock_item.count_on_hand
24
24
  end
25
25
 
@@ -1,10 +1,10 @@
1
1
  class UpdateAdjustmentStates < ActiveRecord::Migration
2
2
  def up
3
- Spree::Order.complete.each do |order|
3
+ Spree::Order.complete.find_each do |order|
4
4
  order.adjustments.update_all(:state => 'closed')
5
5
  end
6
6
 
7
- Spree::Shipment.shipped.each do |shipment|
7
+ Spree::Shipment.shipped.includes(:adjustment).find_each do |shipment|
8
8
  shipment.adjustment.update_column(:state, 'finalized') if shipment.adjustment
9
9
  end
10
10
 
@@ -1,6 +1,6 @@
1
1
  class AddShippingRatesToShipments < ActiveRecord::Migration
2
2
  def up
3
- Spree::Shipment.all.each do |shipment|
3
+ Spree::Shipment.find_each do |shipment|
4
4
  shipment.shipping_rates.create(:shipping_method_id => shipment.shipping_method_id,
5
5
  :cost => shipment.cost,
6
6
  :selected => true)
@@ -6,7 +6,7 @@ class AddNumberToStockTransfer < ActiveRecord::Migration
6
6
  rename_column :spree_stock_transfers, :reference_number, :reference
7
7
  add_column :spree_stock_transfers, :number, :string
8
8
 
9
- Spree::StockTransfer.all.each do |transfer|
9
+ Spree::StockTransfer.find_each do |transfer|
10
10
  transfer.send(:generate_stock_transfer_number)
11
11
  transfer.save!
12
12
  end
@@ -1,12 +1,10 @@
1
1
  class MigrateTaxCategoriesToLineItems < ActiveRecord::Migration
2
2
  def change
3
- Spree::LineItem.includes(:variant => { :product => :tax_category }).find_in_batches do |line_items|
4
- line_items.each do |line_item|
5
- next if line_item.variant.nil?
6
- next if line_item.variant.product.nil?
7
- next if line_item.product.nil?
8
- line_item.update_column(:tax_category_id, line_item.product.tax_category_id)
9
- end
3
+ Spree::LineItem.find_each do |line_item|
4
+ next if line_item.variant.nil?
5
+ next if line_item.variant.product.nil?
6
+ next if line_item.product.nil?
7
+ line_item.update_column(:tax_category_id, line_item.product.tax_category_id)
10
8
  end
11
9
  end
12
10
  end
@@ -74,7 +74,7 @@ module Spree
74
74
  end
75
75
 
76
76
  def ip_address
77
- request.env['HTTP_X_REAL_IP'] || request.env['REMOTE_ADDR']
77
+ request.remote_ip
78
78
  end
79
79
  end
80
80
  end
@@ -49,7 +49,7 @@ module Spree
49
49
  new_variant = variant.dup
50
50
  new_variant.sku = "COPY OF #{new_variant.sku}"
51
51
  new_variant.deleted_at = nil
52
- new_variant.option_values = variant.option_values.map { |option_value| option_value.dup}
52
+ new_variant.option_values = variant.option_values.map { |option_value| option_value}
53
53
  new_variant
54
54
  end
55
55
 
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- "2.1.5"
3
+ "2.1.6"
4
4
  end
5
5
  end
@@ -4,7 +4,9 @@ FactoryGirl.define do
4
4
  name 'UPS Ground'
5
5
 
6
6
  before(:create) do |shipping_method, evaluator|
7
- shipping_method.shipping_categories << (Spree::ShippingCategory.first || create(:shipping_category))
7
+ if shipping_method.shipping_categories.empty?
8
+ shipping_method.shipping_categories << (Spree::ShippingCategory.first || create(:shipping_category))
9
+ end
8
10
  end
9
11
 
10
12
  factory :shipping_method, class: Spree::ShippingMethod do
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.5
4
+ version: 2.1.6
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-02-18 00:00:00.000000000 Z
11
+ date: 2014-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -198,14 +198,14 @@ dependencies:
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: 4.0.0
201
+ version: 4.0.3
202
202
  type: :runtime
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: 4.0.0
208
+ version: 4.0.3
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: ransack
211
211
  requirement: !ruby/object:Gem::Requirement
@@ -663,7 +663,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
663
663
  version: '0'
664
664
  requirements: []
665
665
  rubyforge_project:
666
- rubygems_version: 2.2.0
666
+ rubygems_version: 2.2.2
667
667
  signing_key:
668
668
  specification_version: 4
669
669
  summary: The bare bones necessary for Spree.