spree_zaez_correios 3.0.3 → 3.0.4
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/.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_correios.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: 8e91f8fcf0ed0b9cc3a0887d65fbe8f0127553ac
|
|
4
|
+
data.tar.gz: 3416cc8d1fcf7a14c64cae51dce7355707fb6952
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9bb71a124c0ce79ebf6a2c35bf01a8264fda66c6dffaa2f23f408e257ff65738e8988a2ef9e6d7c0e88c4bd03d3606a498d6b3f6b097a61d80b6d60504a223a2
|
|
7
|
+
data.tar.gz: 78a0167704e884c350d7e0dd0d62cdaf3c92365477dfde6a79efeb632a65a8d51eafe49769c03988f4bc4715e5f9b508fa6da54d2b5b78d1969235909cf813be
|
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
|
data/spree_zaez_correios.gemspec
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Gem::Specification.new do |s|
|
|
3
3
|
s.platform = Gem::Platform::RUBY
|
|
4
4
|
s.name = 'spree_zaez_correios'
|
|
5
|
-
s.version = '3.0.
|
|
5
|
+
s.version = '3.0.4'
|
|
6
6
|
s.summary = "Implements diverse functions in order to enable the use of services from Brazil's Correios in Spree Commerce"
|
|
7
7
|
s.description = s.summary
|
|
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_correios
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.
|
|
4
|
+
version: 3.0.4
|
|
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
|
|
@@ -254,12 +254,7 @@ files:
|
|
|
254
254
|
- app/assets/stylesheets/spree/backend/spree_zaez_correios.css
|
|
255
255
|
- app/assets/stylesheets/spree/frontend/spree_zaez_correios.css
|
|
256
256
|
- app/models/spree/calculator/shipping/correios_base_calculator.rb
|
|
257
|
-
- app/models/spree/calculator/shipping/flat_percent_item_total_decorator.rb
|
|
258
|
-
- app/models/spree/calculator/shipping/flat_rate_decorator.rb
|
|
259
|
-
- app/models/spree/calculator/shipping/flexi_rate_decorator.rb
|
|
260
257
|
- app/models/spree/calculator/shipping/pac.rb
|
|
261
|
-
- app/models/spree/calculator/shipping/per_item_decorator.rb
|
|
262
|
-
- app/models/spree/calculator/shipping/price_sack_decorator.rb
|
|
263
258
|
- app/models/spree/calculator/shipping/sedex.rb
|
|
264
259
|
- app/models/spree/calculator/shipping/sedex10.rb
|
|
265
260
|
- app/models/spree/stock/estimator_decorator.rb
|
|
@@ -276,6 +271,7 @@ files:
|
|
|
276
271
|
- spec/models/spree/calculator/shipping/pac_spec.rb
|
|
277
272
|
- spec/models/spree/calculator/shipping/sedex10_spec.rb
|
|
278
273
|
- spec/models/spree/calculator/shipping/sedex_spec.rb
|
|
274
|
+
- spec/models/spree/stock/estimator_decorator_spec.rb
|
|
279
275
|
- spec/spec_helper.rb
|
|
280
276
|
- spec/support/correios_shared_examples.rb
|
|
281
277
|
- spree_zaez_correios.gemspec
|
|
@@ -309,5 +305,6 @@ test_files:
|
|
|
309
305
|
- spec/models/spree/calculator/shipping/pac_spec.rb
|
|
310
306
|
- spec/models/spree/calculator/shipping/sedex10_spec.rb
|
|
311
307
|
- spec/models/spree/calculator/shipping/sedex_spec.rb
|
|
308
|
+
- spec/models/spree/stock/estimator_decorator_spec.rb
|
|
312
309
|
- spec/spec_helper.rb
|
|
313
310
|
- spec/support/correios_shared_examples.rb
|