solidus_core 1.3.0.beta1 → 1.3.0.rc1
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.
Potentially problematic release.
This version of solidus_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/app/assets/images/noimage/large.png +0 -0
- data/app/assets/images/noimage/mini.png +0 -0
- data/app/assets/images/noimage/product.png +0 -0
- data/app/assets/images/noimage/small.png +0 -0
- data/app/models/spree/app_configuration.rb +9 -9
- data/app/models/spree/country.rb +1 -0
- data/app/models/spree/line_item.rb +7 -1
- data/app/models/spree/payment_method.rb +1 -1
- data/app/models/spree/preferences/preferable.rb +1 -0
- data/app/models/spree/preferences/statically_configurable.rb +2 -2
- data/app/models/spree/price.rb +30 -2
- data/app/models/spree/product.rb +4 -1
- data/app/models/spree/stock/inventory_unit_builder.rb +2 -2
- data/app/models/spree/tax/tax_location.rb +4 -0
- data/app/models/spree/tax_rate.rb +2 -11
- data/app/models/spree/variant/price_selector.rb +35 -0
- data/app/models/spree/variant/pricing_options.rb +69 -4
- data/app/models/spree/variant/vat_price_generator.rb +58 -0
- data/app/models/spree/variant.rb +38 -16
- data/config/locales/en.yml +22 -1
- data/db/migrate/20140410141842_add_many_missing_indexes.rb +15 -13
- data/db/migrate/20140410150358_correct_some_polymorphic_index_and_add_more_missing.rb +40 -38
- data/db/migrate/20141217215630_update_product_slug_index.rb +4 -2
- data/db/migrate/20150723224133_remove_unnecessary_indexes.rb +2 -10
- data/db/migrate/20151219020209_add_stock_item_unique_index.rb +2 -2
- data/db/migrate/20160509181311_add_country_iso_to_prices.rb +8 -0
- data/lib/spree/core/class_constantizer.rb +31 -0
- data/lib/spree/core/engine.rb +55 -59
- data/lib/spree/core/environment/calculators.rb +6 -1
- data/lib/spree/core/environment.rb +5 -2
- data/lib/spree/core/environment_extension.rb +16 -12
- data/lib/spree/core/price_migrator.rb +32 -0
- data/lib/spree/core/search/base.rb +2 -2
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +4 -0
- data/lib/spree/migration_helpers.rb +19 -0
- data/lib/spree/money.rb +41 -15
- data/lib/spree/promo/environment.rb +2 -1
- data/lib/spree/testing_support/controller_requests.rb +22 -7
- data/lib/spree/testing_support/factories/state_factory.rb +7 -0
- data/lib/spree/testing_support/factories/stock_location_factory.rb +4 -1
- data/lib/tasks/migrations/create_vat_prices.rake +11 -0
- data/lib/tasks/upgrade.rake +2 -1
- data/spec/lib/spree/core/class_constantizer_spec.rb +68 -0
- data/spec/lib/spree/core/environment_extension_spec.rb +33 -0
- data/spec/lib/spree/core/price_migrator_spec.rb +356 -0
- data/spec/lib/spree/core/testing_support/factories/state_factory_spec.rb +9 -0
- data/spec/lib/spree/core/testing_support/factories/stock_location_factory_spec.rb +9 -0
- data/spec/lib/spree/money_spec.rb +75 -0
- data/spec/models/spree/app_configuration_spec.rb +5 -5
- data/spec/models/spree/country_spec.rb +16 -0
- data/spec/models/spree/line_item_spec.rb +6 -2
- data/spec/models/spree/preferences/preferable_spec.rb +5 -0
- data/spec/models/spree/preferences/statically_configurable_spec.rb +4 -0
- data/spec/models/spree/price_spec.rb +89 -0
- data/spec/models/spree/stock/coordinator_spec.rb +9 -0
- data/spec/models/spree/stock/splitter/shipping_category_spec.rb +30 -32
- data/spec/models/spree/tax/tax_location_spec.rb +14 -5
- data/spec/models/spree/tax/taxation_integration_spec.rb +15 -42
- data/spec/models/spree/variant/{pricer_spec.rb → price_selector_spec.rb} +41 -1
- data/spec/models/spree/variant/pricing_options_spec.rb +87 -4
- data/spec/models/spree/variant/vat_price_generator_spec.rb +69 -0
- data/spec/models/spree/variant_spec.rb +57 -8
- metadata +14 -5
- data/app/models/spree/product_scope/scopes.rb +0 -47
- data/app/models/spree/variant/pricer.rb +0 -19
@@ -49,4 +49,20 @@ describe Spree::Country, type: :model do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
53
|
+
describe '#prices' do
|
54
|
+
let(:country) { create(:country) }
|
55
|
+
subject { country.prices }
|
56
|
+
|
57
|
+
it { is_expected.to be_a(ActiveRecord::Associations::CollectionProxy) }
|
58
|
+
|
59
|
+
context "if the country has associated prices" do
|
60
|
+
let!(:price_one) { create(:price) }
|
61
|
+
let!(:price_two) { create(:price) }
|
62
|
+
let!(:price_three) { create(:price) }
|
63
|
+
let(:country) { create(:country, prices: [price_one, price_two]) }
|
64
|
+
|
65
|
+
it { is_expected.to contain_exactly(price_one, price_two) }
|
66
|
+
end
|
67
|
+
end
|
52
68
|
end
|
@@ -207,15 +207,19 @@ describe Spree::LineItem, type: :model do
|
|
207
207
|
|
208
208
|
describe "#options=" do
|
209
209
|
it "can handle updating a blank line item with no order" do
|
210
|
-
expect(Spree::Deprecation).not_to receive(:warn)
|
211
210
|
line_item.options = { price: 123 }
|
212
211
|
end
|
213
212
|
|
214
213
|
it "updates the data provided in the options" do
|
215
|
-
expect(Spree::Deprecation).not_to receive(:warn)
|
216
214
|
line_item.options = { price: 123 }
|
217
215
|
expect(line_item.price).to eq 123
|
218
216
|
end
|
217
|
+
|
218
|
+
it "updates the price based on the options provided" do
|
219
|
+
expect(line_item).to receive(:gift_wrap=).with(true)
|
220
|
+
expect(line_item).to receive(:money_price=)
|
221
|
+
line_item.options = { gift_wrap: true }
|
222
|
+
end
|
219
223
|
end
|
220
224
|
|
221
225
|
describe 'money_price=' do
|
@@ -117,6 +117,11 @@ describe Spree::Preferences::Preferable, type: :model do
|
|
117
117
|
@a.set_preference(:is_integer, '')
|
118
118
|
expect(@a.preferences[:is_integer]).to eq(0)
|
119
119
|
end
|
120
|
+
|
121
|
+
it 'does not convert if value is nil' do
|
122
|
+
@a.set_preference(:is_integer, nil)
|
123
|
+
expect(@a.preferences[:is_integer]).to be_nil
|
124
|
+
end
|
120
125
|
end
|
121
126
|
|
122
127
|
context "converts decimal preferences to BigDecimal values" do
|
@@ -1,6 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Spree::Price, type: :model do
|
4
|
+
describe 'searchable columns' do
|
5
|
+
subject { described_class.whitelisted_ransackable_attributes }
|
6
|
+
it 'allows searching by variant_id' do
|
7
|
+
expect(subject).to include("variant_id")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
4
11
|
describe 'validations' do
|
5
12
|
let(:variant) { stub_model Spree::Variant }
|
6
13
|
subject { Spree::Price.new variant: variant, amount: amount }
|
@@ -38,5 +45,87 @@ describe Spree::Price, type: :model do
|
|
38
45
|
let(:amount) { Spree::Price::MAXIMUM_AMOUNT }
|
39
46
|
it { is_expected.to be_valid }
|
40
47
|
end
|
48
|
+
|
49
|
+
context '#country_iso' do
|
50
|
+
subject(:price) { build(:price, country_iso: country_iso) }
|
51
|
+
|
52
|
+
context 'when country iso is nil' do
|
53
|
+
let(:country_iso) { nil }
|
54
|
+
|
55
|
+
it { is_expected.to be_valid }
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when country iso is a country code' do
|
59
|
+
let!(:country) { create(:country, iso: "DE") }
|
60
|
+
let(:country_iso) { "DE" }
|
61
|
+
|
62
|
+
it { is_expected.to be_valid }
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'when country iso is not a country code' do
|
66
|
+
let(:country_iso) { "ZZ" }
|
67
|
+
|
68
|
+
it { is_expected.not_to be_valid }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#country' do
|
73
|
+
let!(:country) { create(:country, iso: "DE") }
|
74
|
+
let(:price) { create(:price, country_iso: "DE", is_default: false) }
|
75
|
+
|
76
|
+
it 'returns the country object' do
|
77
|
+
expect(price.country).to eq(country)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "#currency" do
|
83
|
+
let(:variant) { stub_model Spree::Variant }
|
84
|
+
subject { Spree::Price.new variant: variant, amount: 10, currency: currency }
|
85
|
+
|
86
|
+
describe "validation" do
|
87
|
+
context "with an invalid currency" do
|
88
|
+
let(:currency) { "XYZ" }
|
89
|
+
|
90
|
+
it { is_expected.to be_invalid }
|
91
|
+
|
92
|
+
it "has an understandable error message" do
|
93
|
+
subject.valid?
|
94
|
+
expect(subject.errors.messages[:currency].first).to eq("is not a valid currency code")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "with a valid currency" do
|
99
|
+
let(:currency) { "USD" }
|
100
|
+
|
101
|
+
it { is_expected.to be_valid }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe 'scopes' do
|
107
|
+
describe '.for_any_country' do
|
108
|
+
let(:country) { create(:country) }
|
109
|
+
let!(:fallback_price) { create(:price, country_iso: nil) }
|
110
|
+
let!(:country_price) { create(:price, country: country) }
|
111
|
+
|
112
|
+
subject { described_class.for_any_country }
|
113
|
+
|
114
|
+
it { is_expected.to include(fallback_price) }
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe 'net_amount' do
|
119
|
+
let(:country) { create(:country, iso: "DE") }
|
120
|
+
let(:zone) { create(:zone, countries: [country]) }
|
121
|
+
let!(:tax_rate) { create(:tax_rate, included_in_price: true, zone: zone, tax_category: variant.tax_category) }
|
122
|
+
|
123
|
+
let(:variant) { create(:product).master }
|
124
|
+
|
125
|
+
let(:price) { variant.prices.create(amount: 20, country: country) }
|
126
|
+
|
127
|
+
subject { price.net_amount }
|
128
|
+
|
129
|
+
it { is_expected.to eq(BigDecimal.new(20) / 1.1) }
|
41
130
|
end
|
42
131
|
end
|
@@ -42,6 +42,15 @@ module Spree
|
|
42
42
|
expect(subject.shipments.count).to eq(StockLocation.count - 1)
|
43
43
|
end
|
44
44
|
end
|
45
|
+
|
46
|
+
it "does not unintentionally add shipments to the order" do
|
47
|
+
subject.shipments
|
48
|
+
expect {
|
49
|
+
order.update!
|
50
|
+
}.not_to change {
|
51
|
+
order.shipments.count
|
52
|
+
}
|
53
|
+
end
|
45
54
|
end
|
46
55
|
|
47
56
|
# regression spec
|
@@ -2,46 +2,44 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module Stock
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
inventory_unit.variant.product.shipping_category = shipping_category_1
|
17
|
-
end
|
5
|
+
describe Splitter::ShippingCategory, type: :model do
|
6
|
+
let(:order) { create(:order_with_line_items, line_items_count: 1) }
|
7
|
+
let(:line_item) { order.line_items.first }
|
8
|
+
let(:variant1) { build(:variant) }
|
9
|
+
let(:variant2) { build(:variant) }
|
10
|
+
let(:shipping_category_1) { create(:shipping_category, name: 'A') }
|
11
|
+
let(:shipping_category_2) { create(:shipping_category, name: 'B') }
|
12
|
+
|
13
|
+
def inventory_unit1
|
14
|
+
build(:inventory_unit, variant: variant1, order: order, line_item: line_item).tap do |inventory_unit|
|
15
|
+
inventory_unit.variant.product.shipping_category = shipping_category_1
|
18
16
|
end
|
17
|
+
end
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
19
|
+
def inventory_unit2
|
20
|
+
build(:inventory_unit, variant: variant2, order: order, line_item: line_item).tap do |inventory_unit|
|
21
|
+
inventory_unit.variant.product.shipping_category = shipping_category_2
|
24
22
|
end
|
23
|
+
end
|
25
24
|
|
26
|
-
|
25
|
+
let(:packer) { build(:stock_packer) }
|
27
26
|
|
28
|
-
|
27
|
+
subject { described_class.new(packer) }
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
it 'splits each package by shipping category' do
|
30
|
+
package1 = Package.new(packer.stock_location)
|
31
|
+
4.times { package1.add inventory_unit1 }
|
32
|
+
8.times { package1.add inventory_unit2 }
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
package2 = Package.new(packer.stock_location)
|
35
|
+
6.times { package2.add inventory_unit1 }
|
36
|
+
9.times { package2.add inventory_unit2, :backordered }
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
38
|
+
packages = subject.split([package1, package2])
|
39
|
+
expect(packages[0].quantity).to eq 4
|
40
|
+
expect(packages[1].quantity).to eq 8
|
41
|
+
expect(packages[2].quantity).to eq 6
|
42
|
+
expect(packages[3].quantity).to eq 9
|
45
43
|
end
|
46
44
|
end
|
47
45
|
end
|
@@ -34,13 +34,22 @@ RSpec.describe Spree::Tax::TaxLocation do
|
|
34
34
|
expect(subject.country_id).to eq(country.id)
|
35
35
|
end
|
36
36
|
end
|
37
|
+
end
|
37
38
|
|
38
|
-
|
39
|
-
|
39
|
+
describe "#country" do
|
40
|
+
let(:country) { create(:country) }
|
41
|
+
subject { described_class.new(args).country }
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
43
|
+
context 'with a country object' do
|
44
|
+
let(:args) { { country: country } }
|
45
|
+
|
46
|
+
it { is_expected.to eq(country) }
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'with no country object' do
|
50
|
+
let(:args) { { country: nil } }
|
51
|
+
|
52
|
+
it { is_expected.to be nil }
|
44
53
|
end
|
45
54
|
end
|
46
55
|
|
@@ -43,7 +43,7 @@ RSpec.describe "Taxation system integration tests" do
|
|
43
43
|
context 'selling from germany' do
|
44
44
|
let(:germany) { create :country, iso: "DE" }
|
45
45
|
# The weird default_tax boolean is what makes this context one with default included taxes
|
46
|
-
let!(:germany_zone) { create :zone, countries: [germany]
|
46
|
+
let!(:germany_zone) { create :zone, countries: [germany] }
|
47
47
|
let(:romania) { create(:country, iso: "RO") }
|
48
48
|
let(:romania_zone) { create(:zone, countries: [romania] ) }
|
49
49
|
let(:eu_zone) { create(:zone, countries: [romania, germany]) }
|
@@ -114,6 +114,7 @@ RSpec.describe "Taxation system integration tests" do
|
|
114
114
|
end
|
115
115
|
|
116
116
|
before do
|
117
|
+
Spree::Config.admin_vat_country_iso = "DE"
|
117
118
|
order.contents.add(variant)
|
118
119
|
end
|
119
120
|
|
@@ -310,7 +311,6 @@ RSpec.describe "Taxation system integration tests" do
|
|
310
311
|
let(:variant) { download }
|
311
312
|
|
312
313
|
it 'still has an adjusted price for romania' do
|
313
|
-
pending "waiting for the MOSS refactoring"
|
314
314
|
expect(line_item.price).to eq(10.42)
|
315
315
|
end
|
316
316
|
|
@@ -319,12 +319,10 @@ RSpec.describe "Taxation system integration tests" do
|
|
319
319
|
end
|
320
320
|
|
321
321
|
it 'has 2.02 of included tax' do
|
322
|
-
pending 'waiting for the MOSS refactoring'
|
323
322
|
expect(line_item.included_tax_total).to eq(2.02)
|
324
323
|
end
|
325
324
|
|
326
325
|
it 'has a constant amount pre tax' do
|
327
|
-
pending 'but it changes to 8.06, because Spree thinks both VATs apply'
|
328
326
|
expect(line_item.discounted_amount - line_item.included_tax_total).to eq(8.40)
|
329
327
|
end
|
330
328
|
end
|
@@ -334,19 +332,16 @@ RSpec.describe "Taxation system integration tests" do
|
|
334
332
|
|
335
333
|
before { 2.times { order.next! } }
|
336
334
|
|
337
|
-
it 'it has a shipment with
|
338
|
-
|
339
|
-
expect(shipment.amount).to eq(2.08)
|
335
|
+
it 'it has a shipment with worth 2.00' do
|
336
|
+
expect(shipment.amount).to eq(2.00)
|
340
337
|
end
|
341
338
|
|
342
339
|
it 'has a shipment with 0.40 included tax' do
|
343
|
-
|
344
|
-
expect(shipment.included_tax_total).to eq(0.40)
|
340
|
+
expect(shipment.included_tax_total).to eq(0.39)
|
345
341
|
end
|
346
342
|
|
347
343
|
it 'has a shipping rate that correctly reflects the shipment' do
|
348
|
-
|
349
|
-
expect(shipping_rate.display_price).to eq("$2.08 (incl. $0.40 Romanian VAT)")
|
344
|
+
expect(shipping_rate.display_price).to eq("$2.00 (incl. $0.39 Romanian VAT)")
|
350
345
|
end
|
351
346
|
end
|
352
347
|
end
|
@@ -360,22 +355,18 @@ RSpec.describe "Taxation system integration tests" do
|
|
360
355
|
let(:variant) { book }
|
361
356
|
|
362
357
|
it 'should sell at the net price' do
|
363
|
-
pending "Prices have to be adjusted"
|
364
358
|
expect(line_item.price).to eq(18.69)
|
365
359
|
end
|
366
360
|
|
367
361
|
it 'is adjusted to the net price' do
|
368
|
-
pending 'This will turn green when the default zone is gone'
|
369
362
|
expect(line_item.total).to eq(18.69)
|
370
363
|
end
|
371
364
|
|
372
365
|
it 'has no tax adjustments' do
|
373
|
-
pending "Right now it gets a refund"
|
374
366
|
expect(line_item.adjustments.tax.count).to eq(0)
|
375
367
|
end
|
376
368
|
|
377
369
|
it 'has no included tax' do
|
378
|
-
pending 'This will turn green when the default zone is gone'
|
379
370
|
expect(line_item.included_tax_total).to eq(0)
|
380
371
|
end
|
381
372
|
|
@@ -397,7 +388,6 @@ RSpec.describe "Taxation system integration tests" do
|
|
397
388
|
let(:variant) { book }
|
398
389
|
|
399
390
|
it 'should sell at the net price' do
|
400
|
-
pending "Prices have to be adjusted"
|
401
391
|
expect(line_item.price).to eq(18.69)
|
402
392
|
end
|
403
393
|
|
@@ -406,7 +396,6 @@ RSpec.describe "Taxation system integration tests" do
|
|
406
396
|
end
|
407
397
|
|
408
398
|
it 'has no tax adjustments' do
|
409
|
-
pending "Right now it gets a refund"
|
410
399
|
expect(line_item.adjustments.tax.count).to eq(0)
|
411
400
|
end
|
412
401
|
|
@@ -415,12 +404,10 @@ RSpec.describe "Taxation system integration tests" do
|
|
415
404
|
end
|
416
405
|
|
417
406
|
it 'has no additional tax' do
|
418
|
-
pending 'but there is a refund, still'
|
419
407
|
expect(line_item.additional_tax_total).to eq(0)
|
420
408
|
end
|
421
409
|
|
422
410
|
it 'has a constant amount pre tax' do
|
423
|
-
pending 'But it has a discount that abuses the additional tax total'
|
424
411
|
expect(line_item.discounted_amount - line_item.included_tax_total).to eq(18.69)
|
425
412
|
end
|
426
413
|
|
@@ -429,9 +416,8 @@ RSpec.describe "Taxation system integration tests" do
|
|
429
416
|
|
430
417
|
before { 2.times { order.next! } }
|
431
418
|
|
432
|
-
it 'it has a shipment
|
433
|
-
|
434
|
-
expect(shipment.amount).to eq(7.47)
|
419
|
+
it 'it has a shipment that costs $8.00' do
|
420
|
+
expect(shipment.amount).to eq(8.00)
|
435
421
|
end
|
436
422
|
|
437
423
|
it 'has a shipment with no included tax' do
|
@@ -439,8 +425,7 @@ RSpec.describe "Taxation system integration tests" do
|
|
439
425
|
end
|
440
426
|
|
441
427
|
it 'has a shipping rate that correctly reflects the shipment' do
|
442
|
-
|
443
|
-
expect(shipping_rate.display_price).to eq("$7.47")
|
428
|
+
expect(shipping_rate.display_price).to eq("$8.00")
|
444
429
|
end
|
445
430
|
end
|
446
431
|
end
|
@@ -449,12 +434,10 @@ RSpec.describe "Taxation system integration tests" do
|
|
449
434
|
let(:variant) { sweater }
|
450
435
|
|
451
436
|
it 'should sell at the net price' do
|
452
|
-
pending 'but prices are not adjusted according to the zone yet'
|
453
437
|
expect(line_item.price).to eq(25.21)
|
454
438
|
end
|
455
439
|
|
456
440
|
it 'has no tax adjustments' do
|
457
|
-
pending 'but it has a refund'
|
458
441
|
expect(line_item.adjustments.tax.count).to eq(0)
|
459
442
|
end
|
460
443
|
|
@@ -463,12 +446,10 @@ RSpec.describe "Taxation system integration tests" do
|
|
463
446
|
end
|
464
447
|
|
465
448
|
it 'has no additional tax' do
|
466
|
-
pending 'but it has a refund for included taxes wtf'
|
467
449
|
expect(line_item.additional_tax_total).to eq(0)
|
468
450
|
end
|
469
451
|
|
470
452
|
it 'has a constant amount pre tax' do
|
471
|
-
pending 'But it has a discount that abuses the additional tax total'
|
472
453
|
expect(line_item.discounted_amount - line_item.included_tax_total).to eq(25.21)
|
473
454
|
end
|
474
455
|
|
@@ -477,9 +458,8 @@ RSpec.describe "Taxation system integration tests" do
|
|
477
458
|
|
478
459
|
before { 2.times { order.next! } }
|
479
460
|
|
480
|
-
it 'it has a shipment
|
481
|
-
|
482
|
-
expect(shipment.amount).to eq(13.45)
|
461
|
+
it 'it has a shipment costing $16.00' do
|
462
|
+
expect(shipment.amount).to eq(16.00)
|
483
463
|
end
|
484
464
|
|
485
465
|
it 'has a shipment with no included tax' do
|
@@ -487,8 +467,7 @@ RSpec.describe "Taxation system integration tests" do
|
|
487
467
|
end
|
488
468
|
|
489
469
|
it 'has a shipping rate that correctly reflects the shipment' do
|
490
|
-
|
491
|
-
expect(shipping_rate.display_price).to eq("$13.45")
|
470
|
+
expect(shipping_rate.display_price).to eq("$16.00")
|
492
471
|
end
|
493
472
|
end
|
494
473
|
end
|
@@ -497,12 +476,10 @@ RSpec.describe "Taxation system integration tests" do
|
|
497
476
|
let(:variant) { download }
|
498
477
|
|
499
478
|
it 'should sell at the net price' do
|
500
|
-
pending 'but prices are not adjusted yet'
|
501
479
|
expect(line_item.price).to eq(8.40)
|
502
480
|
end
|
503
481
|
|
504
482
|
it 'has no tax adjustments' do
|
505
|
-
pending 'but a refund is created'
|
506
483
|
expect(line_item.adjustments.tax.count).to eq(0)
|
507
484
|
end
|
508
485
|
|
@@ -511,12 +488,10 @@ RSpec.describe "Taxation system integration tests" do
|
|
511
488
|
end
|
512
489
|
|
513
490
|
it 'has no additional tax' do
|
514
|
-
pending 'but an tax refund that disguises as additional tax is created'
|
515
491
|
expect(line_item.additional_tax_total).to eq(0)
|
516
492
|
end
|
517
493
|
|
518
494
|
it 'has a constant amount pre tax' do
|
519
|
-
pending 'But it has a discount that abuses the additional tax total'
|
520
495
|
expect(line_item.discounted_amount - line_item.included_tax_total).to eq(8.40)
|
521
496
|
end
|
522
497
|
end
|
@@ -526,9 +501,8 @@ RSpec.describe "Taxation system integration tests" do
|
|
526
501
|
|
527
502
|
before { 2.times { order.next! } }
|
528
503
|
|
529
|
-
it 'it has a shipment
|
530
|
-
|
531
|
-
expect(shipment.amount).to eq(1.68)
|
504
|
+
it 'it has a shipment costing 2.00' do
|
505
|
+
expect(shipment.amount).to eq(2.00)
|
532
506
|
end
|
533
507
|
|
534
508
|
it 'has a shipment with no included tax' do
|
@@ -536,8 +510,7 @@ RSpec.describe "Taxation system integration tests" do
|
|
536
510
|
end
|
537
511
|
|
538
512
|
it 'has a shipping rate that correctly reflects the shipment' do
|
539
|
-
|
540
|
-
expect(shipping_rate.display_price).to eq("$1.68")
|
513
|
+
expect(shipping_rate.display_price).to eq("$2.00")
|
541
514
|
end
|
542
515
|
end
|
543
516
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Spree::Variant::
|
3
|
+
describe Spree::Variant::PriceSelector do
|
4
4
|
let(:variant) { build_stubbed(:variant) }
|
5
5
|
|
6
6
|
subject { described_class.new(variant) }
|
@@ -23,6 +23,46 @@ describe Spree::Variant::Pricer do
|
|
23
23
|
it "returns the correct (default) price as a Spree::Money object" do
|
24
24
|
expect(subject.price_for(pricing_options)).to eq(Spree::Money.new(12.34, currency: "USD"))
|
25
25
|
end
|
26
|
+
|
27
|
+
context "with the another country iso" do
|
28
|
+
let(:country) { create(:country, iso: "DE") }
|
29
|
+
|
30
|
+
let(:pricing_options) do
|
31
|
+
described_class.pricing_options_class.new(currency: "USD", country_iso: "DE")
|
32
|
+
end
|
33
|
+
|
34
|
+
context "with a price for that country present" do
|
35
|
+
before do
|
36
|
+
variant.prices.create(amount: 44.44, country: country, currency: Spree::Config.currency)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns the correct price" do
|
40
|
+
expect(subject.price_for(pricing_options)).to eq(Spree::Money.new(44.44, currency: "USD"))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "with no price for that country present" do
|
45
|
+
context "and no fallback price for the variant present" do
|
46
|
+
before do
|
47
|
+
variant.prices.delete_all
|
48
|
+
end
|
49
|
+
|
50
|
+
it "returns nil" do
|
51
|
+
expect(subject.price_for(pricing_options)).to be_nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "and a fallback price for the variant present" do
|
56
|
+
before do
|
57
|
+
variant.prices.create(amount: 55.44, country: nil, currency: Spree::Config.currency)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "returns the fallback price" do
|
61
|
+
expect(subject.price_for(pricing_options)).to eq(Spree::Money.new(55.44, currency: "USD"))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
26
66
|
end
|
27
67
|
|
28
68
|
context "with a different currency" do
|