solidus_volume_pricing 1.1.0 → 1.2.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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +50 -12
  3. data/.github/stale.yml +1 -17
  4. data/.github_changelog_generator +2 -0
  5. data/.gitignore +6 -2
  6. data/.rspec +0 -1
  7. data/.rubocop.yml +4 -1
  8. data/.rubocop_todo.yml +18 -76
  9. data/CHANGELOG.md +1 -84
  10. data/Gemfile +16 -11
  11. data/OLD_CHANGELOG.md +86 -0
  12. data/Rakefile +2 -0
  13. data/app/controllers/spree/admin/volume_price_models_controller.rb +1 -1
  14. data/app/decorators/models/solidus_volume_pricing/spree/variant_decorator.rb +6 -4
  15. data/app/models/spree/volume_price.rb +41 -41
  16. data/app/models/spree/volume_price_model.rb +9 -7
  17. data/app/overrides/spree/admin/shared/_product_tabs/add_volume_pricing_admin_tab.html.erb.deface +3 -0
  18. data/app/overrides/spree/admin/variants/edit/add_volume_pricing_field_to_variant.html.erb.deface +3 -0
  19. data/bin/rails +4 -12
  20. data/bin/rails-engine +13 -0
  21. data/bin/rails-sandbox +16 -0
  22. data/bin/rake +7 -0
  23. data/bin/sandbox +78 -0
  24. data/bin/setup +1 -1
  25. data/db/migrate/20150603143015_create_spree_volume_price_models.rb +1 -0
  26. data/lib/generators/solidus_volume_pricing/install/install_generator.rb +8 -6
  27. data/lib/solidus_volume_pricing/engine.rb +2 -1
  28. data/lib/solidus_volume_pricing/version.rb +1 -1
  29. data/solidus_volume_pricing.gemspec +38 -40
  30. data/spec/controllers/spree/admin/variants_controller_spec.rb +1 -1
  31. data/spec/features/manage_volume_price_models_feature_spec.rb +1 -1
  32. data/spec/lib/solidus_volume_pricing/range_from_string_spec.rb +2 -2
  33. data/spec/spec_helper.rb +12 -4
  34. metadata +25 -14
  35. data/app/overrides/views_decorator.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98bbc2761ea5f9a04ec275d189fc8ef633a9a23a174b0fb0fe7183db0e51ac90
4
- data.tar.gz: 966b8ca6e650a96310cd69d8c216fed8dff2705f2e35f4722bdf29ef9fe4b747
3
+ metadata.gz: 4851ed1cbff2d8a6b293bb4e13004c3d029904ac9b77f184d18d25c0165868d9
4
+ data.tar.gz: 3a8471044299dff716a3d99551dfe353d6aff0b41213288e7e808ec8a7d0f0ad
5
5
  SHA512:
6
- metadata.gz: ea5dec857a30471edb436aadd74bdfd21f553e1320fc29fd787619b73eb74cfeddfea8699fc8c3c960e9a7630d4032591ba4c2fd2fba2527edc0ca0e6e1fb7a4
7
- data.tar.gz: cf4b9beecf2f6cb70d05b4e1018ec910eff96a24c09535b350beb2de2bfa2b802a9e333a19f5242a9888a12347bfda8ad7236731f27bd3e8b9b8c1f63865a1a3
6
+ metadata.gz: eb6a8e0e5e693b25583d7648a42375c6a11ae0afdbd7a6435306ec9cfc159848ce062a0b1f73ca953bbf9ddf48b12266bd95fcdda5e0d3a04a0aca28205c193f
7
+ data.tar.gz: 30aff993f5ed9e502533377c770d252064e5fd77b503024e5cab0759dc9a445396f0bad14b81da672d2bafdccef67d73d5ab295af9459de470da4e4c53d13d9a
data/.circleci/config.yml CHANGED
@@ -1,6 +1,9 @@
1
1
  version: 2.1
2
2
 
3
3
  orbs:
4
+ # Required for feature specs.
5
+ browser-tools: circleci/browser-tools@1.1
6
+
4
7
  # Always take the latest version of the orb, this allows us to
5
8
  # run specs against Solidus supported versions only without the need
6
9
  # to change this configuration every time a Solidus version is released
@@ -8,28 +11,63 @@ orbs:
8
11
  solidusio_extensions: solidusio/extensions@volatile
9
12
 
10
13
  jobs:
11
- run-specs-with-postgres:
12
- executor: solidusio_extensions/postgres
14
+ run-specs:
15
+ parameters:
16
+ solidus:
17
+ type: string
18
+ default: main
19
+ db:
20
+ type: string
21
+ default: "postgres"
22
+ ruby:
23
+ type: string
24
+ default: "3.2"
25
+ executor:
26
+ name: solidusio_extensions/<< parameters.db >>
27
+ ruby_version: << parameters.ruby >>
13
28
  steps:
14
- - solidusio_extensions/run-tests
15
- run-specs-with-mysql:
16
- executor: solidusio_extensions/mysql
29
+ - checkout
30
+ - browser-tools/install-chrome
31
+ - solidusio_extensions/run-tests-solidus-<< parameters.solidus >>
32
+
33
+ lint-code:
34
+ executor:
35
+ name: solidusio_extensions/sqlite
36
+ ruby_version: "3.0"
17
37
  steps:
18
- - solidusio_extensions/run-tests
38
+ - solidusio_extensions/lint-code
19
39
 
20
40
  workflows:
21
41
  "Run specs on supported Solidus versions":
22
42
  jobs:
23
- - run-specs-with-postgres
24
- - run-specs-with-mysql
25
- "Weekly run specs against master":
43
+ - run-specs:
44
+ name: &name "run-specs-solidus-<< matrix.solidus >>-ruby-<< matrix.ruby >>-db-<< matrix.db >>"
45
+ matrix:
46
+ parameters: { solidus: ["main"], ruby: ["3.2"], db: ["postgres"] }
47
+ - run-specs:
48
+ name: *name
49
+ matrix:
50
+ parameters: { solidus: ["current"], ruby: ["3.1"], db: ["mysql"] }
51
+ - run-specs:
52
+ name: *name
53
+ matrix:
54
+ parameters: { solidus: ["older"], ruby: ["3.0"], db: ["sqlite"] }
55
+ - lint-code
56
+
57
+ "Weekly run specs against main":
26
58
  triggers:
27
59
  - schedule:
28
60
  cron: "0 0 * * 4" # every Thursday
29
61
  filters:
30
62
  branches:
31
63
  only:
32
- - master
64
+ - main
33
65
  jobs:
