spree_zaez_tnt_mercurio 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/app/models/spree/stock/estimator_decorator.rb +8 -3
- data/spec/models/spree/stock/estimator_decorator_spec.rb +33 -0
- data/spree_zaez_tnt_mercurio.gemspec +1 -1
- metadata +4 -7
- data/app/models/spree/calculator/shipping/flat_percent_item_total_decorator.rb +0 -7
- data/app/models/spree/calculator/shipping/flat_rate_decorator.rb +0 -6
- data/app/models/spree/calculator/shipping/flexi_rate_decorator.rb +0 -7
- data/app/models/spree/calculator/shipping/per_item_decorator.rb +0 -7
- data/app/models/spree/calculator/shipping/price_sack_decorator.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5519071aed3a2ca1b4d3d2a8e723b8a15b90a31
|
4
|
+
data.tar.gz: d834262495bd2e2f7f6bd20e37dd90545751862b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49cb649a33a9cbe721bbee10b6fed083338e3d0a4cd7fb2b3ba9de274f490bd4b52a3f7f53de8d9c628a3fc93a4d0aa531fb6e1cadad7687ca33bc6dbbf6a725
|
7
|
+
data.tar.gz: 09c3031573787fb3ad089a4f6d8779357201e92ffc32ce41c91ca6e6744a58c4f6b73ba473da9da3e3a2b8d6eeeb212faedd2e465972bed136f4ba8e0694fd52
|
data/.gitignore
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
Spree::Stock::Estimator.class_eval do
|
2
2
|
|
3
|
-
# Override
|
3
|
+
# Override to save the delivery time
|
4
4
|
def calculate_shipping_rates(package, ui_filter)
|
5
5
|
shipping_methods(package, ui_filter).map do |shipping_method|
|
6
6
|
response = shipping_method.calculator.compute(package)
|
7
|
-
|
8
|
-
|
7
|
+
if response.is_a? Hash
|
8
|
+
cost = response[:cost]
|
9
|
+
delivery_time = response[:delivery_time]
|
10
|
+
elsif %w(Float BigDecimal).include? response.class.to_s
|
11
|
+
cost = response
|
12
|
+
delivery_time = nil
|
13
|
+
end
|
9
14
|
|
10
15
|
tax_category = shipping_method.tax_category
|
11
16
|
if tax_category
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
module Stock
|
5
|
+
describe Estimator do
|
6
|
+
let!(:shipping_method) { create(:shipping_method) }
|
7
|
+
let(:package) { build(:stock_package, contents: inventory_units.map { |i| ContentItem.new(inventory_unit) }) }
|
8
|
+
let(:order) { build(:order_with_line_items) }
|
9
|
+
let(:inventory_units) { order.inventory_units }
|
10
|
+
|
11
|
+
subject { Estimator.new(order) }
|
12
|
+
|
13
|
+
context '#shipping rates' do
|
14
|
+
before(:each) do
|
15
|
+
shipping_method.zones.first.members.create(:zoneable => order.ship_address.country)
|
16
|
+
allow_any_instance_of(ShippingMethod).to receive_message_chain(:calculator, :available?).and_return(true)
|
17
|
+
allow_any_instance_of(ShippingMethod).to receive_message_chain(:calculator, :compute).and_return({cost: 4.00, delivery_time: 1})
|
18
|
+
allow_any_instance_of(ShippingMethod).to receive_message_chain(:calculator, :preferences).and_return({:currency => currency})
|
19
|
+
allow_any_instance_of(ShippingMethod).to receive_message_chain(:calculator, :marked_for_destruction?)
|
20
|
+
|
21
|
+
allow(package).to receive_messages(:shipping_methods => [shipping_method])
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:currency) { 'USD' }
|
25
|
+
|
26
|
+
it 'should save the delivery time on shipping rate' do
|
27
|
+
shipping_rates = subject.shipping_rates(package)
|
28
|
+
expect(shipping_rates.first.delivery_time).to eq 1
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.platform = Gem::Platform::RUBY
|
4
4
|
s.name = 'spree_zaez_tnt_mercurio'
|
5
|
-
s.version = '3.0.
|
5
|
+
s.version = '3.0.3'
|
6
6
|
s.summary = 'Implements diverse functions in order to enable the use of services from TNT Mercúrio in Spree Commerce'
|
7
7
|
s.description = 'Implements diverse functions in order to enable the use of services from TNT Mercúrio in Spree Commerce'
|
8
8
|
s.required_ruby_version = '>= 2.0.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_zaez_tnt_mercurio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zaez Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spree_core
|
@@ -282,11 +282,6 @@ files:
|
|
282
282
|
- app/assets/stylesheets/spree/backend/spree_zaez_tnt_mercurio.css
|
283
283
|
- app/assets/stylesheets/spree/frontend/spree_zaez_tnt_mercurio.css
|
284
284
|
- app/controllers/spree/admin/tnt_mercurio_settings_controller.rb
|
285
|
-
- app/models/spree/calculator/shipping/flat_percent_item_total_decorator.rb
|
286
|
-
- app/models/spree/calculator/shipping/flat_rate_decorator.rb
|
287
|
-
- app/models/spree/calculator/shipping/flexi_rate_decorator.rb
|
288
|
-
- app/models/spree/calculator/shipping/per_item_decorator.rb
|
289
|
-
- app/models/spree/calculator/shipping/price_sack_decorator.rb
|
290
285
|
- app/models/spree/calculator/shipping/tnt_mercurio_anc.rb
|
291
286
|
- app/models/spree/calculator/shipping/tnt_mercurio_base_calculator.rb
|
292
287
|
- app/models/spree/calculator/shipping/tnt_mercurio_rnc.rb
|
@@ -309,6 +304,7 @@ files:
|
|
309
304
|
- spec/fixtures/calcula_frete/success_response.xml
|
310
305
|
- spec/models/spree/calculator/shipping/tnt_mercurio_anc_spec.rb
|
311
306
|
- spec/models/spree/calculator/shipping/tnt_mercurio_rnc_spec.rb
|
307
|
+
- spec/models/spree/stock/estimator_decorator_spec.rb
|
312
308
|
- spec/models/spree/tnt_mercurio_configuration_spec.rb
|
313
309
|
- spec/shared_examples/tnt_calculator.rb
|
314
310
|
- spec/spec_helper.rb
|
@@ -347,6 +343,7 @@ test_files:
|
|
347
343
|
- spec/fixtures/calcula_frete/success_response.xml
|
348
344
|
- spec/models/spree/calculator/shipping/tnt_mercurio_anc_spec.rb
|
349
345
|
- spec/models/spree/calculator/shipping/tnt_mercurio_rnc_spec.rb
|
346
|
+
- spec/models/spree/stock/estimator_decorator_spec.rb
|
350
347
|
- spec/models/spree/tnt_mercurio_configuration_spec.rb
|
351
348
|
- spec/shared_examples/tnt_calculator.rb
|
352
349
|
- spec/spec_helper.rb
|