spree_core 3.2.7 → 3.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/spree/payment/processing.rb +2 -2
- data/app/models/spree/promotion/rules/option_value.rb +5 -13
- data/app/models/spree/refund.rb +1 -1
- data/app/validators/db_maximum_length_validator.rb +5 -1
- data/lib/spree/core/engine.rb +3 -3
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/money.rb +15 -1
- data/lib/spree/testing_support/factories.rb +3 -3
- data/lib/spree/testing_support/factories/address_factory.rb +1 -1
- data/lib/spree/testing_support/factories/adjustment_factory.rb +1 -1
- data/lib/spree/testing_support/factories/calculator_factory.rb +1 -1
- data/lib/spree/testing_support/factories/country_factory.rb +1 -1
- data/lib/spree/testing_support/factories/credit_card_factory.rb +1 -1
- data/lib/spree/testing_support/factories/customer_return_factory.rb +1 -1
- data/lib/spree/testing_support/factories/image_factory.rb +1 -1
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +1 -1
- data/lib/spree/testing_support/factories/line_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/options_factory.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +1 -1
- data/lib/spree/testing_support/factories/payment_factory.rb +1 -1
- data/lib/spree/testing_support/factories/payment_method_factory.rb +1 -1
- data/lib/spree/testing_support/factories/price_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_option_type_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_property_factory.rb +1 -1
- data/lib/spree/testing_support/factories/promotion_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/promotion_factory.rb +1 -1
- data/lib/spree/testing_support/factories/promotion_rule_factory.rb +1 -1
- data/lib/spree/testing_support/factories/property_factory.rb +1 -1
- data/lib/spree/testing_support/factories/prototype_factory.rb +1 -1
- data/lib/spree/testing_support/factories/refund_factory.rb +1 -1
- data/lib/spree/testing_support/factories/reimbursement_factory.rb +1 -1
- data/lib/spree/testing_support/factories/reimbursement_type_factory.rb +1 -1
- data/lib/spree/testing_support/factories/return_authorization_factory.rb +1 -1
- data/lib/spree/testing_support/factories/return_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/role_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipment_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipping_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipping_method_factory.rb +1 -1
- data/lib/spree/testing_support/factories/state_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_location_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_movement_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_event_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_type_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_factory.rb +1 -1
- data/lib/spree/testing_support/factories/tag_factory.rb +1 -1
- data/lib/spree/testing_support/factories/tax_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/tax_rate_factory.rb +1 -1
- data/lib/spree/testing_support/factories/taxon_factory.rb +1 -1
- data/lib/spree/testing_support/factories/taxonomy_factory.rb +1 -1
- data/lib/spree/testing_support/factories/tracker_factory.rb +1 -1
- data/lib/spree/testing_support/factories/user_factory.rb +1 -1
- data/lib/spree/testing_support/factories/variant_factory.rb +1 -1
- data/lib/spree/testing_support/factories/zone_factory.rb +1 -1
- data/lib/spree/testing_support/factories/zone_member_factory.rb +1 -1
- data/lib/spree/testing_support/order_walkthrough.rb +9 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5784e0221c1f448f4682cf059247c3e9d01ad19b
|
4
|
+
data.tar.gz: dd80c5de85ebe27ba574f29e33d35c816c600b8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7582fc9f404c240605ba0e75594a154c3318e3388fe4bf50bfb1c5d7474ecfd8021afa9cc182b1c2c07ecdf3c0eb9f87fe4e34ffde5155579a03947ca27410b
|
7
|
+
data.tar.gz: 647cdecd05511282ebbd7c8233cdc76e3abcc261492a1791f4799c38193f728b15bb89e4acd725b371b75e9d197abdb157ebb635e8599fd1de0e0a545383ced0
|
@@ -29,7 +29,7 @@ module Spree
|
|
29
29
|
# a new pending payment record for the remaining amount to capture later.
|
30
30
|
def capture!(amount = nil)
|
31
31
|
return true if completed?
|
32
|
-
amount ||= money.
|
32
|
+
amount ||= money.amount_in_cents
|
33
33
|
started_processing!
|
34
34
|
protect_from_connection_error do
|
35
35
|
# Standard ActiveMerchant capture usage
|
@@ -115,7 +115,7 @@ module Spree
|
|
115
115
|
|
116
116
|
def gateway_action(source, action, success_state)
|
117
117
|
protect_from_connection_error do
|
118
|
-
response = payment_method.send(action, money.
|
118
|
+
response = payment_method.send(action, money.amount_in_cents,
|
119
119
|
source,
|
120
120
|
gateway_options)
|
121
121
|
handle_response(response, success_state, :failure)
|
@@ -31,20 +31,12 @@ module Spree
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def actionable?(line_item)
|
34
|
-
|
35
|
-
|
34
|
+
product_id = line_item.product.id
|
35
|
+
option_values_ids = line_item.variant.option_value_ids
|
36
|
+
eligible_product_ids = preferred_eligible_values.keys
|
37
|
+
eligible_value_ids = preferred_eligible_values[product_id]
|
36
38
|
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def product_ids
|
43
|
-
preferred_eligible_values.keys
|
44
|
-
end
|
45
|
-
|
46
|
-
def value_ids(product_id)
|
47
|
-
preferred_eligible_values[product_id]
|
39
|
+
eligible_product_ids.include?(product_id) && (eligible_value_ids & option_values_ids).present?
|
48
40
|
end
|
49
41
|
end
|
50
42
|
end
|
data/app/models/spree/refund.rb
CHANGED
@@ -43,7 +43,7 @@ module Spree
|
|
43
43
|
def perform!
|
44
44
|
return true if transaction_id.present?
|
45
45
|
|
46
|
-
credit_cents = Spree::Money.new(amount.to_f, currency: payment.currency).
|
46
|
+
credit_cents = Spree::Money.new(amount.to_f, currency: payment.currency).amount_in_cents
|
47
47
|
|
48
48
|
@response = process!(credit_cents)
|
49
49
|
|
@@ -2,7 +2,11 @@
|
|
2
2
|
# Validates a field based on the maximum length of the underlying DB field, if there is one.
|
3
3
|
class DbMaximumLengthValidator < ActiveModel::EachValidator
|
4
4
|
def validate_each(record, attribute, value)
|
5
|
-
|
5
|
+
if defined?(Globalize)
|
6
|
+
limit = record.class.translation_class.columns_hash[attribute.to_s].limit
|
7
|
+
else
|
8
|
+
limit = record.class.columns_hash[attribute.to_s].limit
|
9
|
+
end
|
6
10
|
value = record[attribute.to_sym]
|
7
11
|
if value && limit && value.to_s.length > limit
|
8
12
|
record.errors.add(attribute.to_sym, :too_long, count: limit)
|
data/lib/spree/core/engine.rb
CHANGED
@@ -116,12 +116,12 @@ module Spree
|
|
116
116
|
end
|
117
117
|
|
118
118
|
config.to_prepare do
|
119
|
-
#
|
120
|
-
I18n.load_path
|
119
|
+
# Ensure spree locale paths are present before decorators
|
120
|
+
I18n.load_path.unshift(*(Dir.glob(
|
121
121
|
File.join(
|
122
122
|
File.dirname(__FILE__), '../../../config/locales', '*.{rb,yml}'
|
123
123
|
)
|
124
|
-
)
|
124
|
+
) - I18n.load_path))
|
125
125
|
|
126
126
|
# Load application's model / class decorators
|
127
127
|
Dir.glob(File.join(File.dirname(__FILE__), '../../../app/**/*_decorator*.rb')) do |c|
|
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/money.rb
CHANGED
@@ -15,13 +15,17 @@ module Spree
|
|
15
15
|
|
16
16
|
attr_reader :money
|
17
17
|
|
18
|
-
delegate :cents, to: :money
|
18
|
+
delegate :cents, :currency, to: :money
|
19
19
|
|
20
20
|
def initialize(amount, options={})
|
21
21
|
@money = Monetize.parse([amount, (options[:currency] || Spree::Config[:currency])].join)
|
22
22
|
@options = Spree::Money.default_formatting_rules.merge(options)
|
23
23
|
end
|
24
24
|
|
25
|
+
def amount_in_cents
|
26
|
+
(cents / currency.subunit_to_unit.to_f * 100).round
|
27
|
+
end
|
28
|
+
|
25
29
|
def to_s
|
26
30
|
@money.format(@options)
|
27
31
|
end
|
@@ -40,6 +44,16 @@ module Spree
|
|
40
44
|
to_s
|
41
45
|
end
|
42
46
|
|
47
|
+
def decimal_mark
|
48
|
+
return @money.decimal_mark if @options[:decimal_mark].nil?
|
49
|
+
@options[:decimal_mark]
|
50
|
+
end
|
51
|
+
|
52
|
+
def thousands_separator
|
53
|
+
return @money.thousands_separator if @options[:thousands_separator].nil?
|
54
|
+
@options[:thousands_separator]
|
55
|
+
end
|
56
|
+
|
43
57
|
def ==(obj)
|
44
58
|
@money == obj.money
|
45
59
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'factory_bot'
|
2
2
|
|
3
3
|
Spree::Zone.class_eval do
|
4
4
|
def self.global
|
5
|
-
find_by(name: 'GlobalZone') ||
|
5
|
+
find_by(name: 'GlobalZone') || FactoryBot.create(:global_zone)
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
@@ -10,7 +10,7 @@ Dir["#{File.dirname(__FILE__)}/factories/**"].each do |f|
|
|
10
10
|
load File.expand_path(f)
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
FactoryBot.define do
|
14
14
|
sequence(:random_string) { FFaker::Lorem.sentence }
|
15
15
|
sequence(:random_description) { FFaker::Lorem.paragraphs(1 + Kernel.rand(5)).join("\n") }
|
16
16
|
sequence(:random_email) { FFaker::Internet.email }
|
@@ -2,23 +2,23 @@ class OrderWalkthrough
|
|
2
2
|
def self.up_to(state)
|
3
3
|
# A default store must exist to provide store settings
|
4
4
|
unless Spree::Store.exists?
|
5
|
-
|
5
|
+
FactoryBot.create(:store)
|
6
6
|
end
|
7
7
|
|
8
8
|
# A payment method must exist for an order to proceed through the Address state
|
9
9
|
unless Spree::PaymentMethod.exists?
|
10
|
-
|
10
|
+
FactoryBot.create(:check_payment_method)
|
11
11
|
end
|
12
12
|
|
13
13
|
# Need to create a valid zone too...
|
14
|
-
zone =
|
15
|
-
country =
|
14
|
+
zone = FactoryBot.create(:zone)
|
15
|
+
country = FactoryBot.create(:country)
|
16
16
|
zone.members << Spree::ZoneMember.create(zoneable: country)
|
17
|
-
country.states <<
|
17
|
+
country.states << FactoryBot.create(:state, country: country)
|
18
18
|
|
19
19
|
# A shipping method must exist for rates to be displayed on checkout page
|
20
20
|
unless Spree::ShippingMethod.exists?
|
21
|
-
|
21
|
+
FactoryBot.create(:shipping_method).tap do |sm|
|
22
22
|
sm.calculator.preferred_amount = 10
|
23
23
|
sm.calculator.preferred_currency = Spree::Config[:currency]
|
24
24
|
sm.calculator.save
|
@@ -40,13 +40,13 @@ class OrderWalkthrough
|
|
40
40
|
private
|
41
41
|
|
42
42
|
def self.add_line_item!(order)
|
43
|
-
|
43
|
+
FactoryBot.create(:line_item, order: order)
|
44
44
|
order.reload
|
45
45
|
end
|
46
46
|
|
47
47
|
def self.address(order)
|
48
|
-
order.bill_address =
|
49
|
-
order.ship_address =
|
48
|
+
order.bill_address = FactoryBot.create(:address, country_id: Spree::Zone.global.members.first.zoneable.id)
|
49
|
+
order.ship_address = FactoryBot.create(:address, country_id: Spree::Zone.global.members.first.zoneable.id)
|
50
50
|
order.next!
|
51
51
|
end
|
52
52
|
|
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: 3.2.
|
4
|
+
version: 3.2.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:
|
11
|
+
date: 2018-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -979,7 +979,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
979
979
|
version: 1.8.23
|
980
980
|
requirements: []
|
981
981
|
rubyforge_project:
|
982
|
-
rubygems_version: 2.6.
|
982
|
+
rubygems_version: 2.6.13
|
983
983
|
signing_key:
|
984
984
|
specification_version: 4
|
985
985
|
summary: The bare bones necessary for Spree.
|