34
- - run-specs-with-postgres
35
- - run-specs-with-mysql
66
+ - run-specs:
67
+ name: *name
68
+ matrix:
69
+ parameters: { solidus: ["main"], ruby: ["3.2"], db: ["postgres"] }
70
+ - run-specs:
71
+ name: *name
72
+ matrix:
73
+ parameters: { solidus: ["current"], ruby: ["3.1"], db: ["mysql"] }
data/.github/stale.yml CHANGED
@@ -1,17 +1 @@
1
- # Number of days of inactivity before an issue becomes stale
2
- daysUntilStale: 60
3
- # Number of days of inactivity before a stale issue is closed
4
- daysUntilClose: 7
5
- # Issues with these labels will never be considered stale
6
- exemptLabels:
7
- - pinned
8
- - security
9
- # Label to use when marking an issue as stale
10
- staleLabel: wontfix
11
- # Comment to post when marking an issue as stale. Set to `false` to disable
12
- markComment: >
13
- This issue has been automatically marked as stale because it has not had
14
- recent activity. It will be closed if no further activity occurs. Thank you
15
- for your contributions.
16
- # Comment to post when closing a stale issue. Set to `false` to disable
17
- closeComment: false
1
+ _extends: .github
@@ -0,0 +1,2 @@
1
+ issues=false
2
+ exclude-labels=infrastructure
data/.gitignore CHANGED
@@ -8,11 +8,15 @@
8
8
  .sass-cache
9
9
  coverage
10
10
  Gemfile.lock
11
+ Gemfile-local
11
12
  tmp
12
13
  nbproject
13
14
  pkg
14
15
  *.swp
15
16
  spec/dummy
16
17
  spec/examples.txt
17
- .byebug*
18
- Gemfile-local
18
+ /sandbox
19
+ .rvmrc
20
+ .ruby-version
21
+ .ruby-gemset
22
+ .byebug*
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
1
  --color
2
- --format documentation
3
2
  --require spec_helper
data/.rubocop.yml CHANGED
@@ -1,4 +1,7 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
1
3
  require:
2
4
  - solidus_dev_support/rubocop
3
5
 
4
- inherit_from: .rubocop_todo.yml
6
+ AllCops:
7
+ NewCops: disable
data/.rubocop_todo.yml CHANGED
@@ -1,49 +1,24 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2019-11-23 17:04:33 +0100 using RuboCop version 0.76.0.
3
+ # on 2023-05-12 15:47:30 UTC using RuboCop version 1.50.2.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 1
10
- # Configuration parameters: Include.
11
- # Include: **/*.gemspec,
12
- Gemspec/RequiredRubyVersion:
13
- Exclude:
14
- - 'solidus_volume_pricing.gemspec'
15
-
16
- # Offense count: 2
17
- Lint/InterpolationCheck:
18
- Exclude:
19
- - 'spec/lib/solidus_volume_pricing/range_from_string_spec.rb'
20
-
21
- # Offense count: 21
22
- # Cop supports --auto-correct.
23
- # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
24
- # URISchemes: http, https
25
- Metrics/LineLength:
26
- Max: 160
27
-
28
- # Offense count: 43
29
- # Configuration parameters: Prefixes.
9
+ # Offense count: 42
10
+ # Configuration parameters: Prefixes, AllowedPatterns.
30
11
  # Prefixes: when, with, without
31
12
  RSpec/ContextWording:
32
13
  Exclude:
33
- - 'spec/controllers/spree/admin/variants_controller_spec.rb'
34
14
  - 'spec/helpers/base_helper_spec.rb'
35
15
  - 'spec/models/solidus_volume_pricing/pricer_spec.rb'
36
16
  - 'spec/models/spree/order_spec.rb'
37
17
  - 'spec/models/spree/volume_price_spec.rb'
38
18
 
39
- # Offense count: 2
40
- RSpec/DescribeClass:
41
- Exclude:
42
- - 'spec/features/manage_volume_price_models_feature_spec.rb'
43
- - 'spec/features/manage_volume_prices_feature_spec.rb'
44
-
45
19
  # Offense count: 1
46
- # Configuration parameters: CustomTransform, IgnoreMethods.
20
+ # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
21
+ # Include: **/*_spec*rb*, **/spec/**/*
47
22
  RSpec/FilePath:
48
23
  Exclude:
49
24
  - 'spec/helpers/base_helper_spec.rb'
@@ -56,12 +31,17 @@ RSpec/InstanceVariable:
56
31
  - 'spec/models/spree/order_spec.rb'
57
32
 
58
33
  # Offense count: 5
59
- # Configuration parameters: AggregateFailuresByDefault.
60
34
  RSpec/MultipleExpectations:
61
35
  Max: 3
62
36
 
63
- # Offense count: 58
64
- # Configuration parameters: IgnoreSharedExamples.
37
+ # Offense count: 82
38
+ # Configuration parameters: AllowSubject.
39
+ RSpec/MultipleMemoizedHelpers:
40
+ Max: 8
41
+
42
+ # Offense count: 57
43
+ # Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
44
+ # SupportedStyles: always, named_only
65
45
  RSpec/NamedSubject:
66
46
  Exclude:
67
47
  - 'spec/lib/solidus_volume_pricing/range_from_string_spec.rb'
@@ -70,57 +50,19 @@ RSpec/NamedSubject:
70
50
  - 'spec/models/spree/volume_price_spec.rb'
71
51
 
72
52
  # Offense count: 74
53
+ # Configuration parameters: AllowedGroups.
73
54
  RSpec/NestedGroups:
74
55
  Max: 7
75
56
 
76
- # Offense count: 1
77
- # Configuration parameters: Include.
78
- # Include: db/migrate/*.rb
79
- Rails/CreateTableWithTimestamps:
80
- Exclude:
81
- - 'db/migrate/20150603143015_create_spree_volume_price_models.rb'
82
-
83
- # Offense count: 1
84
- # Configuration parameters: Include.
85
- # Include: app/models/**/*.rb
86
- Rails/HasManyOrHasOneDependent:
57
+ # Offense count: 2
58
+ RSpec/RepeatedExampleGroupDescription:
87
59
  Exclude:
88
- - 'app/models/spree/volume_price_model.rb'
60
+ - 'spec/lib/solidus_volume_pricing/range_from_string_spec.rb'
89
61
 
90
62
  # Offense count: 2
91
- # Configuration parameters: Include.
63
+ # Configuration parameters: IgnoreScopes, Include.
92
64
  # Include: app/models/**/*.rb
93
65
  Rails/InverseOf:
94
66
  Exclude:
95
67
  - 'app/models/spree/volume_price.rb'
96
68
  - 'app/models/spree/volume_price_model.rb'
