spree_core 2.0.4 → 2.0.5
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 +4 -4
- data/app/mailers/spree/test_mailer.rb +2 -1
- data/app/models/spree/adjustment.rb +18 -7
- data/app/models/spree/alert.rb +1 -1
- data/app/models/spree/credit_card.rb +2 -2
- data/app/models/spree/inventory_unit.rb +5 -0
- data/app/models/spree/line_item.rb +18 -4
- data/app/models/spree/order/checkout.rb +10 -14
- data/app/models/spree/order.rb +39 -27
- data/app/models/spree/order_contents.rb +2 -2
- data/app/models/spree/order_inventory.rb +2 -9
- data/app/models/spree/order_updater.rb +18 -7
- data/app/models/spree/payment/processing.rb +102 -102
- data/app/models/spree/payment.rb +10 -9
- data/app/models/spree/preferences/store.rb +1 -1
- data/app/models/spree/product.rb +11 -2
- data/app/models/spree/promotion/rules/user.rb +7 -2
- data/app/models/spree/property.rb +1 -1
- data/app/models/spree/shipment.rb +12 -7
- data/app/models/spree/shipping_method.rb +1 -1
- data/app/models/spree/stock/availability_validator.rb +9 -1
- data/app/models/spree/stock/coordinator.rb +1 -3
- data/app/models/spree/stock/estimator.rb +1 -1
- data/app/models/spree/stock/packer.rb +13 -5
- data/app/models/spree/stock_item.rb +10 -1
- data/app/models/spree/stock_location.rb +1 -1
- data/app/models/spree/tax_rate.rb +3 -1
- data/app/models/spree/zone.rb +37 -1
- data/app/views/spree/test_mailer/test_email.text.erb +4 -0
- data/config/locales/en.yml +24 -1
- data/db/default/spree/roles.rb +2 -2
- data/db/migrate/20130213191427_create_default_stock.rb +2 -1
- data/db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb +1 -1
- data/db/migrate/20130806022521_drop_spree_mail_methods.rb +12 -0
- data/db/migrate/20130806145853_set_default_stock_location_on_shipments.rb +8 -0
- data/db/migrate/20130809164245_add_admin_name_column_to_spree_shipping_methods.rb +5 -0
- data/db/migrate/20130809164330_add_admin_name_column_to_spree_stock_locations.rb +5 -0
- data/db/migrate/20130813140619_expand_order_number_size.rb +9 -0
- data/db/migrate/20130826062534_add_depth_to_spree_taxons.rb +16 -0
- data/db/migrate/20130915032339_add_deleted_at_to_spree_stock_items.rb +5 -0
- data/lib/generators/spree/dummy/templates/rails/database.yml +0 -3
- data/lib/spree/core/engine.rb +1 -5
- data/lib/spree/core/permalinks.rb +4 -2
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/promo/coupon_applicator.rb +2 -2
- data/lib/spree/testing_support/capybara_ext.rb +2 -2
- data/lib/spree/testing_support/factories/order_factory.rb +8 -4
- metadata +17 -12
- data/app/models/spree/new_adjustment.rb +0 -4
- data/app/models/spree/shipping_adjustment.rb +0 -4
- data/db/migrate/20130805043440_create_spree_new_adjustments.rb +0 -8
data/app/models/spree/payment.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
module Spree
|
2
2
|
class Payment < ActiveRecord::Base
|
3
3
|
include Spree::Payment::Processing
|
4
|
+
|
5
|
+
IDENTIFIER_CHARS = (('A'..'Z').to_a + ('0'..'9').to_a - %w(0 1 I O)).freeze
|
6
|
+
|
4
7
|
belongs_to :order, class_name: 'Spree::Order'
|
5
8
|
belongs_to :source, polymorphic: true
|
6
9
|
belongs_to :payment_method, class_name: 'Spree::PaymentMethod'
|
@@ -144,15 +147,13 @@ module Spree
|
|
144
147
|
# and this is it. Related to #1998.
|
145
148
|
# See https://github.com/spree/spree/issues/1998#issuecomment-12869105
|
146
149
|
def set_unique_identifier
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
self.identifier = identifier
|
155
|
-
end
|
150
|
+
begin
|
151
|
+
self.identifier = generate_identifier
|
152
|
+
end while self.class.exists?(identifier: self.identifier)
|
153
|
+
end
|
154
|
+
|
155
|
+
def generate_identifier
|
156
|
+
Array.new(8){ IDENTIFIER_CHARS.sample }.join
|
156
157
|
end
|
157
158
|
end
|
158
159
|
end
|
data/app/models/spree/product.rb
CHANGED
@@ -106,6 +106,8 @@ module Spree
|
|
106
106
|
|
107
107
|
after_initialize :ensure_master
|
108
108
|
|
109
|
+
before_destroy :punch_permalink
|
110
|
+
|
109
111
|
def variants_with_only_master
|
110
112
|
ActiveSupport::Deprecation.warn("[SPREE] Spree::Product#variants_with_only_master will be deprecated in Spree 1.3. Please use Spree::Product#master instead.")
|
111
113
|
master
|
@@ -169,8 +171,11 @@ module Spree
|
|
169
171
|
end
|
170
172
|
|
171
173
|
def self.like_any(fields, values)
|
172
|
-
|
173
|
-
|
174
|
+
where fields.map { |field|
|
175
|
+
values.map { |value|
|
176
|
+
arel_table[field].matches("%#{value}%")
|
177
|
+
}.inject(:or)
|
178
|
+
}.inject(:or)
|
174
179
|
end
|
175
180
|
|
176
181
|
# Suitable for displaying only variants that has at least one option value.
|
@@ -262,6 +267,10 @@ module Spree
|
|
262
267
|
return unless new_record?
|
263
268
|
self.master ||= Variant.new
|
264
269
|
end
|
270
|
+
|
271
|
+
def punch_permalink
|
272
|
+
update_attribute :permalink, "#{Time.now.to_i}_#{permalink}" # punch permalink with date prefix
|
273
|
+
end
|
265
274
|
end
|
266
275
|
end
|
267
276
|
|
@@ -4,8 +4,13 @@ module Spree
|
|
4
4
|
class User < PromotionRule
|
5
5
|
attr_accessible :user_ids_string
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
if Spree.user_class
|
8
|
+
belongs_to :user, class_name: Spree.user_class.to_s
|
9
|
+
has_and_belongs_to_many :users, class_name: Spree.user_class.to_s, join_table: 'spree_promotion_rules_users', foreign_key: 'promotion_rule_id'
|
10
|
+
else
|
11
|
+
belongs_to :user
|
12
|
+
has_and_belongs_to_many :users, join_table: 'spree_promotion_rules_users', foreign_key: 'promotion_rule_id'
|
13
|
+
end
|
9
14
|
|
10
15
|
def eligible?(order, options = {})
|
11
16
|
users.include?(order.user)
|
@@ -2,7 +2,7 @@ module Spree
|
|
2
2
|
class Property < ActiveRecord::Base
|
3
3
|
has_and_belongs_to_many :prototypes, join_table: 'spree_properties_prototypes'
|
4
4
|
|
5
|
-
has_many :product_properties, dependent: :
|
5
|
+
has_many :product_properties, dependent: :delete_all
|
6
6
|
has_many :products, through: :product_properties
|
7
7
|
|
8
8
|
attr_accessible :name, :presentation
|
@@ -6,10 +6,10 @@ module Spree
|
|
6
6
|
belongs_to :address, class_name: 'Spree::Address'
|
7
7
|
belongs_to :stock_location, class_name: 'Spree::StockLocation'
|
8
8
|
|
9
|
-
has_many :shipping_rates, dependent: :
|
9
|
+
has_many :shipping_rates, dependent: :delete_all
|
10
10
|
has_many :shipping_methods, through: :shipping_rates
|
11
11
|
has_many :state_changes, as: :stateful
|
12
|
-
has_many :inventory_units, dependent: :
|
12
|
+
has_many :inventory_units, dependent: :delete_all
|
13
13
|
has_one :adjustment, as: :source, dependent: :destroy
|
14
14
|
|
15
15
|
before_create :generate_shipment_number
|
@@ -105,13 +105,11 @@ module Spree
|
|
105
105
|
def refresh_rates
|
106
106
|
return shipping_rates if shipped?
|
107
107
|
|
108
|
-
shipping_method_id = shipping_method.try(:id)
|
109
108
|
self.shipping_rates = Stock::Estimator.new(order).shipping_rates(to_package)
|
110
109
|
|
111
|
-
|
112
|
-
if shipping_method_id
|
110
|
+
if shipping_method
|
113
111
|
selected_rate = shipping_rates.detect { |rate|
|
114
|
-
rate.shipping_method_id ==
|
112
|
+
rate.shipping_method_id == shipping_method.id
|
115
113
|
}
|
116
114
|
self.selected_shipping_rate_id = selected_rate.id if selected_rate
|
117
115
|
end
|
@@ -158,7 +156,7 @@ module Spree
|
|
158
156
|
end
|
159
157
|
|
160
158
|
def manifest
|
161
|
-
inventory_units.includes(:variant).group_by(&:variant).map do |variant, units|
|
159
|
+
inventory_units.joins(:variant).includes(:variant).group_by(&:variant).map do |variant, units|
|
162
160
|
states = {}
|
163
161
|
units.group_by(&:state).each { |state, iu| states[state] = iu.count }
|
164
162
|
OpenStruct.new(variant: variant, quantity: units.length, states: states)
|
@@ -229,6 +227,13 @@ module Spree
|
|
229
227
|
package
|
230
228
|
end
|
231
229
|
|
230
|
+
def set_up_inventory(state, variant, order)
|
231
|
+
self.inventory_units.create(
|
232
|
+
{ variant_id: variant.id, state: state, order_id: order.id },
|
233
|
+
without_protection: true
|
234
|
+
)
|
235
|
+
end
|
236
|
+
|
232
237
|
private
|
233
238
|
|
234
239
|
def manifest_unstock(item)
|
@@ -14,7 +14,7 @@ module Spree
|
|
14
14
|
:class_name => 'Spree::Zone',
|
15
15
|
:foreign_key => 'shipping_method_id'
|
16
16
|
|
17
|
-
attr_accessible :name, :zones, :display_on, :shipping_category_id,
|
17
|
+
attr_accessible :name, :admin_name, :zones, :display_on, :shipping_category_id,
|
18
18
|
:match_none, :match_one, :match_all, :tracking_url
|
19
19
|
|
20
20
|
validates :name, presence: true
|
@@ -2,9 +2,17 @@ module Spree
|
|
2
2
|
module Stock
|
3
3
|
class AvailabilityValidator < ActiveModel::Validator
|
4
4
|
def validate(line_item)
|
5
|
+
if shipment = line_item.target_shipment
|
6
|
+
units = shipment.inventory_units_for(line_item.variant)
|
7
|
+
return if units.count > line_item.quantity
|
8
|
+
quantity = line_item.quantity - units.count
|
9
|
+
else
|
10
|
+
quantity = line_item.quantity
|
11
|
+
end
|
12
|
+
|
5
13
|
quantifier = Stock::Quantifier.new(line_item.variant_id)
|
6
14
|
|
7
|
-
unless quantifier.can_supply?
|
15
|
+
unless quantifier.can_supply? quantity
|
8
16
|
variant = line_item.variant
|
9
17
|
display_name = %Q{#{variant.name}}
|
10
18
|
display_name += %Q{ (#{variant.options_text})} unless variant.options_text.blank?
|
@@ -24,9 +24,7 @@ module Spree
|
|
24
24
|
# Returns an array of Package instances
|
25
25
|
def build_packages(packages = Array.new)
|
26
26
|
StockLocation.active.each do |stock_location|
|
27
|
-
next unless order.line_items.
|
28
|
-
stock_location.stock_item(item.variant)
|
29
|
-
end
|
27
|
+
next unless stock_location.stock_items.where(:variant_id => order.line_items.pluck(:variant_id)).exists?
|
30
28
|
|
31
29
|
packer = build_packer(stock_location, order)
|
32
30
|
packages += packer.packages
|
@@ -15,7 +15,7 @@ module Spree
|
|
15
15
|
|
16
16
|
shipping_methods.each do |shipping_method|
|
17
17
|
cost = calculate_cost(shipping_method, package)
|
18
|
-
shipping_rates << shipping_method.shipping_rates.new(:cost => cost)
|
18
|
+
shipping_rates << shipping_method.shipping_rates.new(:cost => cost) unless cost.nil?
|
19
19
|
end
|
20
20
|
|
21
21
|
shipping_rates.sort_by! { |r| r.cost || 0 }
|
@@ -10,17 +10,25 @@ module Spree
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def packages
|
13
|
-
|
13
|
+
if splitters.empty?
|
14
|
+
[default_package]
|
15
|
+
else
|
16
|
+
build_splitter.split [default_package]
|
17
|
+
end
|
14
18
|
end
|
15
19
|
|
16
20
|
def default_package
|
17
21
|
package = Package.new(stock_location, order)
|
18
22
|
order.line_items.each do |line_item|
|
19
|
-
|
23
|
+
if Config.track_inventory_levels
|
24
|
+
next unless stock_location.stock_item(line_item.variant)
|
20
25
|
|
21
|
-
|
22
|
-
|
23
|
-
|
26
|
+
on_hand, backordered = stock_location.fill_status(line_item.variant, line_item.quantity)
|
27
|
+
package.add line_item.variant, on_hand, :on_hand if on_hand > 0
|
28
|
+
package.add line_item.variant, backordered, :backordered if backordered > 0
|
29
|
+
else
|
30
|
+
package.add line_item.variant, line_item.quantity, :on_hand
|
31
|
+
end
|
24
32
|
end
|
25
33
|
package
|
26
34
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
module Spree
|
2
2
|
class StockItem < ActiveRecord::Base
|
3
|
+
acts_as_paranoid
|
4
|
+
|
3
5
|
belongs_to :stock_location, class_name: 'Spree::StockLocation'
|
4
6
|
belongs_to :variant, class_name: 'Spree::Variant'
|
5
|
-
has_many :stock_movements
|
7
|
+
has_many :stock_movements
|
6
8
|
|
7
9
|
validates_presence_of :stock_location, :variant
|
8
10
|
validates_uniqueness_of :variant_id, scope: :stock_location_id
|
@@ -28,6 +30,13 @@ module Spree
|
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
33
|
+
def set_count_on_hand(value)
|
34
|
+
self.count_on_hand = value
|
35
|
+
process_backorders if in_stock?
|
36
|
+
|
37
|
+
self.save!
|
38
|
+
end
|
39
|
+
|
31
40
|
def in_stock?
|
32
41
|
self.count_on_hand > 0
|
33
42
|
end
|
@@ -10,7 +10,7 @@ module Spree
|
|
10
10
|
|
11
11
|
attr_accessible :name, :active, :address1, :address2, :city, :zipcode,
|
12
12
|
:backorderable_default, :state_name, :state_id, :country_id, :phone,
|
13
|
-
:country_id, :propagate_all_variants
|
13
|
+
:country_id, :propagate_all_variants, :admin_name
|
14
14
|
|
15
15
|
scope :active, -> { where(active: true) }
|
16
16
|
|
@@ -33,7 +33,9 @@ module Spree
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.adjust(order)
|
36
|
-
order.
|
36
|
+
order.adjustments.tax.destroy_all
|
37
|
+
order.line_item_adjustments.where(originator_type: 'Spree::TaxRate').destroy_all
|
38
|
+
|
37
39
|
self.match(order).each do |rate|
|
38
40
|
rate.adjust(order)
|
39
41
|
end
|
data/app/models/spree/zone.rb
CHANGED
@@ -14,7 +14,7 @@ module Spree
|
|
14
14
|
accepts_nested_attributes_for :zone_members, allow_destroy: true, reject_if: proc { |a| a['zoneable_id'].blank? }
|
15
15
|
|
16
16
|
attr_accessible :name, :description, :default_tax, :kind, :zone_members,
|
17
|
-
:zone_members_attributes
|
17
|
+
:zone_members_attributes, :state_ids, :country_ids
|
18
18
|
|
19
19
|
def kind
|
20
20
|
if members.any? && !members.any? { |member| member.try(:zoneable_type).nil? }
|
@@ -75,6 +75,42 @@ module Spree
|
|
75
75
|
members.collect(&:zoneable)
|
76
76
|
end
|
77
77
|
|
78
|
+
def country_ids
|
79
|
+
if kind == 'country'
|
80
|
+
members.collect(&:zoneable_id)
|
81
|
+
else
|
82
|
+
[]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def state_ids
|
87
|
+
if kind == 'state'
|
88
|
+
members.collect(&:zoneable_id)
|
89
|
+
else
|
90
|
+
[]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def country_ids=(ids)
|
95
|
+
zone_members.destroy_all
|
96
|
+
ids.reject{ |id| id.blank? }.map do |id|
|
97
|
+
member = ZoneMember.new
|
98
|
+
member.zoneable_type = 'Spree::Country'
|
99
|
+
member.zoneable_id = id
|
100
|
+
members << member
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def state_ids=(ids)
|
105
|
+
zone_members.destroy_all
|
106
|
+
ids.reject{ |id| id.blank? }.map do |id|
|
107
|
+
member = ZoneMember.new
|
108
|
+
member.zoneable_type = 'Spree::State'
|
109
|
+
member.zoneable_id = id
|
110
|
+
members << member
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
78
114
|
def self.default_tax
|
79
115
|
where(default_tax: true).first
|
80
116
|
end
|
data/config/locales/en.yml
CHANGED
@@ -63,6 +63,7 @@ en:
|
|
63
63
|
zipcode: Shipping address zipcode
|
64
64
|
spree/payment:
|
65
65
|
amount: Amount
|
66
|
+
one: "Payment"
|
66
67
|
spree/payment_method:
|
67
68
|
name: Name
|
68
69
|
spree/product:
|
@@ -148,9 +149,15 @@ en:
|
|
148
149
|
spree/payment:
|
149
150
|
one: Payment
|
150
151
|
other: Payments
|
152
|
+
spree/payment_method:
|
153
|
+
one: Payment Method
|
154
|
+
other: Payment Methods
|
151
155
|
spree/product:
|
152
156
|
one: Product
|
153
157
|
other: Products
|
158
|
+
spree/promotion:
|
159
|
+
one: Promotion
|
160
|
+
other: Promotions
|
154
161
|
spree/property:
|
155
162
|
one: Property
|
156
163
|
other: Properties
|
@@ -169,9 +176,18 @@ en:
|
|
169
176
|
spree/shipping_category:
|
170
177
|
one: Shipping Category
|
171
178
|
other: Shipping Categories
|
179
|
+
spree/shipping_method:
|
180
|
+
one: Shipping Method
|
181
|
+
other: Shipping Methods
|
172
182
|
spree/state:
|
173
183
|
one: State
|
174
184
|
other: States
|
185
|
+
spree/stock_location:
|
186
|
+
one: Stock Location
|
187
|
+
other: Stock Locations
|
188
|
+
spree/stock_transfer:
|
189
|
+
one: Stock Transfer
|
190
|
+
other: Stock Transfers
|
175
191
|
spree/tax_category:
|
176
192
|
one: Tax Category
|
177
193
|
other: Tax Categories
|
@@ -184,6 +200,9 @@ en:
|
|
184
200
|
spree/taxonomy:
|
185
201
|
one: Taxonomy
|
186
202
|
other: Taxonomies
|
203
|
+
spree/tracker:
|
204
|
+
one: Tracker
|
205
|
+
other: Trackers
|
187
206
|
spree/user:
|
188
207
|
one: User
|
189
208
|
other: Users
|
@@ -360,6 +379,7 @@ en:
|
|
360
379
|
back_to_users_list: Back To Users List
|
361
380
|
back_to_zones_list: Back To Zones List
|
362
381
|
backorderable: Backorderable
|
382
|
+
backorders_allowed: backorders allowed
|
363
383
|
balance_due: Balance Due
|
364
384
|
bill_address: Bill Address
|
365
385
|
billing: Billing
|
@@ -454,6 +474,7 @@ en:
|
|
454
474
|
date: Date
|
455
475
|
date_completed: Date Completed
|
456
476
|
date_picker:
|
477
|
+
first_day: 0
|
457
478
|
format: ! '%Y/%m/%d'
|
458
479
|
js_format: yy/mm/dd
|
459
480
|
date_range: Date Range
|
@@ -575,6 +596,7 @@ en:
|
|
575
596
|
insufficient_stock: Insufficient stock available, only %{on_hand} remaining
|
576
597
|
intercept_email_address: Intercept Email Address
|
577
598
|
intercept_email_instructions: Override email recipient and replace with this address.
|
599
|
+
internal_name: Internal Name
|
578
600
|
invalid_payment_provider: Invalid payment provider.
|
579
601
|
invalid_promotion_action: Invalid promotion action.
|
580
602
|
invalid_promotion_rule: Invalid promotion rule.
|
@@ -590,7 +612,7 @@ en:
|
|
590
612
|
operators:
|
591
613
|
gt: greater than
|
592
614
|
gte: greater than or equal to
|
593
|
-
items_cannot_be_shipped: We are unable to
|
615
|
+
items_cannot_be_shipped: We are unable to calculate shipping rates for the selected items.
|
594
616
|
jirafe: Jirafe
|
595
617
|
landing_page_rule:
|
596
618
|
path: Path
|
@@ -674,6 +696,7 @@ en:
|
|
674
696
|
no_promotions_found: No promotions found
|
675
697
|
no_results: No results
|
676
698
|
no_rules_added: No rules added
|
699
|
+
no_resource_found: ! 'No %{resource} found'
|
677
700
|
no_shipping_methods_found: No shipping methods found
|
678
701
|
no_trackers_found: No Trackers Found
|
679
702
|
no_stock_locations_found: No stock locations found
|
data/db/default/spree/roles.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
Spree::Role.
|
2
|
-
Spree::Role.
|
1
|
+
Spree::Role.where(:name => "admin").first_or_create
|
2
|
+
Spree::Role.where(:name => "user").first_or_create
|
@@ -2,7 +2,8 @@ class CreateDefaultStock < ActiveRecord::Migration
|
|
2
2
|
def up
|
3
3
|
Spree::StockLocation.skip_callback(:create, :after, :create_stock_items)
|
4
4
|
Spree::StockItem.skip_callback(:save, :after, :process_backorders)
|
5
|
-
location = Spree::StockLocation.
|
5
|
+
location = Spree::StockLocation.new(name: 'default')
|
6
|
+
location.save(validate: false)
|
6
7
|
Spree::Variant.all.each do |variant|
|
7
8
|
stock_item = location.stock_items.build(variant: variant)
|
8
9
|
stock_item.send(:count_on_hand=, variant.count_on_hand)
|
@@ -2,7 +2,7 @@ class MigrateTaxCategoriesToLineItems < ActiveRecord::Migration
|
|
2
2
|
def change
|
3
3
|
Spree::LineItem.includes(:variant => { :product => :tax_category }).find_in_batches do |line_items|
|
4
4
|
line_items.each do |line_item|
|
5
|
-
line_item.update_column(:tax_category_id, line_item.product.
|
5
|
+
line_item.update_column(:tax_category_id, line_item.product.tax_category_id)
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class SetDefaultStockLocationOnShipments < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
if Spree::Shipment.where('stock_location_id IS NULL').count > 0
|
4
|
+
location = Spree::StockLocation.find_by_name('default') || Spree::StockLocation.first
|
5
|
+
Spree::Shipment.where('stock_location_id IS NULL').update_all(stock_location_id: location.id)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class AddDepthToSpreeTaxons < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
if !Spree::Taxon.column_names.include?('depth')
|
4
|
+
add_column :spree_taxons, :depth, :integer
|
5
|
+
|
6
|
+
say_with_time 'Update depth on all taxons' do
|
7
|
+
Spree::Taxon.reset_column_information
|
8
|
+
Spree::Taxon.all.each { |t| t.save }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def down
|
14
|
+
remove_column :spree_taxons, :depth
|
15
|
+
end
|
16
|
+
end
|
@@ -17,17 +17,14 @@ production:
|
|
17
17
|
development:
|
18
18
|
adapter: mysql2
|
19
19
|
database: <%= database_prefix %>spree_development
|
20
|
-
username:
|
21
20
|
encoding: utf8
|
22
21
|
test:
|
23
22
|
adapter: mysql2
|
24
23
|
database: <%= database_prefix %>spree_test
|
25
|
-
username:
|
26
24
|
encoding: utf8
|
27
25
|
production:
|
28
26
|
adapter: mysql2
|
29
27
|
database: <%= database_prefix %>spree_production
|
30
|
-
username:
|
31
28
|
encoding: utf8
|
32
29
|
<% when 'postgres' %>
|
33
30
|
development:
|
data/lib/spree/core/engine.rb
CHANGED
@@ -86,11 +86,7 @@ module Spree
|
|
86
86
|
]
|
87
87
|
end
|
88
88
|
|
89
|
-
|
90
|
-
# Spree.user_class would be nil and users might experience errors related
|
91
|
-
# to malformed model associations (Spree.user_class is only defined on
|
92
|
-
# the app initializer)
|
93
|
-
config.after_initialize do
|
89
|
+
initializer 'spree.promo.register.promotion.calculators' do
|
94
90
|
Rails.application.config.spree.promotions.rules.concat [
|
95
91
|
Spree::Promotion::Rules::ItemTotal,
|
96
92
|
Spree::Promotion::Rules::Product,
|
@@ -14,8 +14,10 @@ module Spree
|
|
14
14
|
options[:field] ||= :permalink
|
15
15
|
self.permalink_options = options
|
16
16
|
|
17
|
-
if self.
|
18
|
-
|
17
|
+
if self.connected?
|
18
|
+
if self.table_exists? && self.column_names.include?(permalink_options[:field].to_s)
|
19
|
+
before_validation(:on => :create) { save_permalink }
|
20
|
+
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
data/lib/spree/core/version.rb
CHANGED
@@ -32,8 +32,8 @@ module Spree
|
|
32
32
|
return promotion_usage_limit_exceeded if promotion.usage_limit_exceeded?
|
33
33
|
|
34
34
|
event_name = "spree.checkout.coupon_code_added"
|
35
|
-
|
36
|
-
promo = @order.adjustments.promotion.detect { |p| p.originator.promotion.code == @order.coupon_code }
|
35
|
+
promotion.activate(:coupon_code => @order.coupon_code, :order => @order)
|
36
|
+
promo = @order.adjustments.includes(:originator).promotion.detect { |p| p.originator.promotion.code == @order.coupon_code }
|
37
37
|
determine_promotion_application_result(promo)
|
38
38
|
end
|
39
39
|
|
@@ -104,7 +104,7 @@ end
|
|
104
104
|
|
105
105
|
RSpec::Matchers.define :have_meta do |name, expected|
|
106
106
|
match do |actual|
|
107
|
-
has_css?("meta[name='#{name}'][content='#{expected}']")
|
107
|
+
has_css?("meta[name='#{name}'][content='#{expected}']", visible: false)
|
108
108
|
end
|
109
109
|
|
110
110
|
failure_message_for_should do |actual|
|
@@ -119,7 +119,7 @@ end
|
|
119
119
|
|
120
120
|
RSpec::Matchers.define :have_title do |expected|
|
121
121
|
match do |actual|
|
122
|
-
has_css?("title", :text => expected)
|
122
|
+
has_css?("title", :text => expected, visible: false)
|
123
123
|
end
|
124
124
|
|
125
125
|
failure_message_for_should do |actual|
|
@@ -33,14 +33,18 @@ FactoryGirl.define do
|
|
33
33
|
state 'complete'
|
34
34
|
completed_at { Time.now }
|
35
35
|
|
36
|
+
after(:create) do |order|
|
37
|
+
order.refresh_shipment_rates
|
38
|
+
end
|
39
|
+
|
36
40
|
factory :order_ready_to_ship do
|
37
41
|
payment_state 'paid'
|
38
42
|
shipment_state 'ready'
|
39
43
|
after(:create) do |order|
|
40
44
|
create(:payment, amount: order.total, order: order, state: 'completed')
|
41
45
|
order.shipments.each do |shipment|
|
42
|
-
shipment.inventory_units.each { |u| u.
|
43
|
-
shipment.
|
46
|
+
shipment.inventory_units.each { |u| u.update_column('state', 'on_hand') }
|
47
|
+
shipment.update_column('state', 'ready')
|
44
48
|
end
|
45
49
|
order.reload
|
46
50
|
end
|
@@ -49,8 +53,8 @@ FactoryGirl.define do
|
|
49
53
|
factory :shipped_order do
|
50
54
|
after(:create) do |order|
|
51
55
|
order.shipments.each do |shipment|
|
52
|
-
shipment.inventory_units.each { |u| u.
|
53
|
-
shipment.
|
56
|
+
shipment.inventory_units.each { |u| u.update_column('state', 'shipped') }
|
57
|
+
shipment.update_column('state', 'shipped')
|
54
58
|
end
|
55
59
|
order.reload
|
56
60
|
end
|