spree_core 2.1.2 → 2.1.3
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/assets/images/logo/spree_50.png +0 -0
- data/app/helpers/spree/base_helper.rb +1 -1
- data/app/models/spree/adjustment.rb +6 -2
- data/app/models/spree/app_configuration.rb +1 -0
- data/app/models/spree/credit_card.rb +26 -14
- data/app/models/spree/gateway/bogus_simple.rb +8 -0
- data/app/models/spree/option_type.rb +1 -0
- data/app/models/spree/order/checkout.rb +9 -3
- data/app/models/spree/order.rb +1 -11
- data/app/models/spree/order_inventory.rb +7 -3
- data/app/models/spree/order_updater.rb +5 -11
- data/app/models/spree/payment/processing.rb +4 -3
- data/app/models/spree/product.rb +6 -1
- data/app/models/spree/promotion/rules/user.rb +1 -1
- data/app/models/spree/shipment.rb +7 -10
- data/app/models/spree/tax_rate.rb +29 -3
- data/app/models/spree/taxon.rb +10 -1
- data/app/views/spree/payments/_payment.html.erb +3 -1
- data/config/initializers/user_class_extensions.rb +0 -1
- data/config/locales/en.yml +10 -0
- data/db/migrate/20131113035136_add_channel_to_spree_orders.rb +5 -0
- data/db/migrate/20131118041203_add_tax_total_to_spree_orders.rb +5 -0
- data/db/migrate/20131118043021_add_order_id_to_spree_adjustments.rb +6 -0
- data/db/migrate/20131118074808_add_included_to_spree_adjustments.rb +5 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +3 -4
- data/lib/spree/money.rb +1 -0
- data/lib/spree/permitted_attributes.rb +7 -3
- data/lib/spree/testing_support/capybara_ext.rb +11 -3
- data/lib/spree/testing_support/controller_requests.rb +2 -2
- metadata +26 -24
- data/lib/spree/core/ext/active_record.rb +0 -8
- data/lib/spree/core/user_banners.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8194bdbcc2f3d26d2662205e0deed23ed0bf800
|
4
|
+
data.tar.gz: 232ddcdb7e3b3b8cb25b1029f77015331b2b7043
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da652bb0512643d231a1826e0af01ea36fffc76b2b9f91bffe1ada65133b6ec8d2a6c365f38d88235209db209565816dc44fbfc5868f79dd1b7a111a5c9cc2de
|
7
|
+
data.tar.gz: 9db7c280e5907596695bdb35b9098611ff778b27cbb5fc8f10ca789b3cf86bc7e0aeeda0e6a62b01dc01da7d0fc88ba23ca74a193c301bec105f5f4bfe7805cd
|
Binary file
|
@@ -117,7 +117,7 @@ module Spree
|
|
117
117
|
countries.collect do |country|
|
118
118
|
country.name = Spree.t(country.iso, scope: 'country_names', default: country.name)
|
119
119
|
country
|
120
|
-
end.sort { |a, b| a.name <=> b.name }
|
120
|
+
end.sort { |a, b| a.name.parameterize <=> b.name.parameterize }
|
121
121
|
end
|
122
122
|
|
123
123
|
def seo_url(taxon)
|
@@ -27,6 +27,7 @@ module Spree
|
|
27
27
|
belongs_to :adjustable, polymorphic: true
|
28
28
|
belongs_to :source, polymorphic: true
|
29
29
|
belongs_to :originator, polymorphic: true
|
30
|
+
belongs_to :order, :class_name => 'Spree::Order'
|
30
31
|
|
31
32
|
validates :label, presence: true
|
32
33
|
validates :amount, numericality: true
|
@@ -48,7 +49,7 @@ module Spree
|
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
51
|
-
scope :tax, -> { where(originator_type: 'Spree::TaxRate'
|
52
|
+
scope :tax, -> { where(originator_type: 'Spree::TaxRate') }
|
52
53
|
scope :price, -> { where(adjustable_type: 'Spree::LineItem') }
|
53
54
|
scope :shipping, -> { where(originator_type: 'Spree::ShippingMethod') }
|
54
55
|
scope :optional, -> { where(mandatory: false) }
|
@@ -58,6 +59,8 @@ module Spree
|
|
58
59
|
scope :promotion, -> { where(originator_type: 'Spree::PromotionAction') }
|
59
60
|
scope :manual, -> { where(originator_type: nil) }
|
60
61
|
scope :return_authorization, -> { where(source_type: "Spree::ReturnAuthorization") }
|
62
|
+
scope :included, -> { where(included: true) }
|
63
|
+
scope :additional, -> { where(included: false) }
|
61
64
|
|
62
65
|
def promotion?
|
63
66
|
originator_type == 'Spree::PromotionAction'
|
@@ -97,7 +100,8 @@ module Spree
|
|
97
100
|
# If we attempt to call 'source' before the reload, then source is currently
|
98
101
|
# the order object. After calling a reload, the source is the Shipment.
|
99
102
|
reload
|
100
|
-
|
103
|
+
calculable = source unless calculable == source
|
104
|
+
originator.update_adjustment(self, calculable) if originator.present?
|
101
105
|
set_eligibility
|
102
106
|
end
|
103
107
|
|
@@ -41,6 +41,7 @@ module Spree
|
|
41
41
|
preference :currency, :string, default: "USD"
|
42
42
|
preference :currency_decimal_mark, :string, default: "."
|
43
43
|
preference :currency_symbol_position, :string, default: "before"
|
44
|
+
preference :currency_sign_before_symbol, :boolean, default: true
|
44
45
|
preference :currency_thousands_separator, :string, default: ","
|
45
46
|
preference :display_currency, :boolean, default: false
|
46
47
|
preference :default_country_id, :integer
|
@@ -6,7 +6,7 @@ module Spree
|
|
6
6
|
|
7
7
|
attr_accessor :number, :verification_value
|
8
8
|
|
9
|
-
validates :month, :year, numericality: { only_integer: true }
|
9
|
+
validates :month, :year, numericality: { only_integer: true }, unless: :has_payment_profile?
|
10
10
|
validates :number, presence: true, unless: :has_payment_profile?, on: :create
|
11
11
|
validates :verification_value, presence: true, unless: :has_payment_profile?, on: :create
|
12
12
|
validate :expiry_not_in_the_past
|
@@ -16,9 +16,20 @@ module Spree
|
|
16
16
|
# needed for some of the ActiveMerchant gateways (eg. SagePay)
|
17
17
|
alias_attribute :brand, :cc_type
|
18
18
|
|
19
|
+
CARD_TYPES = {
|
20
|
+
visa: /^4[0-9]{12}(?:[0-9]{3})?$/,
|
21
|
+
master: /(^5[1-5][0-9]{14}$)|(^6759[0-9]{2}([0-9]{10})$)|(^6759[0-9]{2}([0-9]{12})$)|(^6759[0-9]{2}([0-9]{13})$)/,
|
22
|
+
diners_club: /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
|
23
|
+
american_express: /^3[47][0-9]{13}$/,
|
24
|
+
discover: /^6(?:011|5[0-9]{2})[0-9]{12}$/,
|
25
|
+
jcb: /^(?:2131|1800|35\d{3})\d{11}$/
|
26
|
+
}
|
27
|
+
|
19
28
|
def expiry=(expiry)
|
20
|
-
|
21
|
-
|
29
|
+
if expiry.present?
|
30
|
+
self[:month], self[:year] = expiry.delete(' ').split('/')
|
31
|
+
self[:year] = "20" + self[:year] if self[:year].length == 2
|
32
|
+
end
|
22
33
|
end
|
23
34
|
|
24
35
|
def number=(num)
|
@@ -28,17 +39,13 @@ module Spree
|
|
28
39
|
# cc_type is set by jquery.payment, which helpfully provides different
|
29
40
|
# types from Active Merchant. Converting them is necessary.
|
30
41
|
def cc_type=(type)
|
31
|
-
|
32
|
-
when 'mastercard', 'maestro'
|
33
|
-
|
34
|
-
when '
|
35
|
-
|
36
|
-
|
37
|
-
'diners_club'
|
38
|
-
else
|
39
|
-
type
|
42
|
+
self[:cc_type] = case type
|
43
|
+
when 'mastercard', 'maestro' then 'master'
|
44
|
+
when 'amex' then 'american_express'
|
45
|
+
when 'dinersclub' then 'diners_club'
|
46
|
+
when '' then try_type_from_number
|
47
|
+
else type
|
40
48
|
end
|
41
|
-
self[:cc_type] = real_type
|
42
49
|
end
|
43
50
|
|
44
51
|
def set_last_digits
|
@@ -47,6 +54,11 @@ module Spree
|
|
47
54
|
self.last_digits ||= number.to_s.length <= 4 ? number : number.to_s.slice(-4..-1)
|
48
55
|
end
|
49
56
|
|
57
|
+
def try_type_from_number
|
58
|
+
numbers = number.delete(' ') if number
|
59
|
+
CARD_TYPES.find{|type, pattern| return type.to_s if numbers =~ pattern}.to_s
|
60
|
+
end
|
61
|
+
|
50
62
|
def name?
|
51
63
|
first_name? && last_name?
|
52
64
|
end
|
@@ -87,7 +99,7 @@ module Spree
|
|
87
99
|
end
|
88
100
|
|
89
101
|
def has_payment_profile?
|
90
|
-
gateway_customer_profile_id.present?
|
102
|
+
gateway_customer_profile_id.present? || gateway_payment_profile_id.present?
|
91
103
|
end
|
92
104
|
|
93
105
|
def to_active_merchant
|
@@ -6,6 +6,14 @@ module Spree
|
|
6
6
|
false
|
7
7
|
end
|
8
8
|
|
9
|
+
def capture(money, response_code, options = {})
|
10
|
+
if response_code == '12345'
|
11
|
+
ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, :test => true, :authorization => '67890')
|
12
|
+
else
|
13
|
+
ActiveMerchant::Billing::Response.new(false, 'Bogus Gateway: Forced failure', :error => 'Bogus Gateway: Forced failure', :test => true)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
9
17
|
def authorize(money, credit_card, options = {})
|
10
18
|
if VALID_CCS.include? credit_card.number
|
11
19
|
ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, :test => true, :authorization => '12345', :avs_result => { :code => 'A' })
|
@@ -2,6 +2,7 @@ module Spree
|
|
2
2
|
class OptionType < ActiveRecord::Base
|
3
3
|
has_many :option_values, -> { order(:position) }, dependent: :destroy
|
4
4
|
has_many :product_option_types, dependent: :destroy
|
5
|
+
has_many :products, through: :product_option_types
|
5
6
|
has_and_belongs_to_many :prototypes, join_table: 'spree_option_types_prototypes'
|
6
7
|
|
7
8
|
validates :name, :presentation, presence: true
|
@@ -42,8 +42,14 @@ module Spree
|
|
42
42
|
klass.next_event_transitions.each { |t| transition(t.merge(:on => :next)) }
|
43
43
|
|
44
44
|
# Persist the state on the order
|
45
|
-
after_transition do |order|
|
45
|
+
after_transition do |order, transition|
|
46
46
|
order.state = order.state
|
47
|
+
order.state_changes.create(
|
48
|
+
previous_state: transition.from,
|
49
|
+
next_state: transition.to,
|
50
|
+
name: 'order',
|
51
|
+
user_id: order.user_id
|
52
|
+
)
|
47
53
|
order.save
|
48
54
|
end
|
49
55
|
|
@@ -160,7 +166,7 @@ module Spree
|
|
160
166
|
end
|
161
167
|
|
162
168
|
def has_checkout_step?(step)
|
163
|
-
step.present?
|
169
|
+
step.present? && self.checkout_steps.include?(step)
|
164
170
|
end
|
165
171
|
|
166
172
|
def checkout_step_index(step)
|
@@ -172,7 +178,7 @@ module Spree
|
|
172
178
|
end
|
173
179
|
|
174
180
|
def can_go_to_state?(state)
|
175
|
-
return false unless
|
181
|
+
return false unless has_checkout_step?(self.state) && has_checkout_step?(state)
|
176
182
|
checkout_step_index(state) > checkout_step_index(self.state)
|
177
183
|
end
|
178
184
|
end
|
data/app/models/spree/order.rb
CHANGED
@@ -41,6 +41,7 @@ module Spree
|
|
41
41
|
has_many :return_authorizations, dependent: :destroy
|
42
42
|
has_many :adjustments, -> { order("#{Adjustment.table_name}.created_at ASC") }, as: :adjustable, dependent: :destroy
|
43
43
|
has_many :line_item_adjustments, through: :line_items, source: :adjustments
|
44
|
+
has_many :all_adjustments, class_name: 'Spree::Adjustment'
|
44
45
|
has_many :inventory_units
|
45
46
|
|
46
47
|
has_many :shipments, dependent: :destroy do
|
@@ -283,10 +284,6 @@ module Spree
|
|
283
284
|
adjustments.shipping.sum(:amount)
|
284
285
|
end
|
285
286
|
|
286
|
-
def tax_total
|
287
|
-
adjustments.tax.sum(:amount)
|
288
|
-
end
|
289
|
-
|
290
287
|
# Creates new tax charges if there are any applicable rates. If prices already
|
291
288
|
# include taxes then price adjustments are created instead.
|
292
289
|
def create_tax_charge!
|
@@ -336,13 +333,6 @@ module Spree
|
|
336
333
|
updater.run_hooks
|
337
334
|
|
338
335
|
deliver_order_confirmation_email
|
339
|
-
|
340
|
-
self.state_changes.create(
|
341
|
-
previous_state: 'cart',
|
342
|
-
next_state: 'complete',
|
343
|
-
name: 'order' ,
|
344
|
-
user_id: self.user_id
|
345
|
-
)
|
346
336
|
end
|
347
337
|
|
348
338
|
def deliver_order_confirmation_email
|
@@ -65,10 +65,14 @@ module Spree
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def add_to_shipment(shipment, variant, quantity)
|
68
|
-
|
68
|
+
if Config.track_inventory_levels
|
69
|
+
on_hand, back_order = shipment.stock_location.fill_status(variant, quantity)
|
69
70
|
|
70
|
-
|
71
|
-
|
71
|
+
on_hand.times { shipment.set_up_inventory('on_hand', variant, order) }
|
72
|
+
back_order.times { shipment.set_up_inventory('backordered', variant, order) }
|
73
|
+
else
|
74
|
+
quantity.times { shipment.set_up_inventory('on_hand', variant, order) }
|
75
|
+
end
|
72
76
|
|
73
77
|
# adding to this shipment, and removing from stock_location
|
74
78
|
if order.completed?
|
@@ -25,12 +25,11 @@ module Spree
|
|
25
25
|
update_shipment_state
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
update_shipping_adjustments
|
28
|
+
update_adjustments
|
30
29
|
# update totals a second time in case updated adjustments have an effect on the total
|
31
30
|
update_totals
|
32
31
|
|
33
|
-
order.
|
32
|
+
order.update_columns({
|
34
33
|
payment_state: order.payment_state,
|
35
34
|
shipment_state: order.shipment_state,
|
36
35
|
item_total: order.item_total,
|
@@ -56,6 +55,7 @@ module Spree
|
|
56
55
|
order.payment_total = payments.completed.map(&:amount).sum
|
57
56
|
order.item_total = line_items.map(&:amount).sum
|
58
57
|
order.adjustment_total = adjustments.eligible.map(&:amount).sum
|
58
|
+
order.tax_total = order.all_adjustments.tax.map(&:amount).sum
|
59
59
|
order.total = order.item_total + order.adjustment_total
|
60
60
|
end
|
61
61
|
|
@@ -125,17 +125,11 @@ module Spree
|
|
125
125
|
#
|
126
126
|
# Adjustments will check if they are still eligible. Ineligible adjustments
|
127
127
|
# are preserved but not counted towards adjustment_total.
|
128
|
-
def
|
129
|
-
order.adjustments.reload.
|
128
|
+
def update_adjustments
|
129
|
+
order.adjustments.reload.each { |adjustment| adjustment.update!(order) }
|
130
130
|
choose_best_promotion_adjustment
|
131
131
|
end
|
132
132
|
|
133
|
-
# Shipping adjustments don't receive order on update! because they calculated
|
134
|
-
# over a shipping / package object rather than an order object
|
135
|
-
def update_shipping_adjustments
|
136
|
-
order.adjustments.reload.shipping.each { |adjustment| adjustment.update! }
|
137
|
-
end
|
138
|
-
|
139
133
|
private
|
140
134
|
|
141
135
|
# Picks one (and only one) promotion to be eligible for this order
|
@@ -83,11 +83,12 @@ module Spree
|
|
83
83
|
|
84
84
|
credit_amount ||= credit_allowed >= order.outstanding_balance.abs ? order.outstanding_balance.abs : credit_allowed.abs
|
85
85
|
credit_amount = credit_amount.to_f
|
86
|
+
credit_cents = Spree::Money.new(credit_amount, currency: currency).money.cents
|
86
87
|
|
87
88
|
if payment_method.payment_profiles_supported?
|
88
|
-
response = payment_method.credit(
|
89
|
+
response = payment_method.credit(credit_cents, source, response_code, gateway_options)
|
89
90
|
else
|
90
|
-
response = payment_method.credit(
|
91
|
+
response = payment_method.credit(credit_cents, response_code, gateway_options)
|
91
92
|
end
|
92
93
|
|
93
94
|
record_response(response)
|
@@ -141,7 +142,7 @@ module Spree
|
|
141
142
|
protect_from_connection_error do
|
142
143
|
check_environment
|
143
144
|
|
144
|
-
response = payment_method.send(action,
|
145
|
+
response = payment_method.send(action, money.money.cents,
|
145
146
|
source,
|
146
147
|
gateway_options)
|
147
148
|
handle_response(response, success_state, :failure)
|
data/app/models/spree/product.rb
CHANGED
@@ -173,7 +173,12 @@ module Spree
|
|
173
173
|
|
174
174
|
def set_property(property_name, property_value)
|
175
175
|
ActiveRecord::Base.transaction do
|
176
|
-
|
176
|
+
# Works around spree_i18n #301
|
177
|
+
property = if Property.exists?(name: property_name)
|
178
|
+
Property.where(name: property_name).first
|
179
|
+
else
|
180
|
+
Property.create(name: property_name, presentation: property_name)
|
181
|
+
end
|
177
182
|
product_property = ProductProperty.where(product: self, property: property).first_or_initialize
|
178
183
|
product_property.value = property_value
|
179
184
|
product_property.save!
|
@@ -7,7 +7,7 @@ module Spree
|
|
7
7
|
has_and_belongs_to_many :users, class_name: Spree.user_class.to_s, join_table: 'spree_promotion_rules_users', foreign_key: 'promotion_rule_id'
|
8
8
|
else
|
9
9
|
belongs_to :user
|
10
|
-
has_and_belongs_to_many :users, join_table: 'spree_promotion_rules_users', foreign_key: 'promotion_rule_id'
|
10
|
+
has_and_belongs_to_many :users, join_table: 'spree_promotion_rules_users', foreign_key: 'promotion_rule_id', :class_name => Spree.user_class
|
11
11
|
end
|
12
12
|
|
13
13
|
def eligible?(order, options = {})
|
@@ -64,9 +64,7 @@ module Spree
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def to_param
|
67
|
-
number
|
68
|
-
generate_shipment_number unless number
|
69
|
-
number.to_s.to_url.upcase
|
67
|
+
number
|
70
68
|
end
|
71
69
|
|
72
70
|
def backordered?
|
@@ -102,6 +100,7 @@ module Spree
|
|
102
100
|
|
103
101
|
def refresh_rates
|
104
102
|
return shipping_rates if shipped?
|
103
|
+
return [] unless can_get_rates?
|
105
104
|
|
106
105
|
# StockEstimator.new assigment below will replace the current shipping_method
|
107
106
|
original_shipping_method_id = shipping_method.try(:id)
|
@@ -157,7 +156,7 @@ module Spree
|
|
157
156
|
end
|
158
157
|
|
159
158
|
def manifest
|
160
|
-
inventory_units.
|
159
|
+
inventory_units.group_by(&:variant).map do |variant, units|
|
161
160
|
states = {}
|
162
161
|
units.group_by(&:state).each { |state, iu| states[state] = iu.count }
|
163
162
|
OpenStruct.new(variant: variant, quantity: units.length, states: states)
|
@@ -256,12 +255,6 @@ module Spree
|
|
256
255
|
"#{Spree.t(:shipping)} (#{shipping_method.name})"
|
257
256
|
end
|
258
257
|
|
259
|
-
def validate_shipping_method
|
260
|
-
unless shipping_method.nil?
|
261
|
-
errors.add :shipping_method, Spree.t(:is_not_available_to_shipment_address) unless shipping_method.include?(address)
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
258
|
def after_ship
|
266
259
|
inventory_units.each &:ship!
|
267
260
|
adjustment.finalize!
|
@@ -289,5 +282,9 @@ module Spree
|
|
289
282
|
def update_order
|
290
283
|
order.update!
|
291
284
|
end
|
285
|
+
|
286
|
+
def can_get_rates?
|
287
|
+
order.ship_address && order.ship_address.valid?
|
288
|
+
end
|
292
289
|
end
|
293
290
|
end
|
@@ -26,7 +26,7 @@ module Spree
|
|
26
26
|
return [] unless order.tax_zone
|
27
27
|
all.select do |rate|
|
28
28
|
(!rate.included_in_price && (rate.zone == order.tax_zone || rate.zone.contains?(order.tax_zone) || (order.tax_address.nil? && rate.zone.default_tax))) ||
|
29
|
-
|
29
|
+
rate.included_in_price
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -54,15 +54,31 @@ module Spree
|
|
54
54
|
|
55
55
|
# Creates necessary tax adjustments for the order.
|
56
56
|
def adjust(order)
|
57
|
+
# (rate.included_in_price && !order.tax_address.nil? && !rate.zone.contains?(order.tax_zone) && rate.zone.default_tax)
|
57
58
|
label = create_label
|
58
59
|
if included_in_price
|
59
60
|
if Zone.default_tax.contains? order.tax_zone
|
60
|
-
order.line_items.each
|
61
|
+
order.line_items.each do |line_item|
|
62
|
+
amount = calculator.compute(line_item)
|
63
|
+
unless amount == 0
|
64
|
+
line_item.adjustments.create(
|
65
|
+
order: order,
|
66
|
+
amount: amount,
|
67
|
+
source: line_item,
|
68
|
+
originator: self,
|
69
|
+
label: label,
|
70
|
+
mandatory: false,
|
71
|
+
state: "closed",
|
72
|
+
included: true
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end
|
61
76
|
else
|
62
77
|
amount = -1 * calculator.compute(order)
|
63
78
|
label = Spree.t(:refund) + label
|
64
79
|
|
65
80
|
order.adjustments.create(
|
81
|
+
order: order,
|
66
82
|
amount: amount,
|
67
83
|
source: order,
|
68
84
|
originator: self,
|
@@ -71,7 +87,17 @@ module Spree
|
|
71
87
|
)
|
72
88
|
end
|
73
89
|
else
|
74
|
-
|
90
|
+
amount = calculator.compute(order)
|
91
|
+
unless amount == 0
|
92
|
+
order.adjustments.create(
|
93
|
+
order: order,
|
94
|
+
amount: amount,
|
95
|
+
source: order,
|
96
|
+
originator: self,
|
97
|
+
state: "closed",
|
98
|
+
label: label
|
99
|
+
)
|
100
|
+
end
|
75
101
|
end
|
76
102
|
end
|
77
103
|
|
data/app/models/spree/taxon.rb
CHANGED
@@ -16,7 +16,7 @@ module Spree
|
|
16
16
|
url: '/spree/taxons/:id/:style/:basename.:extension',
|
17
17
|
path: ':rails_root/public/spree/taxons/:id/:style/:basename.:extension',
|
18
18
|
default_url: '/assets/default_taxon.png'
|
19
|
-
|
19
|
+
|
20
20
|
include Spree::Core::S3Support
|
21
21
|
supports_s3 :icon
|
22
22
|
|
@@ -69,5 +69,14 @@ module Spree
|
|
69
69
|
ancestor_chain + "#{name}"
|
70
70
|
end
|
71
71
|
|
72
|
+
# awesome_nested_set sorts by :lft and :rgt. This call re-inserts the child
|
73
|
+
# node so that its resulting position matches the observable 0-indexed position.
|
74
|
+
# ** Note ** no :position column needed - a_n_s doesn't handle the reordering if
|
75
|
+
# you bring your own :order_column.
|
76
|
+
#
|
77
|
+
# See #3390 for background.
|
78
|
+
def child_index=(idx)
|
79
|
+
move_to_child_with_index(parent, idx.to_i)
|
80
|
+
end
|
72
81
|
end
|
73
82
|
end
|
@@ -4,7 +4,9 @@
|
|
4
4
|
<% unless (cc_type = source.cc_type).blank? %>
|
5
5
|
<%= image_tag "credit_cards/icons/#{cc_type}.png" %>
|
6
6
|
<% end %>
|
7
|
-
|
7
|
+
<% if source.last_digits %>
|
8
|
+
<%= Spree.t(:ending_in) %> <%= source.last_digits %>
|
9
|
+
<% end %>
|
8
10
|
</span>
|
9
11
|
<br />
|
10
12
|
<span class="full-name">
|
data/config/locales/en.yml
CHANGED
@@ -646,6 +646,15 @@ en:
|
|
646
646
|
look_for_similar_items: Look for similar items
|
647
647
|
mail_method_settings: Mail Method Settings
|
648
648
|
mail_methods: Mail Methods
|
649
|
+
mail_settings:
|
650
|
+
auth:
|
651
|
+
none: "None"
|
652
|
+
plain: "Plain"
|
653
|
+
login: "Login"
|
654
|
+
cram_md5: "cram_md5"
|
655
|
+
security:
|
656
|
+
ssl: "SSL"
|
657
|
+
tls: "TLS"
|
649
658
|
make_refund: Make refund
|
650
659
|
master_price: Master Price
|
651
660
|
match_choices:
|
@@ -666,6 +675,7 @@ en:
|
|
666
675
|
new: New
|
667
676
|
new_adjustment: New Adjustment
|
668
677
|
new_customer: New Customer
|
678
|
+
new_country: New Country
|
669
679
|
new_image: New Image
|
670
680
|
new_option_type: New Option Type
|
671
681
|
new_order: New Order
|
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/core.rb
CHANGED
@@ -16,9 +16,9 @@ module Spree
|
|
16
16
|
|
17
17
|
def self.user_class
|
18
18
|
if @@user_class.is_a?(Class)
|
19
|
-
raise "Spree.user_class MUST be a String object, not a Class object."
|
20
|
-
elsif @@user_class.is_a?(String)
|
21
|
-
@@user_class.constantize
|
19
|
+
raise "Spree.user_class MUST be a String or Symbol object, not a Class object."
|
20
|
+
elsif @@user_class.is_a?(String) || @@user_class.is_a?(Symbol)
|
21
|
+
@@user_class.to_s.constantize
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -45,7 +45,6 @@ require 'spree/money'
|
|
45
45
|
require 'spree/promo/coupon_applicator'
|
46
46
|
|
47
47
|
require 'spree/core/delegate_belongs_to'
|
48
|
-
require 'spree/core/ext/active_record'
|
49
48
|
require 'spree/core/permalinks'
|
50
49
|
require 'spree/core/token_resource'
|
51
50
|
require 'spree/core/calculated_adjustments'
|
data/lib/spree/money.rb
CHANGED
@@ -14,6 +14,7 @@ module Spree
|
|
14
14
|
@options[:no_cents] = Spree::Config[:hide_cents]
|
15
15
|
@options[:decimal_mark] = Spree::Config[:currency_decimal_mark]
|
16
16
|
@options[:thousands_separator] = Spree::Config[:currency_thousands_separator]
|
17
|
+
@options[:sign_before_symbol] = Spree::Config[:currency_sign_before_symbol]
|
17
18
|
@options.merge!(options)
|
18
19
|
# Must be a symbol because the Money gem doesn't do the conversion
|
19
20
|
@options[:symbol_position] = @options[:symbol_position].to_sym
|
@@ -29,7 +29,10 @@ module Spree
|
|
29
29
|
@@address_attributes = [
|
30
30
|
:firstname, :lastname, :address1, :address2,
|
31
31
|
:city, :country_id, :state_id, :zipcode, :phone,
|
32
|
-
:state_name, :alternative_phone, :company
|
32
|
+
:state_name, :alternative_phone, :company,
|
33
|
+
:country => [:iso, :name, :iso3, :iso_name],
|
34
|
+
:state => [:name, :abbr]
|
35
|
+
]
|
33
36
|
|
34
37
|
@@checkout_attributes = [:email, :use_billing, :shipping_method_id, :coupon_code, :special_instructions]
|
35
38
|
|
@@ -43,7 +46,7 @@ module Spree
|
|
43
46
|
|
44
47
|
@@option_value_attributes = [:name, :presentation]
|
45
48
|
|
46
|
-
@@payment_attributes = [:amount, :payment_method_id]
|
49
|
+
@@payment_attributes = [:amount, :payment_method_id, :payment_method]
|
47
50
|
|
48
51
|
@@product_properties_attributes = [:property_name, :value, :position]
|
49
52
|
|
@@ -65,7 +68,8 @@ module Spree
|
|
65
68
|
# month / year may be provided by some sources, or others may elect to use one field
|
66
69
|
@@source_attributes = [
|
67
70
|
:number, :month, :year, :expiry, :verification_value,
|
68
|
-
:first_name, :last_name, :cc_type
|
71
|
+
:first_name, :last_name, :cc_type, :gateway_customer_profile_id,
|
72
|
+
:gateway_payment_profile_id, :last_digits]
|
69
73
|
|
70
74
|
@@stock_item_attributes = [:variant, :stock_location, :backorderable, :variant_id]
|
71
75
|
|
@@ -13,11 +13,19 @@ module CapybaraExt
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def within_row(num, &block)
|
16
|
-
|
16
|
+
if example.metadata[:js]
|
17
|
+
within("table.index tbody tr:nth-child(#{num})", &block)
|
18
|
+
else
|
19
|
+
within(:xpath, all("table.index tbody tr")[num-1].path, &block)
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
def column_text(num)
|
20
|
-
|
24
|
+
if example.metadata[:js]
|
25
|
+
find("td:nth-child(#{num})").text
|
26
|
+
else
|
27
|
+
all("td")[num-1].text
|
28
|
+
end
|
21
29
|
end
|
22
30
|
|
23
31
|
def set_select2_field(field, value)
|
@@ -94,7 +102,7 @@ module CapybaraExt
|
|
94
102
|
|
95
103
|
def wait_for_ajax
|
96
104
|
counter = 0
|
97
|
-
while page.
|
105
|
+
while page.evaluate_script("$.active").to_i > 0
|
98
106
|
counter += 1
|
99
107
|
sleep(0.1)
|
100
108
|
raise "AJAX request took longer than 5 seconds." if counter >= 50
|
@@ -4,9 +4,9 @@
|
|
4
4
|
# Inside your spec_helper.rb, include this module inside the RSpec.configure
|
5
5
|
# block by doing this:
|
6
6
|
#
|
7
|
-
# require 'spree/
|
7
|
+
# require 'spree/testing_support/controller_requests'
|
8
8
|
# RSpec.configure do |c|
|
9
|
-
# c.include Spree::
|
9
|
+
# c.include Spree::TestingSupport::ControllerRequests, :type => :controller
|
10
10
|
# end
|
11
11
|
#
|
12
12
|
# Then, in your controller tests, you can access spree routes like this:
|
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.
|
4
|
+
version: 2.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-20 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.
|
19
|
+
version: 1.42.2
|
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.
|
26
|
+
version: 1.42.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: acts_as_list
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.27.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.27.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: cancan
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,16 +84,16 @@ dependencies:
|
|
84
84
|
name: deface
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.0.0
|
89
|
+
version: 1.0.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.0.0
|
96
|
+
version: 1.0.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: ffaker
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,14 +112,14 @@ dependencies:
|
|
112
112
|
name: highline
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: 1.6.18
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ~>
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 1.6.18
|
125
125
|
- !ruby/object:Gem::Dependency
|
@@ -140,16 +140,16 @@ dependencies:
|
|
140
140
|
name: json
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - ~>
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 1.7
|
145
|
+
version: '1.7'
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - ~>
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 1.7
|
152
|
+
version: '1.7'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: kaminari
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,16 +168,16 @@ dependencies:
|
|
168
168
|
name: money
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- -
|
171
|
+
- - ~>
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 5.1
|
173
|
+
version: '5.1'
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- -
|
178
|
+
- - ~>
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 5.1
|
180
|
+
version: '5.1'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: paperclip
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -226,14 +226,14 @@ dependencies:
|
|
226
226
|
requirements:
|
227
227
|
- - '='
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version: 1.
|
229
|
+
version: 1.1.0
|
230
230
|
type: :runtime
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
234
|
- - '='
|
235
235
|
- !ruby/object:Gem::Version
|
236
|
-
version: 1.
|
236
|
+
version: 1.1.0
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
238
|
name: state_machine
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -455,7 +455,6 @@ files:
|
|
455
455
|
- lib/spree/core/environment/calculators.rb
|
456
456
|
- lib/spree/core/environment.rb
|
457
457
|
- lib/spree/core/environment_extension.rb
|
458
|
-
- lib/spree/core/ext/active_record.rb
|
459
458
|
- lib/spree/core/gateway_error.rb
|
460
459
|
- lib/spree/core/mail_interceptor.rb
|
461
460
|
- lib/spree/core/mail_settings.rb
|
@@ -467,7 +466,6 @@ files:
|
|
467
466
|
- lib/spree/core/s3_support.rb
|
468
467
|
- lib/spree/core/search/base.rb
|
469
468
|
- lib/spree/core/token_resource.rb
|
470
|
-
- lib/spree/core/user_banners.rb
|
471
469
|
- lib/spree/core/validators/email.rb
|
472
470
|
- lib/spree/core/version.rb
|
473
471
|
- lib/spree/core.rb
|
@@ -625,6 +623,10 @@ files:
|
|
625
623
|
- db/migrate/20130909115621_change_states_required_for_countries.rb
|
626
624
|
- db/migrate/20130915032339_add_deleted_at_to_spree_stock_items.rb
|
627
625
|
- db/migrate/20131001013410_remove_unused_credit_card_fields.rb
|
626
|
+
- db/migrate/20131113035136_add_channel_to_spree_orders.rb
|
627
|
+
- db/migrate/20131118041203_add_tax_total_to_spree_orders.rb
|
628
|
+
- db/migrate/20131118043021_add_order_id_to_spree_adjustments.rb
|
629
|
+
- db/migrate/20131118074808_add_included_to_spree_adjustments.rb
|
628
630
|
- db/seeds.rb
|
629
631
|
- vendor/assets/javascripts/jquery-migrate-1.0.0.js
|
630
632
|
- vendor/assets/javascripts/jquery.payment.js
|
@@ -1,8 +0,0 @@
|
|
1
|
-
module ActiveRecord::Persistence
|
2
|
-
|
3
|
-
# Update attributes of a record in the database without callbacks, validations etc.
|
4
|
-
def update_attributes_without_callbacks(attributes)
|
5
|
-
self.assign_attributes(attributes)
|
6
|
-
self.class.where(:id => id).update_all(attributes)
|
7
|
-
end
|
8
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# Utility methods for dealing with user banners and saving
|
2
|
-
# an array of dismissed banners per user
|
3
|
-
# use symbols as banner id
|
4
|
-
module Spree
|
5
|
-
module Core
|
6
|
-
module UserBanners
|
7
|
-
def self.included(base)
|
8
|
-
base.preference :dismissed_banners, :string, :default => ''
|
9
|
-
end
|
10
|
-
|
11
|
-
def dismissed_banner_ids
|
12
|
-
dismissed = self.preferred_dismissed_banners
|
13
|
-
dismissed.split(',').map(&:to_sym)
|
14
|
-
end
|
15
|
-
|
16
|
-
def dismiss_banner(banner_id)
|
17
|
-
self.preferred_dismissed_banners = dismissed_banner_ids.push(banner_id.to_sym).uniq.join(',')
|
18
|
-
end
|
19
|
-
|
20
|
-
def dismissed_banner?(banner_id)
|
21
|
-
dismissed_banner_ids.include? banner_id.to_sym
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|