97
-
98
- # Offense count: 1
99
- # Configuration parameters: Include.
100
- # Include: app/controllers/**/*.rb
101
- Rails/LexicallyScopedActionFilter:
102
- Exclude:
103
- - 'app/controllers/spree/admin/volume_price_models_controller.rb'
104
-
105
- # Offense count: 1
106
- # Configuration parameters: Include.
107
- # Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb
108
- Rails/Output:
109
- Exclude:
110
- - 'lib/generators/solidus_volume_pricing/install/install_generator.rb'
111
-
112
- # Offense count: 2
113
- # Configuration parameters: Blacklist, Whitelist.
114
- # Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters
115
- Rails/SkipsModelValidations:
116
- Exclude:
117
- - 'spec/models/spree/volume_price_spec.rb'
118
-
119
- # Offense count: 2
120
- # Cop supports --auto-correct.
121
- # Configuration parameters: AutoCorrect, EnforcedStyle.
122
- # SupportedStyles: nested, compact
123
- Style/ClassAndModuleChildren:
124
- Exclude:
125
- - 'app/models/spree/volume_price.rb'
126
- - 'app/models/spree/volume_price_model.rb'
data/CHANGELOG.md CHANGED
@@ -1,86 +1,3 @@
1
1
  # Changelog
2
2
 
