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.
Files changed (93) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +35 -0
  3. data/.gem_release.yml +5 -0
  4. data/.github/dependabot.yml +7 -0
  5. data/.github/stale.yml +17 -0
  6. data/.gitignore +14 -9
  7. data/.rspec +2 -2
  8. data/.rubocop.yml +3 -7
  9. data/.rubocop_todo.yml +126 -0
  10. data/CHANGELOG.md +86 -0
  11. data/Gemfile +25 -2
  12. data/Guardfile +3 -1
  13. data/{LICENSE.md → LICENSE} +2 -2
  14. data/README.md +55 -50
  15. data/Rakefile +4 -19
  16. data/app/assets/javascripts/spree/backend/solidus_volume_pricing.js +1 -15
  17. data/app/controllers/spree/admin/volume_price_models_controller.rb +2 -1
  18. data/app/controllers/spree/admin/volume_prices_controller.rb +3 -1
  19. data/app/decorators/controllers/solidus_volume_pricing/spree/admin/variants_controller_decorator.rb +42 -0
  20. data/app/decorators/helpers/solidus_volume_pricing/spree/base_helper_decorator.rb +31 -0
  21. data/app/decorators/models/solidus_volume_pricing/spree/line_item_decorator.rb +18 -0
  22. data/app/decorators/models/solidus_volume_pricing/spree/variant_decorator.rb +21 -0
  23. data/app/models/solidus_volume_pricing/price_display.rb +47 -0
  24. data/app/models/solidus_volume_pricing/pricer.rb +95 -0
  25. data/app/models/solidus_volume_pricing/pricing_options.rb +20 -0
  26. data/app/models/spree/volume_price.rb +43 -26
  27. data/app/models/spree/volume_price_model.rb +6 -4
  28. data/app/overrides/spree/admin/shared/_settings_sub_menu/add_volume_price_model_admin_menu_links.html.erb.deface +5 -0
  29. data/app/overrides/views_decorator.rb +2 -0
  30. data/app/views/spree/admin/shared/_vp_product_tab.html.erb +2 -2
  31. data/app/views/spree/admin/variants/_edit_fields.html.erb +5 -32
  32. data/app/views/spree/admin/variants/volume_prices.html.erb +9 -36
  33. data/app/views/spree/admin/volume_price_models/_form.html.erb +6 -2
  34. data/app/views/spree/admin/volume_price_models/_list.html.erb +8 -4
  35. data/app/views/spree/admin/volume_price_models/_select.html.erb +17 -0
  36. data/app/views/spree/admin/volume_price_models/edit.html.erb +7 -6
  37. data/app/views/spree/admin/volume_price_models/index.html.erb +7 -5
  38. data/app/views/spree/admin/volume_price_models/new.html.erb +5 -5
  39. data/app/views/spree/admin/volume_prices/_table.html.erb +26 -0
  40. data/app/views/spree/admin/volume_prices/_volume_price_fields.html.erb +10 -8
  41. data/app/views/spree/products/_volume_pricing.html.erb +8 -8
  42. data/bin/console +17 -0
  43. data/bin/rails +12 -4
  44. data/bin/setup +8 -0
  45. data/config/locales/de.yml +17 -3
  46. data/config/locales/en.yml +21 -2
  47. data/config/locales/pt.yml +6 -2
  48. data/config/locales/ru.yml +6 -2
  49. data/config/locales/sv.yml +6 -2
  50. data/config/locales/tr.yml +6 -2
  51. data/config/routes.rb +3 -1
  52. data/db/migrate/20081119145604_create_volume_prices.rb +3 -1
  53. data/db/migrate/20110203174010_change_display_name_for_volume_prices.rb +3 -1
  54. data/db/migrate/20111206173307_prefix_volume_pricing_table_names.rb +3 -1
  55. data/db/migrate/20121115043422_add_discount_type_column.rb +3 -1
  56. data/db/migrate/20150513200904_add_role_to_volume_price.rb +3 -1
  57. data/db/migrate/20150603143015_create_spree_volume_price_models.rb +3 -1
  58. data/lib/generators/solidus_volume_pricing/install/install_generator.rb +5 -5
  59. data/lib/solidus_volume_pricing/engine.rb +16 -24
  60. data/lib/solidus_volume_pricing/range_from_string.rb +36 -0
  61. data/lib/solidus_volume_pricing/testing_support/factories.rb +14 -0
  62. data/lib/solidus_volume_pricing/version.rb +3 -16
  63. data/lib/solidus_volume_pricing.rb +6 -1
  64. data/solidus_volume_pricing.gemspec +26 -23
  65. data/spec/controllers/spree/admin/variants_controller_spec.rb +18 -15
  66. data/spec/features/manage_volume_price_models_feature_spec.rb +5 -7
  67. data/spec/features/manage_volume_prices_feature_spec.rb +9 -8
  68. data/spec/helpers/base_helper_spec.rb +3 -1
  69. data/spec/lib/solidus_volume_pricing/range_from_string_spec.rb +61 -0
  70. data/spec/models/solidus_volume_pricing/pricer_spec.rb +669 -0
  71. data/spec/models/solidus_volume_pricing/pricing_options_spec.rb +57 -0
  72. data/spec/models/spree/line_item_spec.rb +23 -21
  73. data/spec/models/spree/order_spec.rb +4 -2
  74. data/spec/models/spree/variant_spec.rb +3 -303
  75. data/spec/models/spree/volume_price_spec.rb +145 -50
  76. data/spec/spec_helper.rb +15 -35
  77. data/spec/support/shoulda.rb +11 -0
  78. metadata +83 -161
  79. data/.hound.yml +0 -40
  80. data/.travis.yml +0 -12
  81. data/CONTRIBUTING.md +0 -81
  82. data/app/controllers/spree/admin/variants_controller_decorator.rb +0 -32
  83. data/app/helpers/spree/base_helper_decorator.rb +0 -19
  84. data/app/models/spree/line_item_decorator.rb +0 -13
  85. data/app/models/spree/user_decorator.rb +0 -10
  86. data/app/models/spree/variant_decorator.rb +0 -104
  87. data/app/overrides/spree/admin/shared/sub_menu/_configuration/add_volume_price_model_admin_menu_links.html.erb.deface +0 -3
  88. data/app/views/spree/admin/volume_prices/_edit_fields.html.erb +0 -31
  89. data/spec/factories/volume_price_factory.rb +0 -12
  90. data/spec/support/capybara.rb +0 -12
  91. data/spec/support/database_cleaner.rb +0 -21
  92. data/spec/support/factory_girl.rb +0 -7
  93. 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