solidus_volume_pricing 0.2.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +35 -0
- data/.gem_release.yml +5 -0
- data/.github/dependabot.yml +7 -0
- data/.github/stale.yml +17 -0
- data/.gitignore +14 -9
- data/.rspec +2 -2
- data/.rubocop.yml +3 -7
- data/.rubocop_todo.yml +126 -0
- data/CHANGELOG.md +86 -0
- data/Gemfile +25 -2
- data/Guardfile +3 -1
- data/{LICENSE.md → LICENSE} +2 -2
- data/README.md +55 -50
- data/Rakefile +4 -19
- data/app/assets/javascripts/spree/backend/solidus_volume_pricing.js +1 -15
- data/app/controllers/spree/admin/volume_price_models_controller.rb +2 -1
- data/app/controllers/spree/admin/volume_prices_controller.rb +3 -1
- data/app/decorators/controllers/solidus_volume_pricing/spree/admin/variants_controller_decorator.rb +42 -0
- data/app/decorators/helpers/solidus_volume_pricing/spree/base_helper_decorator.rb +31 -0
- data/app/decorators/models/solidus_volume_pricing/spree/line_item_decorator.rb +18 -0
- data/app/decorators/models/solidus_volume_pricing/spree/variant_decorator.rb +21 -0
- data/app/models/solidus_volume_pricing/price_display.rb +47 -0
- data/app/models/solidus_volume_pricing/pricer.rb +95 -0
- data/app/models/solidus_volume_pricing/pricing_options.rb +20 -0
- data/app/models/spree/volume_price.rb +43 -26
- data/app/models/spree/volume_price_model.rb +6 -4
- data/app/overrides/spree/admin/shared/_settings_sub_menu/add_volume_price_model_admin_menu_links.html.erb.deface +5 -0
- data/app/overrides/views_decorator.rb +2 -0
- data/app/views/spree/admin/shared/_vp_product_tab.html.erb +2 -2
- data/app/views/spree/admin/variants/_edit_fields.html.erb +5 -32
- data/app/views/spree/admin/variants/volume_prices.html.erb +9 -36
- data/app/views/spree/admin/volume_price_models/_form.html.erb +6 -2
- data/app/views/spree/admin/volume_price_models/_list.html.erb +8 -4
- data/app/views/spree/admin/volume_price_models/_select.html.erb +17 -0
- data/app/views/spree/admin/volume_price_models/edit.html.erb +7 -6
- data/app/views/spree/admin/volume_price_models/index.html.erb +7 -5
- data/app/views/spree/admin/volume_price_models/new.html.erb +5 -5
- data/app/views/spree/admin/volume_prices/_table.html.erb +26 -0
- data/app/views/spree/admin/volume_prices/_volume_price_fields.html.erb +10 -8
- data/app/views/spree/products/_volume_pricing.html.erb +8 -8
- data/bin/console +17 -0
- data/bin/rails +12 -4
- data/bin/setup +8 -0
- data/config/locales/de.yml +17 -3
- data/config/locales/en.yml +21 -2
- data/config/locales/pt.yml +6 -2
- data/config/locales/ru.yml +6 -2
- data/config/locales/sv.yml +6 -2
- data/config/locales/tr.yml +6 -2
- data/config/routes.rb +3 -1
- data/db/migrate/20081119145604_create_volume_prices.rb +3 -1
- data/db/migrate/20110203174010_change_display_name_for_volume_prices.rb +3 -1
- data/db/migrate/20111206173307_prefix_volume_pricing_table_names.rb +3 -1
- data/db/migrate/20121115043422_add_discount_type_column.rb +3 -1
- data/db/migrate/20150513200904_add_role_to_volume_price.rb +3 -1
- data/db/migrate/20150603143015_create_spree_volume_price_models.rb +3 -1
- data/lib/generators/solidus_volume_pricing/install/install_generator.rb +5 -5
- data/lib/solidus_volume_pricing/engine.rb +16 -24
- data/lib/solidus_volume_pricing/range_from_string.rb +36 -0
- data/lib/solidus_volume_pricing/testing_support/factories.rb +14 -0
- data/lib/solidus_volume_pricing/version.rb +3 -16
- data/lib/solidus_volume_pricing.rb +6 -1
- data/solidus_volume_pricing.gemspec +26 -23
- data/spec/controllers/spree/admin/variants_controller_spec.rb +18 -15
- data/spec/features/manage_volume_price_models_feature_spec.rb +5 -7
- data/spec/features/manage_volume_prices_feature_spec.rb +9 -8
- data/spec/helpers/base_helper_spec.rb +3 -1
- data/spec/lib/solidus_volume_pricing/range_from_string_spec.rb +61 -0
- data/spec/models/solidus_volume_pricing/pricer_spec.rb +669 -0
- data/spec/models/solidus_volume_pricing/pricing_options_spec.rb +57 -0
- data/spec/models/spree/line_item_spec.rb +23 -21
- data/spec/models/spree/order_spec.rb +4 -2
- data/spec/models/spree/variant_spec.rb +3 -303
- data/spec/models/spree/volume_price_spec.rb +145 -50
- data/spec/spec_helper.rb +15 -35
- data/spec/support/shoulda.rb +11 -0
- metadata +83 -161
- data/.hound.yml +0 -40
- data/.travis.yml +0 -12
- data/CONTRIBUTING.md +0 -81
- data/app/controllers/spree/admin/variants_controller_decorator.rb +0 -32
- data/app/helpers/spree/base_helper_decorator.rb +0 -19
- data/app/models/spree/line_item_decorator.rb +0 -13
- data/app/models/spree/user_decorator.rb +0 -10
- data/app/models/spree/variant_decorator.rb +0 -104
- data/app/overrides/spree/admin/shared/sub_menu/_configuration/add_volume_price_model_admin_menu_links.html.erb.deface +0 -3
- data/app/views/spree/admin/volume_prices/_edit_fields.html.erb +0 -31
- data/spec/factories/volume_price_factory.rb +0 -12
- data/spec/support/capybara.rb +0 -12
- data/spec/support/database_cleaner.rb +0 -21
- data/spec/support/factory_girl.rb +0 -7
- data/spec/support/spree.rb +0 -10
@@ -0,0 +1,61 @@
|
|
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
|