3
- ## [v1.1.0](https://github.com/solidusio-contrib/solidus_volume_pricing/tree/v1.1.0) (2023-02-09)
4
-
5
- [Full Changelog](https://github.com/solidusio-contrib/solidus_volume_pricing/compare/v1.0.0...v1.1.0)
6
-
7
- **Closed issues:**
8
-
9
- - Dependabot can't resolve your Ruby dependency files [\#57](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/57)
10
- - Prepare Solidus Volume Pricing for Solidus 3.0 [\#53](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/53)
11
- - Dependabot can't resolve your Ruby dependency files [\#52](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/52)
12
- - Dependabot can't resolve your Ruby dependency files [\#51](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/51)
13
- - Role base volume pricing not working [\#47](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/47)
14
- - Dependabot couldn't find a Gemfile-local for this project [\#44](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/44)
15
- - Dependabot can't resolve your Ruby dependency files [\#42](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/42)
16
- - Dependabot can't resolve your Ruby dependency files [\#41](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/41)
17
- - Dependabot can't resolve your Ruby dependency files [\#40](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/40)
18
- - Dependabot can't resolve your Ruby dependency files [\#39](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/39)
19
- - Dependabot can't resolve your Ruby dependency files [\#38](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/38)
20
- - Dependabot can't resolve your Ruby dependency files [\#37](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/37)
21
- - Dependabot can't resolve your Ruby dependency files [\#36](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/36)
22
- - Dependabot can't resolve your Ruby dependency files [\#35](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/35)
23
- - Can we get a new release? [\#29](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/29)
24
-
25
- **Merged pull requests:**
26
-
27
- - Update supported ruby version [\#66](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/66) ([mcrisologo](https://github.com/mcrisologo))
28
- - Bump version to 1.1.0 [\#65](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/65) ([mcrisologo](https://github.com/mcrisologo))
29
- - Update to use forked solidus\_frontend when needed [\#64](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/64) ([waiting-for-dev](https://github.com/waiting-for-dev))
30
- - Configure autoloader to ignore decorators [\#61](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/61) ([pelargir](https://github.com/pelargir))
31
- - Updating gemspec for Ruby 3 support [\#60](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/60) ([embold-given](https://github.com/embold-given))
32
- - Solidus 3 preparation [\#59](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/59) ([cpfergus1](https://github.com/cpfergus1))
33
- - Upgrade to GitHub-native Dependabot [\#58](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/58) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
34
- - Relax solidus\_support dependency [\#50](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/50) ([kennyadsl](https://github.com/kennyadsl))
35
- - Fix Dependabot looking for Gemfile-local [\#48](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/48) ([aldesantis](https://github.com/aldesantis))
36
- - Fix role discounts [\#46](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/46) ([hrdchz](https://github.com/hrdchz))
37
- - Rerun dev tools extension update command to improve the structure [\#45](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/45) ([blocknotes](https://github.com/blocknotes))
38
- - Upgrade the extension using solidus\_dev\_support [\#43](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/43) ([blocknotes](https://github.com/blocknotes))
39
-
40
- ## [v1.0.0](https://github.com/solidusio-contrib/solidus_volume_pricing/tree/v1.0.0) (2019-11-23)
41
-
42
- [Full Changelog](https://github.com/solidusio-contrib/solidus_volume_pricing/compare/v0.2.1...v1.0.0)
43
-
44
- **Implemented enhancements:**
45
-
46
- - Replace `I18n.t` with `t` in views [\#22](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/22)
47
-
48
- **Closed issues:**
49
-
50
- - can we create packs of product by this ? [\#13](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/13)
51
- - Rails v 5.0.1 [\#8](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/8)
52
-
53
- **Merged pull requests:**
54
-
55
- - Replace I18n.t with t in views [\#34](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/34) ([aldesantis](https://github.com/aldesantis))
56
- - Reformat readme [\#33](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/33) ([aldesantis](https://github.com/aldesantis))
57
- - Adopt solidus\_extension\_dev\_tools [\#32](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/32) ([aldesantis](https://github.com/aldesantis))
58
- - Switch to sassc/rails [\#30](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/30) ([pelargir](https://github.com/pelargir))
59
- - Update pg requirement from ~\> 0.21 to ~\> 1.1 [\#27](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/27) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
60
- - Update coffee-rails requirement from ~\> 4.0 to ~\> 5.0 [\#26](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/26) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
61
- - Adopt CircleCI instead of Travis [\#23](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/23) ([aldesantis](https://github.com/aldesantis))
62
- - Solidus 2.4 UI updates [\#21](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/21) ([tvdeyen](https://github.com/tvdeyen))
63
- - Test suite maintenance [\#20](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/20) ([aitbw](https://github.com/aitbw))
64
- - Remove 2.2 from CI \(EOL\) [\#19](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/19) ([jacobherrington](https://github.com/jacobherrington))
65
- - Remove versions past EOL from .travis.yml [\#17](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/17) ([jacobherrington](https://github.com/jacobherrington))
66
- - Add Solidus 2.1-2.7 to .travis.yml [\#16](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/16) ([jacobherrington](https://github.com/jacobherrington))
67
- - Remove deprecated icon option from button [\#12](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/12) ([pelargir](https://github.com/pelargir))
68
- - V2.1 [\#11](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/11) ([seand7565](https://github.com/seand7565))
69
- - Role fix [\#9](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/9) ([Senjai](https://github.com/Senjai))
70
- - 1.0 fixes [\#7](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/7) ([tvdeyen](https://github.com/tvdeyen))
71
- - Add pricers to calculate volume prices [\#4](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/4) ([tvdeyen](https://github.com/tvdeyen))
72
- - Remove String monkey patch [\#3](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/3) ([tvdeyen](https://github.com/tvdeyen))
73
- - Solidus 1.3 [\#2](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/2) ([tvdeyen](https://github.com/tvdeyen))
74
- - Rename to solidus [\#1](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/1) ([tvdeyen](https://github.com/tvdeyen))
75
-
76
- ## [v0.2.1](https://github.com/solidusio-contrib/solidus_volume_pricing/tree/v0.2.1) (2017-01-20)
77
-
78
- [Full Changelog](https://github.com/solidusio-contrib/solidus_volume_pricing/compare/v0.1.1...v0.2.1)
79
-
80
- ## [v0.1.1](https://github.com/solidusio-contrib/solidus_volume_pricing/tree/v0.1.1) (2017-01-20)
81
-
82
- [Full Changelog](https://github.com/solidusio-contrib/solidus_volume_pricing/compare/9bcf78426749d2d73878c6c7c8eb3bf0e5747ada...v0.1.1)
83
-
84
-
85
-
86
- \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
3
+ See https://github.com/solidusio-contrib/solidus_volume_pricing/releases or [OLD_CHANGELOG.md](OLD_CHANGELOG.md) for older versions.
data/Gemfile CHANGED
@@ -3,14 +3,11 @@
3
3
  source 'https://rubygems.org'
4
4
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
5
 
6
- branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
7
- solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2')
8
- %w[solidusio/solidus solidusio/solidus_frontend]
9
- else
10
- %w[solidusio/solidus] * 2
11
- end
12
- gem 'solidus', github: solidus_git, branch: branch
13
- gem 'solidus_frontend', github: solidus_frontend_git, branch: branch
6
+ branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
7
+ gem 'solidus', github: 'solidusio/solidus', branch: branch
8
+
9
+ # The solidus_frontend gem has been pulled out since v3.2
10
+ gem 'solidus_frontend'
14
11
 
15
12
  # Needed to help Bundler figure out how to resolve dependencies,
16
13
  # otherwise it takes forever to resolve them.
@@ -20,7 +17,7 @@ gem 'rails', '>0.a'
20
17
  # Provides basic authentication functionality for testing parts of your engine
21
18
  gem 'solidus_auth_devise'
22
19
 
23
- case ENV['DB']
20
+ case ENV.fetch('DB', nil)
24
21
  when 'mysql'
25
22
  gem 'mysql2'
26
23
  when 'postgresql'
@@ -29,8 +26,16 @@ else
29
26
  gem 'sqlite3'
30
27
  end
31
28
 
29
+ # While we still support Ruby < 3 we need to workaround a limitation in
30
+ # the 'async' gem that relies on the latest ruby, since RubyGems doesn't
31
+ # resolve gems based on the required ruby version.
32
+ gem 'async', '< 3' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3')
33
+
32
34
  gemspec
33
35
 
34
36
  # Use a local Gemfile to include development dependencies that might not be
35
- # relevant for the project or for other contributors, e.g.: `gem 'pry-debug'`.
36
- send :eval_gemfile, 'Gemfile-local' if File.exist? 'Gemfile-local'
37
+ # relevant for the project or for other contributors, e.g. pry-byebug.
38
+ #
39
+ # We use `send` instead of calling `eval_gemfile` to work around an issue with
40
+ # how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
41
+ send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
data/OLD_CHANGELOG.md ADDED
@@ -0,0 +1,86 @@
1
+ # Changelog
2
+
3
+ ## [v1.1.0](https://github.com/solidusio-contrib/solidus_volume_pricing/tree/v1.1.0) (2023-02-09)
4
+
5
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_volume_pricing/compare/v1.0.0...v1.1.0)
6
+
7
+ **Closed issues:**
8
+
9
+ - Dependabot can't resolve your Ruby dependency files [\#57](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/57)
10
+ - Prepare Solidus Volume Pricing for Solidus 3.0 [\#53](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/53)
11
+ - Dependabot can't resolve your Ruby dependency files [\#52](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/52)
12
+ - Dependabot can't resolve your Ruby dependency files [\#51](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/51)
13
+ - Role base volume pricing not working [\#47](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/47)
14
+ - Dependabot couldn't find a Gemfile-local for this project [\#44](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/44)
15
+ - Dependabot can't resolve your Ruby dependency files [\#42](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/42)
16
+ - Dependabot can't resolve your Ruby dependency files [\#41](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/41)
17
+ - Dependabot can't resolve your Ruby dependency files [\#40](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/40)
18
+ - Dependabot can't resolve your Ruby dependency files [\#39](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/39)
19
+ - Dependabot can't resolve your Ruby dependency files [\#38](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/38)
20
+ - Dependabot can't resolve your Ruby dependency files [\#37](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/37)
21
+ - Dependabot can't resolve your Ruby dependency files [\#36](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/36)
22
+ - Dependabot can't resolve your Ruby dependency files [\#35](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/35)
23
+ - Can we get a new release? [\#29](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/29)
24
+
25
+ **Merged pull requests:**
26
+
27
+ - Update supported ruby version [\#66](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/66) ([mcrisologo](https://github.com/mcrisologo))
28
+ - Bump version to 1.1.0 [\#65](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/65) ([mcrisologo](https://github.com/mcrisologo))
29
+ - Update to use forked solidus\_frontend when needed [\#64](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/64) ([waiting-for-dev](https://github.com/waiting-for-dev))
30
+ - Configure autoloader to ignore decorators [\#61](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/61) ([pelargir](https://github.com/pelargir))
31
+ - Updating gemspec for Ruby 3 support [\#60](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/60) ([embold-given](https://github.com/embold-given))
32
+ - Solidus 3 preparation [\#59](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/59) ([cpfergus1](https://github.com/cpfergus1))
33
+ - Upgrade to GitHub-native Dependabot [\#58](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/58) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
34
+ - Relax solidus\_support dependency [\#50](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/50) ([kennyadsl](https://github.com/kennyadsl))
35
+ - Fix Dependabot looking for Gemfile-local [\#48](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/48) ([aldesantis](https://github.com/aldesantis))
36
+ - Fix role discounts [\#46](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/46) ([hrdchz](https://github.com/hrdchz))
37
+ - Rerun dev tools extension update command to improve the structure [\#45](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/45) ([blocknotes](https://github.com/blocknotes))
38
+ - Upgrade the extension using solidus\_dev\_support [\#43](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/43) ([blocknotes](https://github.com/blocknotes))
39
+
40
+ ## [v1.0.0](https://github.com/solidusio-contrib/solidus_volume_pricing/tree/v1.0.0) (2019-11-23)
41
+
42
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_volume_pricing/compare/v0.2.1...v1.0.0)
43
+
44
+ **Implemented enhancements:**
45
+
46
+ - Replace `I18n.t` with `t` in views [\#22](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/22)
47
+
48
+ **Closed issues:**
49
+
50
+ - can we create packs of product by this ? [\#13](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/13)
51
+ - Rails v 5.0.1 [\#8](https://github.com/solidusio-contrib/solidus_volume_pricing/issues/8)
52
+
53
+ **Merged pull requests:**
54
+
55
+ - Replace I18n.t with t in views [\#34](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/34) ([aldesantis](https://github.com/aldesantis))
56
+ - Reformat readme [\#33](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/33) ([aldesantis](https://github.com/aldesantis))
57
+ - Adopt solidus\_extension\_dev\_tools [\#32](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/32) ([aldesantis](https://github.com/aldesantis))
58
+ - Switch to sassc/rails [\#30](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/30) ([pelargir](https://github.com/pelargir))
59
+ - Update pg requirement from ~\> 0.21 to ~\> 1.1 [\#27](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/27) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
60
+ - Update coffee-rails requirement from ~\> 4.0 to ~\> 5.0 [\#26](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/26) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
61
+ - Adopt CircleCI instead of Travis [\#23](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/23) ([aldesantis](https://github.com/aldesantis))
62
+ - Solidus 2.4 UI updates [\#21](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/21) ([tvdeyen](https://github.com/tvdeyen))
63
+ - Test suite maintenance [\#20](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/20) ([aitbw](https://github.com/aitbw))
64
+ - Remove 2.2 from CI \(EOL\) [\#19](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/19) ([jacobherrington](https://github.com/jacobherrington))
65
+ - Remove versions past EOL from .travis.yml [\#17](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/17) ([jacobherrington](https://github.com/jacobherrington))
66
+ - Add Solidus 2.1-2.7 to .travis.yml [\#16](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/16) ([jacobherrington](https://github.com/jacobherrington))
67
+ - Remove deprecated icon option from button [\#12](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/12) ([pelargir](https://github.com/pelargir))
68
+ - V2.1 [\#11](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/11) ([seand7565](https://github.com/seand7565))
69
+ - Role fix [\#9](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/9) ([Senjai](https://github.com/Senjai))
70
+ - 1.0 fixes [\#7](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/7) ([tvdeyen](https://github.com/tvdeyen))
71
+ - Add pricers to calculate volume prices [\#4](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/4) ([tvdeyen](https://github.com/tvdeyen))
72
+ - Remove String monkey patch [\#3](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/3) ([tvdeyen](https://github.com/tvdeyen))
73
+ - Solidus 1.3 [\#2](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/2) ([tvdeyen](https://github.com/tvdeyen))
74
+ - Rename to solidus [\#1](https://github.com/solidusio-contrib/solidus_volume_pricing/pull/1) ([tvdeyen](https://github.com/tvdeyen))
75
+
76
+ ## [v0.2.1](https://github.com/solidusio-contrib/solidus_volume_pricing/tree/v0.2.1) (2017-01-20)
77
+
78
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_volume_pricing/compare/v0.1.1...v0.2.1)
79
+
80
+ ## [v0.1.1](https://github.com/solidusio-contrib/solidus_volume_pricing/tree/v0.1.1) (2017-01-20)
81
+
82
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_volume_pricing/compare/9bcf78426749d2d73878c6c7c8eb3bf0e5747ada...v0.1.1)
83
+
84
+
85
+
86
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/Rakefile CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'bundler/gem_tasks'
4
+
3
5
  require 'solidus_dev_support/rake_tasks'
4
6
  SolidusDevSupport::RakeTasks.install
5
7
 
@@ -3,7 +3,7 @@
3
3
  module Spree
4
4
  module Admin
5
5
  class VolumePriceModelsController < ResourceController
6
- before_action :load_volume_prices, only: [:new, :edit]
6
+ before_action :load_volume_prices, only: [:new, :edit] # rubocop:disable Rails/LexicallyScopedActionFilter
7
7
 
8
8
  private
9
9
 
@@ -7,11 +7,13 @@ module SolidusVolumePricing
7
7
  base.class_eval do
8
8
  has_and_belongs_to_many :volume_price_models
9
9
  has_many :volume_prices, -> { order(position: :asc) }, dependent: :destroy
10
- has_many :model_volume_prices, -> { order(position: :asc) }, class_name: '::Spree::VolumePrice', through: :volume_price_models, source: :volume_prices
10
+ has_many :model_volume_prices, -> {
11
+ order(position: :asc)
12
+ }, class_name: '::Spree::VolumePrice', through: :volume_price_models, source: :volume_prices
11
13
  accepts_nested_attributes_for :volume_prices, allow_destroy: true,
12
- reject_if: proc { |volume_price|
13
- volume_price[:amount].blank? && volume_price[:range].blank?
14
- }
14
+ reject_if: proc { |volume_price|
15
+ volume_price[:amount].blank? && volume_price[:range].blank?
16
+ }
15
17
  end
16
18
  end
17
19
 
@@ -1,52 +1,52 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Spree::VolumePrice < ApplicationRecord
4
- belongs_to :variant, touch: true, optional: true
5
- belongs_to :volume_price_model, touch: true, optional: true
6
- belongs_to :spree_role, class_name: 'Spree::Role', foreign_key: 'role_id', optional: true
7
- acts_as_list scope: [:variant_id, :volume_price_model_id]
8
-
9
- validates :amount, presence: true
10
- validates :discount_type,
11
- presence: true,
12
- inclusion: {
13
- in: %w(price dollar percent)
14
- }
15
-
16
- validate :range_format
17
-
18
- def self.for_variant(variant, user: nil)
19
- roles = [nil]
20
- if user
21
- user.spree_roles.each {|r| roles << r.id}
3
+ module Spree
4
+ class VolumePrice < ApplicationRecord
5
+ belongs_to :variant, touch: true, optional: true
6
+ belongs_to :volume_price_model, touch: true, optional: true
7
+ belongs_to :spree_role, class_name: 'Spree::Role', foreign_key: 'role_id', optional: true
8
+ acts_as_list scope: [:variant_id, :volume_price_model_id]
9
+
10
+ validates :amount, presence: true
11
+ validates :discount_type,
12
+ presence: true,
13
+ inclusion: {
14
+ in: %w(price dollar percent)
15
+ }
16
+
17
+ validate :range_format
18
+
19
+ def self.for_variant(variant, user: nil)
20
+ roles = [nil]
21
+ user&.spree_roles&.each { |r| roles << r.id }
22
+
23
+ where(
24
+ arel_table[:variant_id].eq(variant.id).
25
+ or(
26
+ arel_table[:volume_price_model_id].in(variant.volume_price_model_ids)
27
+ )
28
+ ).
29
+ where(role_id: roles).
30
+ order(position: :asc, amount: :asc)
22
31
  end
23
32
 
24
- where(
25
- arel_table[:variant_id].eq(variant.id).
26
- or(
27
- arel_table[:volume_price_model_id].in(variant.volume_price_model_ids)
28
- )
29
- ).
30
- where(role_id: roles).
31
- order(position: :asc, amount: :asc)
32
- end
33
-
34
- delegate :include?, to: :range_from_string
33
+ delegate :include?, to: :range_from_string
35
34
 
36
- def display_range
37
- range.gsub(/\.+/, "-").gsub(/\(|\)/, '')
38
- end
35
+ def display_range
36
+ range.gsub(/\.+/, "-").gsub(/\(|\)/, '')
37
+ end
39
38
 
40
- private
39
+ private
41
40
 
42
- def range_format
43
- if !(SolidusVolumePricing::RangeFromString::RANGE_FORMAT =~ range ||
44
- SolidusVolumePricing::RangeFromString::OPEN_ENDED =~ range)
45
- errors.add(:range, :must_be_in_format)
41
+ def range_format
42
+ if !(SolidusVolumePricing::RangeFromString::RANGE_FORMAT =~ range ||
43
+ SolidusVolumePricing::RangeFromString::OPEN_ENDED =~ range)
44
+ errors.add(:range, :must_be_in_format)
45
+ end
46
46
  end
47
- end
48
47
 
49
- def range_from_string
50
- SolidusVolumePricing::RangeFromString.new(range).to_range
48
+ def range_from_string
49
+ SolidusVolumePricing::RangeFromString.new(range).to_range
50
+ end
51
51
  end
52
52
  end
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Spree::VolumePriceModel < ApplicationRecord
4
- has_many :variants
5
- has_many :volume_prices, -> { order(position: :asc) }, dependent: :destroy
6
- accepts_nested_attributes_for :volume_prices, allow_destroy: true,
7
- reject_if: proc { |volume_price|
8
- volume_price[:amount].blank? && volume_price[:range].blank?
9
- }
3
+ module Spree
4
+ class VolumePriceModel < ApplicationRecord
5
+ has_many :variants, dependent: :nullify
6
+ has_many :volume_prices, -> { order(position: :asc) }, dependent: :destroy
7
+ accepts_nested_attributes_for :volume_prices, allow_destroy: true,
8
+ reject_if: proc { |volume_price|
9
+ volume_price[:amount].blank? && volume_price[:range].blank?
10
+ }
11
+ end
10
12
  end
@@ -0,0 +1,3 @@
1
+ <!-- insert_bottom '[data-hook="admin_product_tabs"]' -->
2
+
3
+ <%= render 'spree/admin/shared/vp_product_tab', current: current %>
@@ -0,0 +1,3 @@
1
+ <!-- insert_after '[data-hook="admin_variant_edit_form"]' -->
2
+
3
+ <%= render 'spree/admin/variants/edit_fields', f: f %>
data/bin/rails CHANGED
@@ -1,15 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # frozen_string_literal: true
4
-
5
- app_root = 'spec/dummy'
6
-
7
- unless File.exist? "#{app_root}/bin/rails"
8
- system "bin/rake", app_root or begin # rubocop:disable Style/AndOr
9
- warn "Automatic creation of the dummy app failed"
10
- exit 1
11
- end
3
+ if %w[g generate].include? ARGV.first
4
+ exec "#{__dir__}/rails-engine", *ARGV
5
+ else
6
+ exec "#{__dir__}/rails-sandbox", *ARGV
12
7
  end
13
-
14
- Dir.chdir app_root
15
- exec 'bin/rails', *ARGV
data/bin/rails-engine ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('..', __dir__)
6
+ ENGINE_PATH = File.expand_path('../lib/solidus_volume_pricing/engine', __dir__)
7
+
8
+ # Set up gems listed in the Gemfile.
9
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
10
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
11
+
12
+ require 'rails/all'
13
+ require 'rails/engine/commands'
data/bin/rails-sandbox ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ app_root = 'sandbox'
4
+
5
+ unless File.exist? "#{app_root}/bin/rails"
6
+ warn 'Creating the sandbox app...'
7
+ Dir.chdir "#{__dir__}/.." do
8
+ system "#{__dir__}/sandbox" or begin
9
+ warn 'Automatic creation of the sandbox app failed'
10
+ exit 1
11
+ end
12
+ end
13
+ end
14
+
15
+ Dir.chdir app_root
16
+ exec 'bin/rails', *ARGV
data/bin/rake ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "rubygems"
5
+ require "bundler/setup"
6
+
7
+ load Gem.bin_path("rake", "rake")
data/bin/sandbox ADDED
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+ test -z "${DEBUG+empty_string}" || set -x
5
+
6
+ test "$DB" = "sqlite" && export DB="sqlite3"
7
+
8
+ if [ -z "$SOLIDUS_BRANCH" ]
9
+ then
10
+ echo "~~> Use 'export SOLIDUS_BRANCH=[master|v3.2|...]' to control the Solidus branch"
11
+ SOLIDUS_BRANCH="master"
12
+ fi
13
+ echo "~~> Using branch $SOLIDUS_BRANCH of solidus"
14
+
15
+ if [ -z "$SOLIDUS_FRONTEND" ]
16
+ then
17
+ echo "~~> Use 'export SOLIDUS_FRONTEND=[solidus_frontend|solidus_starter_frontend]' to control the Solidus frontend"
18
+ SOLIDUS_FRONTEND="solidus_frontend"
19
+ fi
20
+ echo "~~> Using branch $SOLIDUS_FRONTEND as the solidus frontend"
21
+
22
+ extension_name="solidus_volume_pricing"
23
+
24
+ # Stay away from the bundler env of the containing extension.
25
+ function unbundled {
26
+ ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@
27
+ }
28
+
29
+ rm -rf ./sandbox
30
+ unbundled bundle exec rails new sandbox \
31
+ --database="${DB:-sqlite3}" \
32
+ --skip-bundle \
33
+ --skip-git \
34
+ --skip-keeps \
35
+ --skip-rc \
36
+ --skip-spring \
37
+ --skip-test \
38
+ --skip-javascript
39
+
40
+ if [ ! -d "sandbox" ]; then
41
+ echo 'sandbox rails application failed'
42
+ exit 1
43
+ fi
44
+
45
+ cd ./sandbox
46
+ cat <<RUBY >> Gemfile
47
+ gem 'solidus', github: 'solidusio/solidus', branch: '$SOLIDUS_BRANCH'
48
+ gem 'rails-i18n'
49
+ gem 'solidus_i18n'
50
+
51
+ gem '$extension_name', path: '..'
52
+
53
+ group :test, :development do
54
+ platforms :mri do
55
+ gem 'pry-byebug'
56
+ end
57
+ end
58
+ RUBY
59
+
60
+ unbundled bundle install --gemfile Gemfile
61
+
62
+ unbundled bundle exec rake db:drop db:create
63
+
64
+ unbundled bundle exec rails generate solidus:install \
65
+ --auto-accept \
66
+ --user_class=Spree::User \
67
+ --enforce_available_locales=true \
68
+ --with-authentication=true \
69
+ --payment-method=none \
70
+ --frontend=${SOLIDUS_FRONTEND} \
71
+ $@
72
+
73
+ unbundled bundle exec rails generate solidus:auth:install --auto-run-migrations
74
+ unbundled bundle exec rails generate ${extension_name}:install --auto-run-migrations
75
+
76
+ echo
77
+ echo "🚀 Sandbox app successfully created for $extension_name!"
78
+ echo "🧪 This app is intended for test purposes."
data/bin/setup CHANGED
@@ -5,4 +5,4 @@ set -vx
5
5
 
6
6
  gem install bundler --conservative
7
7
  bundle update
8
- bundle exec rake clobber
8
+ bin/rake clobber
@@ -10,6 +10,7 @@ class CreateSpreeVolumePriceModels < ActiveRecord::Migration[4.2]
10
10
  create_table :spree_variants_volume_price_models do |t|
11
11
  t.belongs_to :volume_price_model
12
12
  t.belongs_to :variant
13
+ t.timestamps
13
14
  end
14
15
 
15
16
  add_reference :spree_volume_prices, :volume_price_model
@@ -5,18 +5,20 @@ module SolidusVolumePricing
5
5
  class InstallGenerator < Rails::Generators::Base
6
6
  class_option :auto_run_migrations, type: :boolean, default: false
7
7
 
8
+ def self.exit_on_failure?
9
+ true
10
+ end
11
+
8
12
  def add_migrations
9
- run 'bundle exec rake railties:install:migrations FROM=solidus_volume_pricing'
13
+ run 'bin/rails railties:install:migrations FROM=solidus_volume_pricing'
10
14
  end
11
15
 
12
16
  def run_migrations
13
- run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(
14
- ask('Would you like to run the migrations now? [Y/n]')
15
- )
17
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Layout/LineLength
16
18
  if run_migrations
17
- run 'bundle exec rake db:migrate'
19
+ run 'bin/rails db:migrate'
18
20
  else
19
- puts 'Skipping rake db:migrate, don\'t forget to run it!'
21
+ puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
20
22
  end
21
23
  end
22
24
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'spree/core'
4
+ require 'solidus_support'
4
5
 
5
6
  module SolidusVolumePricing
6
7
  class Engine < Rails::Engine
@@ -17,7 +18,7 @@ module SolidusVolumePricing
17
18
  end
18
19
 
19
20
  def self.activate
20
- Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
21
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')).sort.each do |c|
21
22
  Rails.configuration.cache_classes ? require(c) : load(c)
22
23
  Rails.autoloaders.main.ignore(c) if Rails.autoloaders.zeitwerk_enabled?
23
24
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusVolumePricing
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.0'
5
5
  end
@@ -1,43 +1,41 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- $:.push File.expand_path('lib', __dir__)
4
- require 'solidus_volume_pricing/version'
5
-
6
- Gem::Specification.new do |s|
7
- s.platform = Gem::Platform::RUBY
8
- s.name = 'solidus_volume_pricing'
9
- s.version = SolidusVolumePricing::VERSION
10
- s.summary = 'Allow prices to be configured in quantity ranges for each variant'
11
- s.description = s.summary
12
-
13
- s.required_ruby_version = '>= 2.5'
14
-
15
- s.author = 'Sean Schofield'
16
- s.email = 'sean@railsdog.com'
17
- s.homepage = 'https://github.com/solidusio-contrib/solidus_volume_pricing'
18
- s.license = 'BSD-3-Clause'
19
-
20
- s.files = Dir.chdir(File.expand_path(__dir__)) do
21
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
- end
23
- s.test_files = Dir['spec/**/*']
24
- s.bindir = "exe"
25
- s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
- s.require_paths = ["lib"]
27
-
28
- if s.respond_to?(:metadata)
29
- s.metadata["homepage_uri"] = s.homepage if s.homepage
30
- s.metadata["source_code_uri"] = s.homepage if s.homepage
31
- end
32
-
33
- s.add_runtime_dependency 'solidus_backend', ['>= 2.4.0', '< 4']
34
-
35
- s.add_dependency 'coffee-rails'
36
- s.add_dependency 'deface'
37
- s.add_dependency 'sassc-rails'
38
- s.add_dependency 'solidus_core', ['>= 2.4.0', '< 4']
39
- s.add_dependency 'solidus_support', '~> 0.8'
40
-
41
- s.add_development_dependency 'shoulda-matchers'
42
- s.add_development_dependency 'solidus_dev_support'
3
+ require_relative 'lib/solidus_volume_pricing/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'solidus_volume_pricing'
7
+ spec.version = SolidusVolumePricing::VERSION
8
+ spec.authors = ['Sean Schofield']
9
+ spec.email = 'sean@railsdog.com'
10
+
11
+ spec.summary = 'Allow prices to be configured in quantity ranges for each variant'
12
+ spec.description = 'Allow prices to be configured in quantity ranges for each variant'
13
+ spec.homepage = 'https://github.com/solidusio-contrib/solidus_volume_pricing'
14
+ spec.license = 'BSD-3-Clause'
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = 'https://github.com/solidusio-contrib/solidus_volume_pricing'
18
+ spec.metadata['changelog_uri'] = 'https://github.com/solidusio-contrib/solidus_volume_pricing/releases'
19
+
20
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5', '< 4')
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
25
+
26
+ spec.files = files.grep_v(%r{^(test|spec|features)/})
27
+ spec.test_files = files.grep(%r{^(test|spec|features)/})
28
+ spec.bindir = "exe"
29
+ spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_runtime_dependency 'solidus_backend', ['>= 2.4.0', '< 5']
33
+ spec.add_dependency 'coffee-rails'
34
+ spec.add_dependency 'deface'
35
+ spec.add_dependency 'sassc-rails'
36
+ spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 5']
37
+ spec.add_dependency 'solidus_support', '~> 0.8'
38
+
39
+ spec.add_development_dependency 'shoulda-matchers'
40
+ spec.add_development_dependency 'solidus_dev_support', '~> 2.6'
43
41
  end
@@ -3,7 +3,7 @@
3
3
  RSpec.describe Spree::Admin::VariantsController, type: :controller do
4
4
  stub_authorization!
5
5
 
6
- context 'PUT #update' do
6
+ describe 'PUT #update' do
7
7
  it 'creates a volume price' do
8
8
  variant = create :variant
9
9
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- RSpec.describe 'Managing volume price models' do
5
+ RSpec.describe 'Managing volume price models', type: :system do
6
6
  stub_authorization!
7
7
 
8
8
  it 'an admin can create and remove volume price models', :js do
@@ -30,13 +30,13 @@ RSpec.describe SolidusVolumePricing::RangeFromString do
30
30
  it { is_expected.to eq(1...2) }
31
31
  end
32
32
 
33
- context 'with an open-ended string like #{x}+' do
33
+ context 'with an open-ended string like x+' do
34
34
  let(:argument) { '10+' }
35
35
 
36
36
  it { is_expected.to eq(10..Float::INFINITY) }
37
37
  end
38
38
 
39
- context 'with an open-ended string like #{x}+ and parens' do
39
+ context 'with an open-ended string like x+" and parens' do
40
40
  let(:argument) { '(10+)' }
41
41
 
42
42
  it { is_expected.to eq(10..Float::INFINITY) }
data/spec/spec_helper.rb CHANGED
@@ -1,24 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Configure Rails Environment
4
- ENV['RAILS_ENV'] ||= 'test'
4
+ ENV['RAILS_ENV'] = 'test'
5
5
 
6
6
  # Run Coverage report
7
7
  require 'solidus_dev_support/rspec/coverage'
8
8
 
9
- require File.expand_path('dummy/config/environment.rb', __dir__)
9
+ # Create the dummy app if it's still missing.
10
+ dummy_env = "#{__dir__}/dummy/config/environment.rb"
11
+ system 'bin/rake extension:test_app' unless File.exist? dummy_env
12
+ require dummy_env
10
13
 
11
14
  # Requires factories and other useful helpers defined in spree_core.
12
15
  require 'solidus_dev_support/rspec/feature_helper'
13
16
 
14
17
  # Requires supporting ruby files with custom matchers and macros, etc,
15
18
  # in spec/support/ and its subdirectories.
16
- Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
19
+ Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }
17
20
 
18
- # Requires factories defined in lib/solidus_volume_pricing/testing_support/factories.rb
21
+ # Requires factories defined in Solidus core and this extension.
22
+ # See: lib/solidus_volume_pricing/testing_support/factories.rb
19
23
  SolidusDevSupport::TestingSupport::Factories.load_for(SolidusVolumePricing::Engine)
20
24
 
21
25
  RSpec.configure do |config|
22
26
  config.infer_spec_type_from_file_location!
23
27
  config.use_transactional_fixtures = false
28
+
29
+ if Spree.solidus_gem_version < Gem::Version.new('2.11')
30
+ config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system
31
+ end
24
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_volume_pricing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-09 00:00:00.000000000 Z
11
+ date: 2024-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_backend
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 2.4.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '4'
22
+ version: '5'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 2.4.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '4'
32
+ version: '5'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: coffee-rails
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -78,20 +78,20 @@ dependencies:
78
78
  requirements:
79
79
  - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: 2.4.0
81
+ version: 2.0.0
82
82
  - - "<"
83
83
  - !ruby/object:Gem::Version
84
- version: '4'
84
+ version: '5'
85
85
  type: :runtime
86
86
  prerelease: false
87
87
  version_requirements: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - ">="
90
90
  - !ruby/object:Gem::Version
91
- version: 2.4.0
91
+ version: 2.0.0
92
92
  - - "<"
93
93
  - !ruby/object:Gem::Version
94
- version: '4'
94
+ version: '5'
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: solidus_support
97
97
  requirement: !ruby/object:Gem::Requirement
@@ -124,16 +124,16 @@ dependencies:
124
124
  name: solidus_dev_support
125
125
  requirement: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - ">="
127
+ - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '0'
129
+ version: '2.6'
130
130
  type: :development
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
- - - ">="
134
+ - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: '0'
136
+ version: '2.6'
137
137
  description: Allow prices to be configured in quantity ranges for each variant
138
138
  email: sean@railsdog.com
139
139
  executables: []
@@ -144,6 +144,7 @@ files:
144
144
  - ".gem_release.yml"
145
145
  - ".github/dependabot.yml"
146
146
  - ".github/stale.yml"
147
+ - ".github_changelog_generator"
147
148
  - ".gitignore"
148
149
  - ".rspec"
149
150
  - ".rubocop.yml"
@@ -152,6 +153,7 @@ files:
152
153
  - Gemfile
153
154
  - Guardfile
154
155
  - LICENSE
156
+ - OLD_CHANGELOG.md
155
157
  - README.md
156
158
  - Rakefile
157
159
  - app/assets/javascripts/spree/backend/solidus_volume_pricing.js
@@ -166,8 +168,9 @@ files:
166
168
  - app/models/solidus_volume_pricing/pricing_options.rb
167
169
  - app/models/spree/volume_price.rb
168
170
  - app/models/spree/volume_price_model.rb
171
+ - app/overrides/spree/admin/shared/_product_tabs/add_volume_pricing_admin_tab.html.erb.deface
169
172
  - app/overrides/spree/admin/shared/_settings_sub_menu/add_volume_price_model_admin_menu_links.html.erb.deface
170
- - app/overrides/views_decorator.rb
173
+ - app/overrides/spree/admin/variants/edit/add_volume_pricing_field_to_variant.html.erb.deface
171
174
  - app/views/spree/admin/shared/_vp_product_tab.html.erb
172
175
  - app/views/spree/admin/variants/_edit_fields.html.erb
173
176
  - app/views/spree/admin/variants/volume_prices.html.erb
@@ -182,6 +185,10 @@ files:
182
185
  - app/views/spree/products/_volume_pricing.html.erb
183
186
  - bin/console
184
187
  - bin/rails
188
+ - bin/rails-engine
189
+ - bin/rails-sandbox
190
+ - bin/rake
191
+ - bin/sandbox
185
192
  - bin/setup
186
193
  - config/locales/de.yml
187
194
  - config/locales/en.yml
@@ -222,6 +229,7 @@ licenses:
222
229
  metadata:
223
230
  homepage_uri: https://github.com/solidusio-contrib/solidus_volume_pricing
224
231
  source_code_uri: https://github.com/solidusio-contrib/solidus_volume_pricing
232
+ changelog_uri: https://github.com/solidusio-contrib/solidus_volume_pricing/releases
225
233
  post_install_message:
226
234
  rdoc_options: []
227
235
  require_paths:
@@ -231,13 +239,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
231
239
  - - ">="
232
240
  - !ruby/object:Gem::Version
233
241
  version: '2.5'
242
+ - - "<"
243
+ - !ruby/object:Gem::Version
244
+ version: '4'
234
245
  required_rubygems_version: !ruby/object:Gem::Requirement
235
246
  requirements:
236
247
  - - ">="
237
248
  - !ruby/object:Gem::Version
238
249
  version: '0'
239
250
  requirements: []
240
- rubygems_version: 3.3.7
251
+ rubygems_version: 3.2.33
241
252
  signing_key:
242
253
  specification_version: 4
243
254
  summary: Allow prices to be configured in quantity ranges for each variant
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Deface::Override.new(
4
- virtual_path: 'spree/admin/shared/_product_tabs',
5
- name: 'add_volume_pricing_admin_tab',
6
- insert_bottom: '[data-hook="admin_product_tabs"]',
7
- partial: 'spree/admin/shared/vp_product_tab'
8
- )
9
-
10
- Deface::Override.new(
11
- virtual_path: 'spree/admin/variants/edit',
12
- name: 'add_volume_pricing_field_to_variant',
13
- insert_after: '[data-hook="admin_variant_edit_form"]',
14
- partial: 'spree/admin/variants/edit_fields'
15
- )