solidus_volume_pricing 1.2.0 → 2.0.0
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/.git-blame-ignore-revs +3 -0
- data/.github/workflows/lint.yml +25 -0
- data/.github/workflows/test.yml +59 -0
- data/.rubocop.yml +0 -5
- data/Gemfile +21 -23
- data/Guardfile +8 -8
- data/README.md +1 -1
- data/Rakefile +3 -3
- data/app/models/solidus_volume_pricing/pricer.rb +9 -9
- data/app/models/solidus_volume_pricing/pricing_options.rb +2 -2
- data/app/models/spree/volume_price.rb +8 -8
- data/app/patches/helpers/solidus_volume_pricing/spree_base_helper_patch.rb +29 -0
- data/app/patches/models/solidus_volume_pricing/spree_line_item_patch.rb +18 -0
- data/app/patches/models/solidus_volume_pricing/spree_variant_patch.rb +21 -0
- data/bin/rails-engine +6 -6
- data/bin/rails-sandbox +4 -4
- data/config/routes.rb +1 -1
- data/db/migrate/20150603143015_create_spree_volume_price_models.rb +2 -2
- data/lib/generators/solidus_volume_pricing/install/install_generator.rb +4 -4
- data/lib/patches/backend/controllers/solidus_volume_pricing/spree_admin_variants_controller_patch.rb +38 -0
- data/lib/solidus_volume_pricing/engine.rb +22 -11
- data/lib/solidus_volume_pricing/range_from_string.rb +4 -4
- data/lib/solidus_volume_pricing/testing_support/factories.rb +5 -5
- data/lib/solidus_volume_pricing/version.rb +1 -1
- data/lib/solidus_volume_pricing.rb +9 -9
- data/solidus_volume_pricing.gemspec +20 -21
- metadata +41 -63
- data/.circleci/config.yml +0 -73
- data/.rubocop_todo.yml +0 -68
- data/app/decorators/controllers/solidus_volume_pricing/spree/admin/variants_controller_decorator.rb +0 -42
- data/app/decorators/helpers/solidus_volume_pricing/spree/base_helper_decorator.rb +0 -31
- data/app/decorators/models/solidus_volume_pricing/spree/line_item_decorator.rb +0 -18
- data/app/decorators/models/solidus_volume_pricing/spree/variant_decorator.rb +0 -23
- data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -30
- data/spec/features/manage_volume_price_models_feature_spec.rb +0 -24
- data/spec/features/manage_volume_prices_feature_spec.rb +0 -33
- data/spec/helpers/base_helper_spec.rb +0 -24
- data/spec/lib/solidus_volume_pricing/range_from_string_spec.rb +0 -61
- data/spec/models/solidus_volume_pricing/pricer_spec.rb +0 -669
- data/spec/models/solidus_volume_pricing/pricing_options_spec.rb +0 -57
- data/spec/models/spree/line_item_spec.rb +0 -36
- data/spec/models/spree/order_spec.rb +0 -51
- data/spec/models/spree/variant_spec.rb +0 -6
- data/spec/models/spree/volume_price_spec.rb +0 -216
- data/spec/spec_helper.rb +0 -32
- data/spec/support/shoulda.rb +0 -11
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe Spree::BaseHelper, type: :helper do
|
|
4
|
-
include described_class
|
|
5
|
-
|
|
6
|
-
context 'volume pricing' do
|
|
7
|
-
before do
|
|
8
|
-
@variant = create :variant, price: 10
|
|
9
|
-
@variant.volume_prices.create! amount: 1, discount_type: 'dollar', range: '(10+)'
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it 'gives discounted price' do
|
|
13
|
-
expect(display_volume_price(@variant, 10)).to eq '$9.00'
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it 'gives discount percent' do
|
|
17
|
-
expect(display_volume_price_earning_percent(@variant, 10)).to eq '10'
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'gives discount amount' do
|
|
21
|
-
expect(display_volume_price_earning_amount(@variant, 10)).to eq '$1.00'
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
RSpec.describe SolidusVolumePricing::RangeFromString do
|
|
6
|
-
describe 'new' do
|
|
7
|
-
subject(:range) { described_class.new(argument).to_range }
|
|
8
|
-
|
|
9
|
-
context 'with a string with two dots' do
|
|
10
|
-
let(:argument) { '1..2' }
|
|
11
|
-
|
|
12
|
-
it { is_expected.to eq(1..2) }
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
context 'with a string with two dots and parens' do
|
|
16
|
-
let(:argument) { '(1..2)' }
|
|
17
|
-
|
|
18
|
-
it { is_expected.to eq(1..2) }
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
context 'with a string with three dots' do
|
|
22
|
-
let(:argument) { '1...2' }
|
|
23
|
-
|
|
24
|
-
it { is_expected.to eq(1...2) }
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
context 'with a string with three dots and parens' do
|
|
28
|
-
let(:argument) { '(1...2)' }
|
|
29
|
-
|
|
30
|
-
it { is_expected.to eq(1...2) }
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context 'with an open-ended string like x+' do
|
|
34
|
-
let(:argument) { '10+' }
|
|
35
|
-
|
|
36
|
-
it { is_expected.to eq(10..Float::INFINITY) }
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
context 'with an open-ended string like x+" and parens' do
|
|
40
|
-
let(:argument) { '(10+)' }
|
|
41
|
-
|
|
42
|
-
it { is_expected.to eq(10..Float::INFINITY) }
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context 'with invalid input' do
|
|
46
|
-
let(:argument) { 'system("rm -rf /*")' }
|
|
47
|
-
|
|
48
|
-
it do
|
|
49
|
-
expect { subject }.to raise_error(ArgumentError)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
context 'with invalid input' do
|
|
54
|
-
let(:argument) { '1..3; puts "Do not run Ruby Code"' }
|
|
55
|
-
|
|
56
|
-
it do
|
|
57
|
-
expect { subject }.to raise_error(ArgumentError)
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|