solidus_reviews 1.5.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +23 -3
  3. data/.github/stale.yml +1 -0
  4. data/.github_changelog_generator +2 -0
  5. data/.gitignore +1 -0
  6. data/.rubocop.yml +4 -0
  7. data/CHANGELOG.md +1 -153
  8. data/Gemfile +22 -3
  9. data/LICENSE +1 -1
  10. data/OLD_CHANGELOG.md +155 -0
  11. data/README.md +17 -50
  12. data/Rakefile +1 -0
  13. data/app/controllers/spree/reviews_controller.rb +2 -2
  14. data/app/models/spree/review.rb +18 -1
  15. data/app/overrides/spree/products/show/add_reviews_after_product_properties.html.erb.deface +3 -0
  16. data/bin/sandbox +23 -31
  17. data/config/initializers/add_spree_reviews_to_menu.rb +33 -0
  18. data/config/initializers/load_preferences.rb +4 -1
  19. data/lib/controllers/spree/api/feedback_reviews_controller.rb +1 -1
  20. data/lib/generators/solidus_reviews/install/install_generator.rb +9 -0
  21. data/lib/generators/solidus_reviews/install/templates/initializer.rb +6 -0
  22. data/lib/solidus_reviews/configuration.rb +21 -0
  23. data/lib/solidus_reviews/engine.rb +3 -2
  24. data/lib/solidus_reviews/{factories.rb → testing_support/factories.rb} +1 -1
  25. data/lib/solidus_reviews/version.rb +1 -1
  26. data/lib/solidus_reviews.rb +1 -0
  27. data/solidus_reviews.gemspec +6 -4
  28. data/spec/controllers/spree/admin/review_settings_controller_spec.rb +1 -1
  29. data/spec/controllers/spree/admin/reviews_controller_spec.rb +1 -4
  30. data/spec/controllers/spree/reviews_controller_spec.rb +1 -4
  31. data/spec/models/review_spec.rb +12 -0
  32. data/spec/spec_helper.rb +6 -2
  33. metadata +33 -16
  34. data/app/overrides/add_reviews_after_product_properties.rb +0 -7
  35. data/app/overrides/add_reviews_tab_to_admin.rb +0 -20
  36. data/app/overrides/add_reviews_to_admin_configuration_sidebar.rb +0 -20
  37. data/spec/support/factories.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f17ce08e72bf0a578195dda4763786e80ca5ce9b2f9126db7790f3f1571efa10
4
- data.tar.gz: 7ffc6b1fd506cb9d21d5922f5fb049e1574d884ee184e7070a1ae76b3e3eb88a
3
+ metadata.gz: a4e942dd7285deb7b0cf758d8fbe4a953ce2b963633663548973d92d3de96011
4
+ data.tar.gz: 13c4dcf8795994edf582f417d48b584d1cebc8c393656c43d0688a75301aa500
5
5
  SHA512:
6
- metadata.gz: 959becf7cbddb80453025ac7601fa6aa25349849707455839040587612a505c014df75469d529249daba670414bf24e886b355da0426eb60ba3102bc45be38dc
7
- data.tar.gz: d1e7b71a6aad1548bbedef2d40bbbd986ed39b20c1b6133d8ae73decb7cf7c135923c449cb26ce5d221a2604d8d578867ddba9695d116840ea05718705baacfc
6
+ metadata.gz: 32089cd4cb4ab16ef7da9cb8f6f865a01d0e98676f274736a2ec6978227390434b10bbe03ce64e5ee6df3ce9a69c15a306f57fab5164bd65be04ede4e67d090d
7
+ data.tar.gz: b6020cf9ef67a93fee51d2c9622a1b62d1423414396781159048f47965ec0e4b289069fb7576fea5d4aaae9eb02cfdc73abfce6231f6fedd4599734ba1f1cb2e
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,22 +11,38 @@ orbs:
8
11
  solidusio_extensions: solidusio/extensions@volatile
9
12
 
10
13
  jobs:
14
+ run-specs-with-sqlite:
15
+ executor:
16
+ name: solidusio_extensions/sqlite
17
+ ruby_version: "3.0"
18
+ steps:
19
+ - browser-tools/install-chrome
20
+ - solidusio_extensions/run-tests
11
21
  run-specs-with-postgres:
12
- executor: solidusio_extensions/postgres
22
+ executor:
23
+ name: solidusio_extensions/postgres
24
+ ruby_version: "3.0"
13
25
  steps:
26
+ - browser-tools/install-chrome
14
27
  - solidusio_extensions/run-tests
15
28
  run-specs-with-mysql:
16
- executor: solidusio_extensions/mysql
29
+ executor:
30
+ name: solidusio_extensions/mysql
31
+ ruby_version: "3.0"
17
32
  steps:
33
+ - browser-tools/install-chrome
18
34
  - solidusio_extensions/run-tests
19
35
  lint-code:
20
- executor: solidusio_extensions/sqlite-memory
36
+ executor:
37
+ name: solidusio_extensions/sqlite-memory
38
+ ruby_version: "3.0"
21
39
  steps:
22
40
  - solidusio_extensions/lint-code
23
41
 
24
42
  workflows:
25
43
  "Run specs on supported Solidus versions":
26
44
  jobs:
45
+ - run-specs-with-sqlite
27
46
  - run-specs-with-postgres
28
47
  - run-specs-with-mysql
29
48
  - lint-code
@@ -37,5 +56,6 @@ workflows:
37
56
  only:
38
57
  - master
39
58
  jobs:
59
+ - run-specs-with-sqlite
40
60
  - run-specs-with-postgres
41
61
  - run-specs-with-mysql
data/.github/stale.yml ADDED
@@ -0,0 +1 @@
1
+ _extends: .github
@@ -0,0 +1,2 @@
1
+ issues=false
2
+ exclude-labels=infrastructure
data/.gitignore CHANGED
@@ -8,6 +8,7 @@
8
8
  .sass-cache
9
9
  coverage
10
10
  Gemfile.lock
11
+ Gemfile-local
11
12
  tmp
12
13
  nbproject
13
14
  pkg
data/.rubocop.yml CHANGED
@@ -2,3 +2,7 @@ inherit_from: .rubocop_todo.yml
2
2
 
3
3
  require:
4
4
  - solidus_dev_support/rubocop
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 3.0
8
+ NewCops: disable
data/CHANGELOG.md CHANGED
@@ -1,155 +1,3 @@
1
1
  # Changelog
2
2
 
3
- ## [v1.5.0](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.5.0) (2021-09-20)
4
-
5
- [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/v1.4.1...v1.5.0)
6
-
7
- **Closed issues:**
8
-
9
- - Dependabot can't resolve your Ruby dependency files [\#105](https://github.com/solidusio-contrib/solidus_reviews/issues/105)
10
- - Prepare Solidus Reviews for Solidus 3.0 [\#101](https://github.com/solidusio-contrib/solidus_reviews/issues/101)
11
- - Installing fresh solidus and solidus\_reviews, rails g solidus\_reviews:install fails [\#100](https://github.com/solidusio-contrib/solidus_reviews/issues/100)
12
- - Dependabot can't resolve your Ruby dependency files [\#97](https://github.com/solidusio-contrib/solidus_reviews/issues/97)
13
- - Dependabot can't resolve your Ruby dependency files [\#96](https://github.com/solidusio-contrib/solidus_reviews/issues/96)
14
-
15
- **Merged pull requests:**
16
-
17
- - bump to support ruby 3 and solidus 3 [\#103](https://github.com/solidusio-contrib/solidus_reviews/pull/103) ([peterberkenbosch](https://github.com/peterberkenbosch))
18
- - Fix specs to allow support for solidus 3 [\#102](https://github.com/solidusio-contrib/solidus_reviews/pull/102) ([seriousammy](https://github.com/seriousammy))
19
- - Update gem to latest solidus\_dev\_support [\#99](https://github.com/solidusio-contrib/solidus_reviews/pull/99) ([nirebu](https://github.com/nirebu))
20
- - Make reviews:config like the config in solidus-frontend [\#98](https://github.com/solidusio-contrib/solidus_reviews/pull/98) ([marcrohloff](https://github.com/marcrohloff))
21
-
22
- ## [v1.4.1](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.4.1) (2020-08-10)
23
-
24
- [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/v1.4.0...v1.4.1)
25
-
26
- ## [v1.4.0](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.4.0) (2020-08-06)
27
-
28
- [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/v1.3.0...v1.4.0)
29
-
30
- **Closed issues:**
31
-
32
- - Cannot select star rating when creating or editing a review [\#88](https://github.com/solidusio-contrib/solidus_reviews/issues/88)
33
- - uninitialized constant SolidusReviews::Spree::Admin \(NameError\) [\#77](https://github.com/solidusio-contrib/solidus_reviews/issues/77)
34
- - Dependabot can't resolve your Ruby dependency files [\#75](https://github.com/solidusio-contrib/solidus_reviews/issues/75)
35
- - Dependabot can't resolve your Ruby dependency files [\#74](https://github.com/solidusio-contrib/solidus_reviews/issues/74)
36
- - Dependabot can't resolve your Ruby dependency files [\#73](https://github.com/solidusio-contrib/solidus_reviews/issues/73)
37
- - Dependabot can't resolve your Ruby dependency files [\#71](https://github.com/solidusio-contrib/solidus_reviews/issues/71)
38
- - Dependabot can't resolve your Ruby dependency files [\#70](https://github.com/solidusio-contrib/solidus_reviews/issues/70)
39
- - Dependabot can't resolve your Ruby dependency files [\#69](https://github.com/solidusio-contrib/solidus_reviews/issues/69)
40
- - Users should be able to upload images as part of their review [\#67](https://github.com/solidusio-contrib/solidus_reviews/issues/67)
41
-
42
- **Merged pull requests:**
43
-
44
- - Replace deprected ` SolidusSupport::EngineExtensions::Decorators` with ` SolidusSupport::EngineExtensions` [\#93](https://github.com/solidusio-contrib/solidus_reviews/pull/93) ([marcrohloff](https://github.com/marcrohloff))
45
- - Allow solidus\_support 0.4 [\#92](https://github.com/solidusio-contrib/solidus_reviews/pull/92) ([mamhoff](https://github.com/mamhoff))
46
- - Fixes review title [\#91](https://github.com/solidusio-contrib/solidus_reviews/pull/91) ([memotoro](https://github.com/memotoro))
47
- - remove extraneous .css file [\#90](https://github.com/solidusio-contrib/solidus_reviews/pull/90) ([dhughesbc](https://github.com/dhughesbc))
48
- - Relax solidus\_support dependency [\#86](https://github.com/solidusio-contrib/solidus_reviews/pull/86) ([kennyadsl](https://github.com/kennyadsl))
49
- - Adds PermissionSets classes and checks for Reviews [\#85](https://github.com/solidusio-contrib/solidus_reviews/pull/85) ([memotoro](https://github.com/memotoro))
50
- - Adds controls for image uploads [\#83](https://github.com/solidusio-contrib/solidus_reviews/pull/83) ([memotoro](https://github.com/memotoro))
51
- - Add option to auto approve star only reviews [\#82](https://github.com/solidusio-contrib/solidus_reviews/pull/82) ([KaemonIsland](https://github.com/KaemonIsland))
52
- - Add touch to feedback review model [\#81](https://github.com/solidusio-contrib/solidus_reviews/pull/81) ([KaemonIsland](https://github.com/KaemonIsland))
53
- - Add feedback reviews to api [\#79](https://github.com/solidusio-contrib/solidus_reviews/pull/79) ([KaemonIsland](https://github.com/KaemonIsland))
54
- - Fix path for Spree::ProductsControllerDecorator [\#78](https://github.com/solidusio-contrib/solidus_reviews/pull/78) ([aldesantis](https://github.com/aldesantis))
55
- - Add edit and update methods to reviews controller [\#76](https://github.com/solidusio-contrib/solidus_reviews/pull/76) ([KaemonIsland](https://github.com/KaemonIsland))
56
- - Update to solidus\_dev\_support [\#72](https://github.com/solidusio-contrib/solidus_reviews/pull/72) ([aldesantis](https://github.com/aldesantis))
57
-
58
- ## [v1.3.0](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.3.0) (2019-11-27)
59
-
60
- [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/v1.2.0...v1.3.0)
61
-
62
- **Closed issues:**
63
-
64
- - sass/rails is deprecated. Please update to `require 'sassc/rails'` [\#48](https://github.com/solidusio-contrib/solidus_reviews/issues/48)
65
- - Class variable access from toplevel [\#47](https://github.com/solidusio-contrib/solidus_reviews/issues/47)
66
-
67
- **Merged pull requests:**
68
-
69
- - Prepare v1.3.0 [\#68](https://github.com/solidusio-contrib/solidus_reviews/pull/68) ([aldesantis](https://github.com/aldesantis))
70
- - Adopt solidus\_extension\_dev\_tools [\#66](https://github.com/solidusio-contrib/solidus_reviews/pull/66) ([aldesantis](https://github.com/aldesantis))
71
- - Switch to sassc/rails [\#65](https://github.com/solidusio-contrib/solidus_reviews/pull/65) ([pelargir](https://github.com/pelargir))
72
- - Fix flaky specs caused by bad preference stubbing [\#54](https://github.com/solidusio-contrib/solidus_reviews/pull/54) ([aldesantis](https://github.com/aldesantis))
73
-
74
- ## [v1.2.0](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.2.0) (2019-09-17)
75
-
76
- [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/v1.1.1...v1.2.0)
77
-
78
- **Merged pull requests:**
79
-
80
- - Remove solidus\_auth\_devise as dependency [\#53](https://github.com/solidusio-contrib/solidus_reviews/pull/53) ([kennyadsl](https://github.com/kennyadsl))
81
- - Adopt CircleCI instead of Travis [\#51](https://github.com/solidusio-contrib/solidus_reviews/pull/51) ([aldesantis](https://github.com/aldesantis))
82
-
83
- ## [v1.1.1](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.1.1) (2019-08-15)
84
-
85
- [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/v1.1.0...v1.1.1)
86
-
87
- **Closed issues:**
88
-
89
- - Rubygems release [\#22](https://github.com/solidusio-contrib/solidus_reviews/issues/22)
90
-
91
- **Merged pull requests:**
92
-
93
- - Adds missing API features to the index and show endpoints [\#46](https://github.com/solidusio-contrib/solidus_reviews/pull/46) ([ericsaupe](https://github.com/ericsaupe))
94
-
95
- ## [v1.1.0](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.1.0) (2019-08-14)
96
-
97
- [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/v1.0.0...v1.1.0)
98
-
99
- **Closed issues:**
100
-
101
- - Support rating only reviews [\#41](https://github.com/solidusio-contrib/solidus_reviews/issues/41)
102
- - Settings \> Reviews styling is broken [\#35](https://github.com/solidusio-contrib/solidus_reviews/issues/35)
103
- - Need add key to translate file ru.yml [\#23](https://github.com/solidusio-contrib/solidus_reviews/issues/23)
104
- - Error in solidus 2.1 due to add\_routes method [\#5](https://github.com/solidusio-contrib/solidus_reviews/issues/5)
105
-
106
- **Merged pull requests:**
107
-
108
- - General Typos [\#45](https://github.com/solidusio-contrib/solidus_reviews/pull/45) ([ericsaupe](https://github.com/ericsaupe))
109
- - Updated API to include new fields [\#44](https://github.com/solidusio-contrib/solidus_reviews/pull/44) ([ericsaupe](https://github.com/ericsaupe))
110
- - Fix specs [\#43](https://github.com/solidusio-contrib/solidus_reviews/pull/43) ([ericsaupe](https://github.com/ericsaupe))
111
- - Rating only reviews [\#42](https://github.com/solidusio-contrib/solidus_reviews/pull/42) ([ericsaupe](https://github.com/ericsaupe))
112
- - Adds verified purchaser [\#40](https://github.com/solidusio-contrib/solidus_reviews/pull/40) ([ericsaupe](https://github.com/ericsaupe))
113
- - Cleanup [\#39](https://github.com/solidusio-contrib/solidus_reviews/pull/39) ([ericsaupe](https://github.com/ericsaupe))
114
- - Added Images to Reviews [\#38](https://github.com/solidusio-contrib/solidus_reviews/pull/38) ([ericsaupe](https://github.com/ericsaupe))
115
- - Add missing admin translation [\#37](https://github.com/solidusio-contrib/solidus_reviews/pull/37) ([jtapia](https://github.com/jtapia))
116
- - Fix wrong locale id for require login in admin [\#36](https://github.com/solidusio-contrib/solidus_reviews/pull/36) ([kevinnio](https://github.com/kevinnio))
117
- - Gem maintenance [\#34](https://github.com/solidusio-contrib/solidus_reviews/pull/34) ([spaghetticode](https://github.com/spaghetticode))
118
- - Remove Solidus v2.3 from Travis config \(EOL\) [\#33](https://github.com/solidusio-contrib/solidus_reviews/pull/33) ([aitbw](https://github.com/aitbw))
119
- - Add Solidus v2.7 and v2.8 to Travis config [\#32](https://github.com/solidusio-contrib/solidus_reviews/pull/32) ([aitbw](https://github.com/aitbw))
120
- - Fix deprecation warnings [\#31](https://github.com/solidusio-contrib/solidus_reviews/pull/31) ([aitbw](https://github.com/aitbw))
121
- - Fix Travis build [\#30](https://github.com/solidusio-contrib/solidus_reviews/pull/30) ([aitbw](https://github.com/aitbw))
122
- - Fix validation i18n [\#29](https://github.com/solidusio-contrib/solidus_reviews/pull/29) ([mamhoff](https://github.com/mamhoff))
123
- - Avoid conflicts when same rating HTML is repeated on page [\#28](https://github.com/solidusio-contrib/solidus_reviews/pull/28) ([spaghetticode](https://github.com/spaghetticode))
124
- - Add missing TH tag [\#27](https://github.com/solidusio-contrib/solidus_reviews/pull/27) ([spaghetticode](https://github.com/spaghetticode))
125
- - Use default translation key structure for validation message [\#26](https://github.com/solidusio-contrib/solidus_reviews/pull/26) ([aldesantis](https://github.com/aldesantis))
126
- - Remove redundant rescue\_from from api controller [\#24](https://github.com/solidusio-contrib/solidus_reviews/pull/24) ([dgra](https://github.com/dgra))
127
- - Improve specs [\#21](https://github.com/solidusio-contrib/solidus_reviews/pull/21) ([kennyadsl](https://github.com/kennyadsl))
128
- - Refactor spec helper to let specs pass [\#20](https://github.com/solidusio-contrib/solidus_reviews/pull/20) ([kennyadsl](https://github.com/kennyadsl))
129
- - Fix Trevis CI badge to use master branch status [\#19](https://github.com/solidusio-contrib/solidus_reviews/pull/19) ([kennyadsl](https://github.com/kennyadsl))
130
- - Fix bundle install issue with solidus\_auth\_devise 2.0 [\#18](https://github.com/solidusio-contrib/solidus_reviews/pull/18) ([kennyadsl](https://github.com/kennyadsl))
131
- - Fix resetting preferences in specs [\#17](https://github.com/solidusio-contrib/solidus_reviews/pull/17) ([kennyadsl](https://github.com/kennyadsl))
132
- - Add italian translations [\#16](https://github.com/solidusio-contrib/solidus_reviews/pull/16) ([vassalloandrea](https://github.com/vassalloandrea))
133
- - Add user email to admin review editing page [\#15](https://github.com/solidusio-contrib/solidus_reviews/pull/15) ([pelargir](https://github.com/pelargir))
134
- - Api interface [\#14](https://github.com/solidusio-contrib/solidus_reviews/pull/14) ([dgra](https://github.com/dgra))
135
- - General Solidus 2.3 updates [\#13](https://github.com/solidusio-contrib/solidus_reviews/pull/13) ([dgra](https://github.com/dgra))
136
- - Prefix named route [\#11](https://github.com/solidusio-contrib/solidus_reviews/pull/11) ([pelargir](https://github.com/pelargir))
137
- - Add the has\_many association for reviews from a user [\#10](https://github.com/solidusio-contrib/solidus_reviews/pull/10) ([dgra](https://github.com/dgra))
138
- - Updates to Solidus admin UI [\#9](https://github.com/solidusio-contrib/solidus_reviews/pull/9) ([tvdeyen](https://github.com/tvdeyen))
139
- - Update for Solidus 2.1 [\#6](https://github.com/solidusio-contrib/solidus_reviews/pull/6) ([kennyadsl](https://github.com/kennyadsl))
140
-
141
- ## [v1.0.0](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.0.0) (2017-02-03)
142
-
143
- [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/8640958dc42f9472cb5cbb85cab981a44f4c45db...v1.0.0)
144
-
145
- **Merged pull requests:**
146
-
147
- - Allow solidus\_auth\_devise \< 1.5 [\#8](https://github.com/solidusio-contrib/solidus_reviews/pull/8) ([tvdeyen](https://github.com/tvdeyen))
148
- - Test against multiple Solidus 1.x versions [\#7](https://github.com/solidusio-contrib/solidus_reviews/pull/7) ([tvdeyen](https://github.com/tvdeyen))
149
- - Fix install generator [\#3](https://github.com/solidusio-contrib/solidus_reviews/pull/3) ([andrewjwu](https://github.com/andrewjwu))
150
- - Do not add CRUD product routes to frontend [\#2](https://github.com/solidusio-contrib/solidus_reviews/pull/2) ([mamhoff](https://github.com/mamhoff))
151
- - Move factories into `lib` [\#1](https://github.com/solidusio-contrib/solidus_reviews/pull/1) ([alexblackie](https://github.com/alexblackie))
152
-
153
-
154
-
155
- \* *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_reviews/releases or [OLD_CHANGELOG.md](OLD_CHANGELOG.md) for older versions.
data/Gemfile CHANGED
@@ -3,9 +3,18 @@
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')
6
+ branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
7
7
  gem 'solidus', github: 'solidusio/solidus', branch: branch
8
8
 
9
+ # The solidus_frontend gem has been pulled out since v3.2
10
+ if branch >= 'v3.2'
11
+ gem 'solidus_frontend'
12
+ elsif branch == 'main'
13
+ gem 'solidus_frontend', github: 'solidusio/solidus_frontend', branch: branch
14
+ else
15
+ gem 'solidus_frontend', github: 'solidusio/solidus', branch: branch
16
+ end
17
+
9
18
  # Needed to help Bundler figure out how to resolve dependencies,
10
19
  # otherwise it takes forever to resolve them.
11
20
  # See https://github.com/bundler/bundler/issues/6677
@@ -14,7 +23,7 @@ gem 'rails', '>0.a'
14
23
  # Provides basic authentication functionality for testing parts of your engine
15
24
  gem 'solidus_auth_devise'
16
25
 
17
- case ENV['DB']
26
+ case ENV.fetch('DB', nil)
18
27
  when 'mysql'
19
28
  gem 'mysql2'
20
29
  when 'postgresql'
@@ -23,6 +32,16 @@ else
23
32
  gem 'sqlite3'
24
33
  end
25
34
 
26
- gem 'rails-controller-testing', group: :test
35
+ # While we still support Ruby < 3 we need to workaround a limitation in
36
+ # the 'async' gem that relies on the latest ruby, since RubyGems doesn't
37
+ # resolve gems based on the required ruby version.
38
+ gem 'async', '< 3' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3')
27
39
 
28
40
  gemspec
41
+
42
+ # Use a local Gemfile to include development dependencies that might not be
43
+ # relevant for the project or for other contributors, e.g. pry-byebug.
44
+ #
45
+ # We use `send` instead of calling `eval_gemfile` to work around an issue with
46
+ # how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
47
+ send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2020 Solidus and contributors
1
+ Copyright (c) 2023 Solidus Contrib
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without modification,
data/OLD_CHANGELOG.md ADDED
@@ -0,0 +1,155 @@
1
+ # Changelog
2
+
3
+ ## [v1.5.0](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.5.0) (2021-09-20)
4
+
5
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/v1.4.1...v1.5.0)
6
+
7
+ **Closed issues:**
8
+
9
+ - Dependabot can't resolve your Ruby dependency files [\#105](https://github.com/solidusio-contrib/solidus_reviews/issues/105)
10
+ - Prepare Solidus Reviews for Solidus 3.0 [\#101](https://github.com/solidusio-contrib/solidus_reviews/issues/101)
11
+ - Installing fresh solidus and solidus\_reviews, rails g solidus\_reviews:install fails [\#100](https://github.com/solidusio-contrib/solidus_reviews/issues/100)
12
+ - Dependabot can't resolve your Ruby dependency files [\#97](https://github.com/solidusio-contrib/solidus_reviews/issues/97)
13
+ - Dependabot can't resolve your Ruby dependency files [\#96](https://github.com/solidusio-contrib/solidus_reviews/issues/96)
14
+
15
+ **Merged pull requests:**
16
+
17
+ - bump to support ruby 3 and solidus 3 [\#103](https://github.com/solidusio-contrib/solidus_reviews/pull/103) ([peterberkenbosch](https://github.com/peterberkenbosch))
18
+ - Fix specs to allow support for solidus 3 [\#102](https://github.com/solidusio-contrib/solidus_reviews/pull/102) ([seriousammy](https://github.com/seriousammy))
19
+ - Update gem to latest solidus\_dev\_support [\#99](https://github.com/solidusio-contrib/solidus_reviews/pull/99) ([nirebu](https://github.com/nirebu))
20
+ - Make reviews:config like the config in solidus-frontend [\#98](https://github.com/solidusio-contrib/solidus_reviews/pull/98) ([marcrohloff](https://github.com/marcrohloff))
21
+
22
+ ## [v1.4.1](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.4.1) (2020-08-10)
23
+
24
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/v1.4.0...v1.4.1)
25
+
26
+ ## [v1.4.0](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.4.0) (2020-08-06)
27
+
28
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/v1.3.0...v1.4.0)
29
+
30
+ **Closed issues:**
31
+
32
+ - Cannot select star rating when creating or editing a review [\#88](https://github.com/solidusio-contrib/solidus_reviews/issues/88)
33
+ - uninitialized constant SolidusReviews::Spree::Admin \(NameError\) [\#77](https://github.com/solidusio-contrib/solidus_reviews/issues/77)
34
+ - Dependabot can't resolve your Ruby dependency files [\#75](https://github.com/solidusio-contrib/solidus_reviews/issues/75)
35
+ - Dependabot can't resolve your Ruby dependency files [\#74](https://github.com/solidusio-contrib/solidus_reviews/issues/74)
36
+ - Dependabot can't resolve your Ruby dependency files [\#73](https://github.com/solidusio-contrib/solidus_reviews/issues/73)
37
+ - Dependabot can't resolve your Ruby dependency files [\#71](https://github.com/solidusio-contrib/solidus_reviews/issues/71)
38
+ - Dependabot can't resolve your Ruby dependency files [\#70](https://github.com/solidusio-contrib/solidus_reviews/issues/70)
39
+ - Dependabot can't resolve your Ruby dependency files [\#69](https://github.com/solidusio-contrib/solidus_reviews/issues/69)
40
+ - Users should be able to upload images as part of their review [\#67](https://github.com/solidusio-contrib/solidus_reviews/issues/67)
41
+
42
+ **Merged pull requests:**
43
+
44
+ - Replace deprected ` SolidusSupport::EngineExtensions::Decorators` with ` SolidusSupport::EngineExtensions` [\#93](https://github.com/solidusio-contrib/solidus_reviews/pull/93) ([marcrohloff](https://github.com/marcrohloff))
45
+ - Allow solidus\_support 0.4 [\#92](https://github.com/solidusio-contrib/solidus_reviews/pull/92) ([mamhoff](https://github.com/mamhoff))
46
+ - Fixes review title [\#91](https://github.com/solidusio-contrib/solidus_reviews/pull/91) ([memotoro](https://github.com/memotoro))
47
+ - remove extraneous .css file [\#90](https://github.com/solidusio-contrib/solidus_reviews/pull/90) ([dhughesbc](https://github.com/dhughesbc))
48
+ - Relax solidus\_support dependency [\#86](https://github.com/solidusio-contrib/solidus_reviews/pull/86) ([kennyadsl](https://github.com/kennyadsl))
49
+ - Adds PermissionSets classes and checks for Reviews [\#85](https://github.com/solidusio-contrib/solidus_reviews/pull/85) ([memotoro](https://github.com/memotoro))
50
+ - Adds controls for image uploads [\#83](https://github.com/solidusio-contrib/solidus_reviews/pull/83) ([memotoro](https://github.com/memotoro))
51
+ - Add option to auto approve star only reviews [\#82](https://github.com/solidusio-contrib/solidus_reviews/pull/82) ([KaemonIsland](https://github.com/KaemonIsland))
52
+ - Add touch to feedback review model [\#81](https://github.com/solidusio-contrib/solidus_reviews/pull/81) ([KaemonIsland](https://github.com/KaemonIsland))
53
+ - Add feedback reviews to api [\#79](https://github.com/solidusio-contrib/solidus_reviews/pull/79) ([KaemonIsland](https://github.com/KaemonIsland))
54
+ - Fix path for Spree::ProductsControllerDecorator [\#78](https://github.com/solidusio-contrib/solidus_reviews/pull/78) ([aldesantis](https://github.com/aldesantis))
55
+ - Add edit and update methods to reviews controller [\#76](https://github.com/solidusio-contrib/solidus_reviews/pull/76) ([KaemonIsland](https://github.com/KaemonIsland))
56
+ - Update to solidus\_dev\_support [\#72](https://github.com/solidusio-contrib/solidus_reviews/pull/72) ([aldesantis](https://github.com/aldesantis))
57
+
58
+ ## [v1.3.0](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.3.0) (2019-11-27)
59
+
60
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/v1.2.0...v1.3.0)
61
+
62
+ **Closed issues:**
63
+
64
+ - sass/rails is deprecated. Please update to `require 'sassc/rails'` [\#48](https://github.com/solidusio-contrib/solidus_reviews/issues/48)
65
+ - Class variable access from toplevel [\#47](https://github.com/solidusio-contrib/solidus_reviews/issues/47)
66
+
67
+ **Merged pull requests:**
68
+
69
+ - Prepare v1.3.0 [\#68](https://github.com/solidusio-contrib/solidus_reviews/pull/68) ([aldesantis](https://github.com/aldesantis))
70
+ - Adopt solidus\_extension\_dev\_tools [\#66](https://github.com/solidusio-contrib/solidus_reviews/pull/66) ([aldesantis](https://github.com/aldesantis))
71
+ - Switch to sassc/rails [\#65](https://github.com/solidusio-contrib/solidus_reviews/pull/65) ([pelargir](https://github.com/pelargir))
72
+ - Fix flaky specs caused by bad preference stubbing [\#54](https://github.com/solidusio-contrib/solidus_reviews/pull/54) ([aldesantis](https://github.com/aldesantis))
73
+
74
+ ## [v1.2.0](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.2.0) (2019-09-17)
75
+
76
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/v1.1.1...v1.2.0)
77
+
78
+ **Merged pull requests:**
79
+
80
+ - Remove solidus\_auth\_devise as dependency [\#53](https://github.com/solidusio-contrib/solidus_reviews/pull/53) ([kennyadsl](https://github.com/kennyadsl))
81
+ - Adopt CircleCI instead of Travis [\#51](https://github.com/solidusio-contrib/solidus_reviews/pull/51) ([aldesantis](https://github.com/aldesantis))
82
+
83
+ ## [v1.1.1](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.1.1) (2019-08-15)
84
+
85
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/v1.1.0...v1.1.1)
86
+
87
+ **Closed issues:**
88
+
89
+ - Rubygems release [\#22](https://github.com/solidusio-contrib/solidus_reviews/issues/22)
90
+
91
+ **Merged pull requests:**
92
+
93
+ - Adds missing API features to the index and show endpoints [\#46](https://github.com/solidusio-contrib/solidus_reviews/pull/46) ([ericsaupe](https://github.com/ericsaupe))
94
+
95
+ ## [v1.1.0](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.1.0) (2019-08-14)
96
+
97
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/v1.0.0...v1.1.0)
98
+
99
+ **Closed issues:**
100
+
101
+ - Support rating only reviews [\#41](https://github.com/solidusio-contrib/solidus_reviews/issues/41)
102
+ - Settings \> Reviews styling is broken [\#35](https://github.com/solidusio-contrib/solidus_reviews/issues/35)
103
+ - Need add key to translate file ru.yml [\#23](https://github.com/solidusio-contrib/solidus_reviews/issues/23)
104
+ - Error in solidus 2.1 due to add\_routes method [\#5](https://github.com/solidusio-contrib/solidus_reviews/issues/5)
105
+
106
+ **Merged pull requests:**
107
+
108
+ - General Typos [\#45](https://github.com/solidusio-contrib/solidus_reviews/pull/45) ([ericsaupe](https://github.com/ericsaupe))
109
+ - Updated API to include new fields [\#44](https://github.com/solidusio-contrib/solidus_reviews/pull/44) ([ericsaupe](https://github.com/ericsaupe))
110
+ - Fix specs [\#43](https://github.com/solidusio-contrib/solidus_reviews/pull/43) ([ericsaupe](https://github.com/ericsaupe))
111
+ - Rating only reviews [\#42](https://github.com/solidusio-contrib/solidus_reviews/pull/42) ([ericsaupe](https://github.com/ericsaupe))
112
+ - Adds verified purchaser [\#40](https://github.com/solidusio-contrib/solidus_reviews/pull/40) ([ericsaupe](https://github.com/ericsaupe))
113
+ - Cleanup [\#39](https://github.com/solidusio-contrib/solidus_reviews/pull/39) ([ericsaupe](https://github.com/ericsaupe))
114
+ - Added Images to Reviews [\#38](https://github.com/solidusio-contrib/solidus_reviews/pull/38) ([ericsaupe](https://github.com/ericsaupe))
115
+ - Add missing admin translation [\#37](https://github.com/solidusio-contrib/solidus_reviews/pull/37) ([jtapia](https://github.com/jtapia))
116
+ - Fix wrong locale id for require login in admin [\#36](https://github.com/solidusio-contrib/solidus_reviews/pull/36) ([kevinnio](https://github.com/kevinnio))
117
+ - Gem maintenance [\#34](https://github.com/solidusio-contrib/solidus_reviews/pull/34) ([spaghetticode](https://github.com/spaghetticode))
118
+ - Remove Solidus v2.3 from Travis config \(EOL\) [\#33](https://github.com/solidusio-contrib/solidus_reviews/pull/33) ([aitbw](https://github.com/aitbw))
119
+ - Add Solidus v2.7 and v2.8 to Travis config [\#32](https://github.com/solidusio-contrib/solidus_reviews/pull/32) ([aitbw](https://github.com/aitbw))
120
+ - Fix deprecation warnings [\#31](https://github.com/solidusio-contrib/solidus_reviews/pull/31) ([aitbw](https://github.com/aitbw))
121
+ - Fix Travis build [\#30](https://github.com/solidusio-contrib/solidus_reviews/pull/30) ([aitbw](https://github.com/aitbw))
122
+ - Fix validation i18n [\#29](https://github.com/solidusio-contrib/solidus_reviews/pull/29) ([mamhoff](https://github.com/mamhoff))
123
+ - Avoid conflicts when same rating HTML is repeated on page [\#28](https://github.com/solidusio-contrib/solidus_reviews/pull/28) ([spaghetticode](https://github.com/spaghetticode))
124
+ - Add missing TH tag [\#27](https://github.com/solidusio-contrib/solidus_reviews/pull/27) ([spaghetticode](https://github.com/spaghetticode))
125
+ - Use default translation key structure for validation message [\#26](https://github.com/solidusio-contrib/solidus_reviews/pull/26) ([aldesantis](https://github.com/aldesantis))
126
+ - Remove redundant rescue\_from from api controller [\#24](https://github.com/solidusio-contrib/solidus_reviews/pull/24) ([dgra](https://github.com/dgra))
127
+ - Improve specs [\#21](https://github.com/solidusio-contrib/solidus_reviews/pull/21) ([kennyadsl](https://github.com/kennyadsl))
128
+ - Refactor spec helper to let specs pass [\#20](https://github.com/solidusio-contrib/solidus_reviews/pull/20) ([kennyadsl](https://github.com/kennyadsl))
129
+ - Fix Trevis CI badge to use master branch status [\#19](https://github.com/solidusio-contrib/solidus_reviews/pull/19) ([kennyadsl](https://github.com/kennyadsl))
130
+ - Fix bundle install issue with solidus\_auth\_devise 2.0 [\#18](https://github.com/solidusio-contrib/solidus_reviews/pull/18) ([kennyadsl](https://github.com/kennyadsl))
131
+ - Fix resetting preferences in specs [\#17](https://github.com/solidusio-contrib/solidus_reviews/pull/17) ([kennyadsl](https://github.com/kennyadsl))
132
+ - Add italian translations [\#16](https://github.com/solidusio-contrib/solidus_reviews/pull/16) ([vassalloandrea](https://github.com/vassalloandrea))
133
+ - Add user email to admin review editing page [\#15](https://github.com/solidusio-contrib/solidus_reviews/pull/15) ([pelargir](https://github.com/pelargir))
134
+ - Api interface [\#14](https://github.com/solidusio-contrib/solidus_reviews/pull/14) ([dgra](https://github.com/dgra))
135
+ - General Solidus 2.3 updates [\#13](https://github.com/solidusio-contrib/solidus_reviews/pull/13) ([dgra](https://github.com/dgra))
136
+ - Prefix named route [\#11](https://github.com/solidusio-contrib/solidus_reviews/pull/11) ([pelargir](https://github.com/pelargir))
137
+ - Add the has\_many association for reviews from a user [\#10](https://github.com/solidusio-contrib/solidus_reviews/pull/10) ([dgra](https://github.com/dgra))
138
+ - Updates to Solidus admin UI [\#9](https://github.com/solidusio-contrib/solidus_reviews/pull/9) ([tvdeyen](https://github.com/tvdeyen))
139
+ - Update for Solidus 2.1 [\#6](https://github.com/solidusio-contrib/solidus_reviews/pull/6) ([kennyadsl](https://github.com/kennyadsl))
140
+
141
+ ## [v1.0.0](https://github.com/solidusio-contrib/solidus_reviews/tree/v1.0.0) (2017-02-03)
142
+
143
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_reviews/compare/8640958dc42f9472cb5cbb85cab981a44f4c45db...v1.0.0)
144
+
145
+ **Merged pull requests:**
146
+
147
+ - Allow solidus\_auth\_devise \< 1.5 [\#8](https://github.com/solidusio-contrib/solidus_reviews/pull/8) ([tvdeyen](https://github.com/tvdeyen))
148
+ - Test against multiple Solidus 1.x versions [\#7](https://github.com/solidusio-contrib/solidus_reviews/pull/7) ([tvdeyen](https://github.com/tvdeyen))
149
+ - Fix install generator [\#3](https://github.com/solidusio-contrib/solidus_reviews/pull/3) ([andrewjwu](https://github.com/andrewjwu))
150
+ - Do not add CRUD product routes to frontend [\#2](https://github.com/solidusio-contrib/solidus_reviews/pull/2) ([mamhoff](https://github.com/mamhoff))
151
+ - Move factories into `lib` [\#1](https://github.com/solidusio-contrib/solidus_reviews/pull/1) ([alexblackie](https://github.com/alexblackie))
152
+
153
+
154
+
155
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Solidus Reviews
2
2
 
3
3
  [![CircleCI](https://circleci.com/gh/solidusio-contrib/solidus_reviews.svg?style=svg)](https://circleci.com/gh/solidusio-contrib/solidus_reviews)
4
+ [![codecov](https://codecov.io/gh/solidusio-contrib/solidus_reviews/branch/master/graph/badge.svg)](https://codecov.io/gh/solidusio-contrib/solidus_reviews)
4
5
 
5
6
  Straightforward review/rating functionality, updated for [Solidus](https://solidus.io).
6
7
 
@@ -8,38 +9,18 @@ While the gem's name has changed, the module namespace and commands are still `s
8
9
 
9
10
  ## Installation
10
11
 
11
- Add the following to your `Gemfile` to install from git:
12
+ Add solidus_reviews to your Gemfile:
12
13
 
13
14
  ```ruby
14
- gem 'solidus_reviews', github: 'solidusio-contrib/solidus_reviews'
15
+ gem 'solidus_reviews'
15
16
  ```
16
17
 
17
- Now bundle up with:
18
+ Bundle your dependencies and run the installation generator:
18
19
 
19
- ```console
20
- $ bundle
21
- ```
22
-
23
- Next, run the rake task that copies the necessary migrations and assets to your project:
24
-
25
- ```console
26
- $ rails g solidus_reviews:install
27
- ```
28
-
29
- And finish with a migrate:
30
-
31
- ```console
32
- $ rake db:migrate
33
- ```
34
-
35
- Now you should be able to boot up your server with:
36
-
37
- ```console
38
- $ rails s
20
+ ```shell
21
+ bin/rails generate solidus_reviews:install
39
22
  ```
40
23
 
41
- That's all!
42
-
43
24
  ## Usage
44
25
 
45
26
  The `Spree::ReviewsController` controller provides all the CRUD functionality for product reviews.
@@ -49,19 +30,11 @@ You can think of these as meta-reviews (e.g. the classic "Was this useful?" moda
49
30
 
50
31
  You can approve, edit and delete reviews and feedback reviews from the backend.
51
32
 
52
- ## Factories
53
-
54
- If you want factories for our models available in your application, simply require our factories in
55
- your `spec_helper.rb`:
56
-
57
- ```ruby
58
- require 'solidus_reviews/factories'
59
- ```
33
+ ## Development
60
34
 
61
35
  ### Testing the extension
62
36
 
63
37
  First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
64
-
65
38
  app if it does not exist, then it will run specs. The dummy app can be regenerated by using
66
39
  `bin/rake extension:test_app`.
67
40
 
@@ -75,10 +48,16 @@ To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
75
48
  bundle exec rubocop
76
49
  ```
77
50
 
51
+ When testing your application's integration with this extension you may use its factories.
52
+ You can load Solidus core factories along with this extension's factories using this statement:
53
+
54
+ ```ruby
55
+ SolidusDevSupport::TestingSupport::Factories.load_for(SolidusReviews::Engine)
56
+ ```
57
+
78
58
  ### Running the sandbox
79
59
 
80
60
  To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
81
-
82
61
  the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
83
62
  `sandbox/bin/rails`.
84
63
 
@@ -92,22 +71,10 @@ $ bin/rails server
92
71
  Use Ctrl-C to stop
93
72
  ```
94
73
 
95
- ### Updating the changelog
96
-
97
- Before and after releases the changelog should be updated to reflect the up-to-date status of
98
- the project:
99
- ```shell
100
-
101
- bin/rake changelog
102
- git add CHANGELOG.md
103
- git commit -m "Update the changelog"
104
- ```
105
-
106
- ## Contributing
74
+ ### Releasing new versions
107
75
 
108
- Bug reports and pull requests are welcome on GitHub at <https://github.com/solidusio-contrib/solidus_reviews>.
76
+ Please refer to the [dedicated page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) in the Solidus wiki.
109
77
 
110
78
  ## License
111
79
 
112
- Copyright (c) 2009-2020 [Solidus](https://github.com/solidusio) and [contributors](https://github.com/solidusio-contrib/solidus_reviews/graphs/contributors),
113
- released under the [New BSD License](https://github.com/solidusio-contrib/solidus_reviews/blob/master/LICENSE.md).
80
+ Copyright (c) 2023 Solidus Contrib, released under the New BSD License.
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "bundler/gem_tasks"
3
4
  require 'solidus_dev_support/rake_tasks'
4
5
  SolidusDevSupport::RakeTasks.install
5
6
 
@@ -32,7 +32,7 @@ class Spree::ReviewsController < Spree::StoreController
32
32
  @review.locale = I18n.locale.to_s if Spree::Reviews::Config[:track_locale]
33
33
  # Handle images
34
34
  params[:review][:images]&.each do |image|
35
- @review.images.new(attachment: image)
35
+ @review.images.new(attachment: image) if image.present?
36
36
  end
37
37
 
38
38
  authorize! :create, @review
@@ -51,7 +51,7 @@ class Spree::ReviewsController < Spree::StoreController
51
51
 
52
52
  # Handle images
53
53
  params[:review][:images]&.each do |image|
54
- @review.images.new(attachment: image)
54
+ @review.images.new(attachment: image) if image.present?
55
55
  end
56
56
 
57
57
  authorize! :update, @review
@@ -5,7 +5,7 @@ class Spree::Review < ApplicationRecord
5
5
  belongs_to :user, class_name: Spree.user_class.to_s, optional: true
6
6
  has_many :feedback_reviews, dependent: :destroy
7
7
  has_many :images, -> { order(:position) }, as: :viewable,
8
- dependent: :destroy, class_name: "Spree::Image"
8
+ dependent: :destroy, class_name: "Spree::Image"
9
9
 
10
10
  before_save :verify_purchaser
11
11
  before_save :approve_review, unless: :approved?
@@ -27,6 +27,23 @@ class Spree::Review < ApplicationRecord
27
27
  scope :not_approved, -> { where(approved: false) }
28
28
  scope :default_approval_filter, -> { Spree::Reviews::Config[:include_unapproved_reviews] ? all : approved }
29
29
 
30
+ def self.ransackable_attributes(*)
31
+ [
32
+ "approved",
33
+ "name",
34
+ "review",
35
+ "title"
36
+ ]
37
+ end
38
+
39
+ def self.ransackable_associations(*)
40
+ [
41
+ "feedback_reviews",
42
+ "product",
43
+ "user"
44
+ ]
45
+ end
46
+
30
47
  def feedback_stars
31
48
  return 0 if feedback_reviews.size <= 0
32
49
 
@@ -0,0 +1,3 @@
1
+ <!-- insert_after "[data-hook='product_properties']" -->
2
+
3
+ <%= render "spree/shared/reviews" %>
data/bin/sandbox CHANGED
@@ -1,29 +1,23 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  set -e
4
+ test -z "${DEBUG+empty_string}" || set -x
4
5
 
5
- case "$DB" in
6
- postgres|postgresql)
7
- RAILSDB="postgresql"
8
- ;;
9
- mysql)
10
- RAILSDB="mysql"
11
- ;;
12
- sqlite|'')
13
- RAILSDB="sqlite3"
14
- ;;
15
- *)
16
- echo "Invalid DB specified: $DB"
17
- exit 1
18
- ;;
19
- esac
6
+ test "$DB" = "sqlite" && export DB="sqlite3"
7
+
8
+ if [ -z "$SOLIDUS_BRANCH" ]
9
+ then
10
+ echo "~~> Use 'export SOLIDUS_BRANCH=[main|v3.2|...]' to control the Solidus branch"
11
+ SOLIDUS_BRANCH="main"
12
+ fi
13
+ echo "~~> Using branch $SOLIDUS_BRANCH of solidus"
20
14
 
21
- if [ ! -z $SOLIDUS_BRANCH ]
15
+ if [ -z "$SOLIDUS_FRONTEND" ]
22
16
  then
23
- BRANCH=$SOLIDUS_BRANCH
24
- else
25
- BRANCH="master"
17
+ echo "~~> Use 'export SOLIDUS_FRONTEND=[solidus_frontend|solidus_starter_frontend]' to control the Solidus frontend"
18
+ SOLIDUS_FRONTEND="solidus_frontend"
26
19
  fi
20
+ echo "~~> Using branch $SOLIDUS_FRONTEND as the solidus frontend"
27
21
 
28
22
  extension_name="solidus_reviews"
29
23
 
@@ -33,7 +27,8 @@ function unbundled {
33
27
  }
34
28
 
35
29
  rm -rf ./sandbox
36
- unbundled bundle exec rails new sandbox --database="$RAILSDB" \
30
+ unbundled bundle exec rails new sandbox \
31
+ --database="${DB:-sqlite3}" \
37
32
  --skip-bundle \
38
33
  --skip-git \
39
34
  --skip-keeps \
@@ -49,8 +44,7 @@ fi
49
44
 
50
45
  cd ./sandbox
51
46
  cat <<RUBY >> Gemfile
52
- gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
53
- gem 'solidus_auth_devise', '>= 2.1.0'
47
+ gem 'solidus', github: 'solidusio/solidus', branch: '$SOLIDUS_BRANCH'
54
48
  gem 'rails-i18n'
55
49
  gem 'solidus_i18n'
56
50
 
@@ -67,20 +61,18 @@ unbundled bundle install --gemfile Gemfile
67
61
 
68
62
  unbundled bundle exec rake db:drop db:create
69
63
 
70
- unbundled bundle exec rails generate spree:install \
64
+ unbundled bundle exec rails generate solidus:install \
71
65
  --auto-accept \
72
66
  --user_class=Spree::User \
73
67
  --enforce_available_locales=true \
74
- --with-authentication=false \
75
- --payment-method=none
68
+ --with-authentication=true \
69
+ --payment-method=none \
70
+ --frontend=${SOLIDUS_FRONTEND} \
76
71
  $@
77
72
 
78
- unbundled bundle exec rails generate solidus:auth:install
79
- unbundled bundle exec rails generate ${extension_name}:install
73
+ unbundled bundle exec rails generate solidus:auth:install --auto-run-migrations
74
+ unbundled bundle exec rails generate ${extension_name}:install --auto-run-migrations
80
75
 
81
76
  echo
82
77
  echo "🚀 Sandbox app successfully created for $extension_name!"
83
- echo "🚀 Using $RAILSDB and Solidus $BRANCH"
84
- echo "🚀 Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
85
- echo "🚀 Use 'export SOLIDUS_BRANCH=<BRANCH-NAME>' to control the Solidus version"
86
- echo "🚀 This app is intended for test purposes."
78
+ echo "🧪 This app is intended for test purposes."
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.config.to_prepare do
4
+ Spree::Backend::Config.configure do |config|
5
+ config.menu_items = config.menu_items.map do |item|
6
+ if item.label.to_sym == :settings
7
+ # The API of the MenuItem class changes in Solidus 4.2.0
8
+ if item.respond_to?(:children)
9
+ item.children << Spree::BackendConfiguration::MenuItem.new(
10
+ label: :reviews,
11
+ condition: -> { can?(:admin, Spree::ReviewsConfiguration) },
12
+ url: -> { Spree::Core::Engine.routes.url_helpers.edit_admin_review_settings_path },
13
+ match_path: /review_settings/
14
+ )
15
+ else
16
+ item.sections << :reviews
17
+ end
18
+ elsif item.label.to_sym == :products
19
+ if item.respond_to?(:children)
20
+ item.children << Spree::BackendConfiguration::MenuItem.new(
21
+ label: :reviews,
22
+ condition: -> { can?(:admin, Spree::Review) },
23
+ url: -> { Spree::Core::Engine.routes.url_helpers.admin_reviews_path },
24
+ match_path: /reviews/
25
+ )
26
+ else
27
+ item.sections << :reviews
28
+ end
29
+ end
30
+ item
31
+ end
32
+ end
33
+ end
@@ -2,6 +2,9 @@
2
2
 
3
3
  module Spree
4
4
  module Reviews
5
- Config = Spree::ReviewsConfiguration.new
6
5
  end
7
6
  end
7
+
8
+ Rails.application.reloader.to_prepare do
9
+ Spree::Reviews.const_set(:Config, Spree::ReviewsConfiguration.new)
10
+ end
@@ -84,7 +84,7 @@ module Spree
84
84
  # Converts rating strings like "5 units" to "5"
85
85
  # Operates on params
86
86
  def sanitize_rating
87
- params[:rating].to_s.sub!(/\s*[^0-9]*\z/, '') unless params[:feedback_review] && params[:feedback_review][:rating].blank?
87
+ params[:rating].to_s.dup.sub!(/\s*[^0-9]*\z/, '') unless params[:feedback_review] && params[:feedback_review][:rating].blank?
88
88
  end
89
89
  end
90
90
  end
@@ -4,6 +4,15 @@ module SolidusReviews
4
4
  module Generators
5
5
  class InstallGenerator < Rails::Generators::Base
6
6
  class_option :auto_run_migrations, type: :boolean, default: false
7
+ source_root File.expand_path('templates', __dir__)
8
+
9
+ def self.exit_on_failure?
10
+ true
11
+ end
12
+
13
+ def copy_initializer
14
+ template 'initializer.rb', 'config/initializers/solidus_reviews.rb'
15
+ end
7
16
 
8
17
  def add_javascripts
9
18
  append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/solidus_reviews\n"
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ SolidusReviews.configure do |config|
4
+ # TODO: Remember to change this with the actual preferences you have implemented!
5
+ # config.sample_preference = 'sample_value'
6
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusReviews
4
+ class Configuration
5
+ # Define here the settings for this extension, e.g.:
6
+ #
7
+ # attr_accessor :my_setting
8
+ end
9
+
10
+ class << self
11
+ def configuration
12
+ @configuration ||= Configuration.new
13
+ end
14
+
15
+ alias config configuration
16
+
17
+ def configure
18
+ yield configuration
19
+ end
20
+ end
21
+ end
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/core'
3
+ require 'solidus_core'
4
+ require 'solidus_support'
4
5
 
5
6
  module SolidusReviews
6
7
  class Engine < Rails::Engine
7
8
  include SolidusSupport::EngineExtensions
8
9
 
9
- isolate_namespace Spree
10
+ isolate_namespace ::Spree
10
11
 
11
12
  engine_name 'solidus_reviews'
12
13
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  require "factory_bot"
4
4
 
5
- Dir["#{File.dirname(__FILE__)}/factories/**"].each do |f|
5
+ Dir["#{File.dirname(__FILE__)}/../factories/**"].each do |f|
6
6
  require File.expand_path(f)
7
7
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusReviews
4
- VERSION = '1.5.0'
4
+ VERSION = '1.7.0'
5
5
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'solidus_core'
4
+ require 'solidus_reviews/configuration'
4
5
  require 'solidus_support'
5
6
  require 'deface'
6
7
 
@@ -14,8 +14,9 @@ Gem::Specification.new do |spec|
14
14
 
15
15
  spec.metadata['homepage_uri'] = spec.homepage
16
16
  spec.metadata['source_code_uri'] = 'https://github.com/solidusio-contrib/solidus_reviews'
17
+ spec.metadata['changelog_uri'] = 'https://github.com/solidusio-contrib/solidus_reviews/releases'
17
18
 
18
- spec.required_ruby_version = Gem::Requirement.new('> 2.5')
19
+ spec.required_ruby_version = '>= 3.0'
19
20
 
20
21
  # Specify which files should be added to the gem when it is released.
21
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -27,8 +28,9 @@ Gem::Specification.new do |spec|
27
28
  spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
28
29
  spec.require_paths = ["lib"]
29
30
 
30
- spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 4']
31
- spec.add_dependency 'solidus_support', '~> 0.5'
31
+ spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 5']
32
+ spec.add_dependency 'solidus_support', '~> 0.8'
32
33
 
33
- spec.add_development_dependency 'solidus_dev_support'
34
+ spec.add_development_dependency 'rails-controller-testing'
35
+ spec.add_development_dependency 'solidus_dev_support', '~> 2.7'
34
36
  end
@@ -16,7 +16,7 @@ describe Spree::Admin::ReviewSettingsController do
16
16
  expect(response).to redirect_to spree.edit_admin_review_settings_path
17
17
  end
18
18
 
19
- context 'For parameters:
19
+ context 'with parameters:
20
20
  preview_size: 4,
21
21
  show_email: false,
22
22
  feedback_rating: false,
@@ -15,10 +15,7 @@ describe Spree::Admin::ReviewsController do
15
15
 
16
16
  describe '#index' do
17
17
  it 'list reviews' do
18
- reviews = [
19
- create(:review, product: product),
20
- create(:review, product: product)
21
- ]
18
+ reviews = create_list(:review, 2, product: product)
22
19
  get :index, params: { product_id: product.slug }
23
20
  expect(assigns[:reviews]).to match_array reviews
24
21
  end
@@ -33,10 +33,7 @@ describe Spree::ReviewsController, type: :controller do
33
33
 
34
34
  context 'for a valid product' do
35
35
  it 'list approved reviews' do
36
- approved_reviews = [
37
- create(:review, :approved, product: product),
38
- create(:review, :approved, product: product)
39
- ]
36
+ approved_reviews = create_list(:review, 2, :approved, product: product)
40
37
  get :index, params: { product_id: product.slug }
41
38
  expect(assigns[:approved_reviews]).to match_array approved_reviews
42
39
  end
@@ -123,6 +123,18 @@ describe Spree::Review do
123
123
  end
124
124
  end
125
125
 
126
+ describe '.ransackable_attributes' do
127
+ subject { described_class.ransackable_attributes }
128
+
129
+ it { is_expected.to contain_exactly("approved", "name", "review", "title") }
130
+ end
131
+
132
+ describe '.ransackable_associations' do
133
+ subject { described_class.ransackable_associations }
134
+
135
+ it { is_expected.to contain_exactly("feedback_reviews", "product", "user") }
136
+ end
137
+
126
138
  describe '#recalculate_product_rating' do
127
139
  let(:product) { create(:product) }
128
140
  let!(:review) { create(:review, product: product) }
data/spec/spec_helper.rb CHANGED
@@ -3,6 +3,9 @@
3
3
  # Configure Rails Environment
4
4
  ENV['RAILS_ENV'] = 'test'
5
5
 
6
+ require 'rails-controller-testing'
7
+ Rails::Controller::Testing.install
8
+
6
9
  # Run Coverage report
7
10
  require 'solidus_dev_support/rspec/coverage'
8
11
 
@@ -18,8 +21,9 @@ require 'solidus_dev_support/rspec/feature_helper'
18
21
  # in spec/support/ and its subdirectories.
19
22
  Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }
20
23
 
21
- # Requires factories defined in lib/solidus_reviews/factories.rb
22
- require 'solidus_reviews/factories'
24
+ # Requires factories defined in Solidus core and this extension.
25
+ # See: lib/solidus_reviews/testing_support/factories.rb
26
+ SolidusDevSupport::TestingSupport::Factories.load_for(SolidusReviews::Engine)
23
27
 
24
28
  RSpec.configure do |config|
25
29
  config.infer_spec_type_from_file_location!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_reviews
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Contrib
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-20 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_core
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 2.0.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,23 +29,23 @@ dependencies:
29
29
  version: 2.0.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '4'
32
+ version: '5'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: solidus_support
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.5'
39
+ version: '0.8'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.5'
46
+ version: '0.8'
47
47
  - !ruby/object:Gem::Dependency
48
- name: solidus_dev_support
48
+ name: rails-controller-testing
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
@@ -58,6 +58,20 @@ dependencies:
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: solidus_dev_support
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '2.7'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '2.7'
61
75
  description: Review and rating functionality for your Solidus store.
62
76
  email:
63
77
  executables: []
@@ -66,6 +80,8 @@ extra_rdoc_files: []
66
80
  files:
67
81
  - ".circleci/config.yml"
68
82
  - ".gem_release.yml"
83
+ - ".github/stale.yml"
84
+ - ".github_changelog_generator"
69
85
  - ".gitignore"
70
86
  - ".rspec"
71
87
  - ".rubocop.yml"
@@ -73,6 +89,7 @@ files:
73
89
  - CHANGELOG.md
74
90
  - Gemfile
75
91
  - LICENSE
92
+ - OLD_CHANGELOG.md
76
93
  - README.md
77
94
  - Rakefile
78
95
  - app/assets/images/store/reviews/delete.gif
@@ -98,9 +115,7 @@ files:
98
115
  - app/models/spree/review.rb
99
116
  - app/models/spree/reviews_ability.rb
100
117
  - app/models/spree/reviews_configuration.rb
101
- - app/overrides/add_reviews_after_product_properties.rb
102
- - app/overrides/add_reviews_tab_to_admin.rb
103
- - app/overrides/add_reviews_to_admin_configuration_sidebar.rb
118
+ - app/overrides/spree/products/show/add_reviews_after_product_properties.html.erb.deface
104
119
  - app/views/spree/admin/feedback_reviews/index.html.erb
105
120
  - app/views/spree/admin/review_settings/edit.html.erb
106
121
  - app/views/spree/admin/reviews/_form.html.erb
@@ -130,6 +145,7 @@ files:
130
145
  - bin/rake
131
146
  - bin/sandbox
132
147
  - bin/setup
148
+ - config/initializers/add_spree_reviews_to_menu.rb
133
149
  - config/initializers/constants.rb
134
150
  - config/initializers/load_preferences.rb
135
151
  - config/locales/de-CH.yml
@@ -166,11 +182,13 @@ files:
166
182
  - lib/controllers/spree/api/feedback_reviews_controller.rb
167
183
  - lib/controllers/spree/api/reviews_controller.rb
168
184
  - lib/generators/solidus_reviews/install/install_generator.rb
185
+ - lib/generators/solidus_reviews/install/templates/initializer.rb
169
186
  - lib/solidus_reviews.rb
187
+ - lib/solidus_reviews/configuration.rb
170
188
  - lib/solidus_reviews/engine.rb
171
- - lib/solidus_reviews/factories.rb
172
189
  - lib/solidus_reviews/factories/feedback_review_factory.rb
173
190
  - lib/solidus_reviews/factories/review_factory.rb
191
+ - lib/solidus_reviews/testing_support/factories.rb
174
192
  - lib/solidus_reviews/version.rb
175
193
  - solidus_reviews.gemspec
176
194
  - spec/controllers/spree/admin/feedback_reviews_controller_spec.rb
@@ -191,7 +209,6 @@ files:
191
209
  - spec/models/reviews_configuration_spec.rb
192
210
  - spec/spec_helper.rb
193
211
  - spec/support/config.rb
194
- - spec/support/factories.rb
195
212
  - vendor/assets/javascripts/jquery.rating.js
196
213
  homepage: https://github.com/solidusio-contrib/solidus_reviews
197
214
  licenses:
@@ -199,22 +216,23 @@ licenses:
199
216
  metadata:
200
217
  homepage_uri: https://github.com/solidusio-contrib/solidus_reviews
201
218
  source_code_uri: https://github.com/solidusio-contrib/solidus_reviews
219
+ changelog_uri: https://github.com/solidusio-contrib/solidus_reviews/releases
202
220
  post_install_message:
203
221
  rdoc_options: []
204
222
  require_paths:
205
223
  - lib
206
224
  required_ruby_version: !ruby/object:Gem::Requirement
207
225
  requirements:
208
- - - ">"
226
+ - - ">="
209
227
  - !ruby/object:Gem::Version
210
- version: '2.5'
228
+ version: '3.0'
211
229
  required_rubygems_version: !ruby/object:Gem::Requirement
212
230
  requirements:
213
231
  - - ">="
214
232
  - !ruby/object:Gem::Version
215
233
  version: '0'
216
234
  requirements: []
217
- rubygems_version: 3.2.20
235
+ rubygems_version: 3.5.3
218
236
  signing_key:
219
237
  specification_version: 4
220
238
  summary: Review and rating functionality for your Solidus store.
@@ -237,4 +255,3 @@ test_files:
237
255
  - spec/models/reviews_configuration_spec.rb
238
256
  - spec/spec_helper.rb
239
257
  - spec/support/config.rb
240
- - spec/support/factories.rb
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Deface::Override.new(virtual_path: "spree/products/show",
4
- name: "converted_product_properties_767643482",
5
- insert_after: "[data-hook='product_properties']",
6
- partial: "spree/shared/reviews",
7
- disabled: false)
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Spree::Backend::Config.configure do |config|
4
- config.menu_items.detect { |menu_item|
5
- menu_item.label == :products
6
- }.sections << :reviews
7
- end
8
-
9
- Deface::Override.new(
10
- virtual_path: "spree/admin/shared/_product_sub_menu",
11
- name: "reviews_admin_tab",
12
- insert_bottom: "[data-hook='admin_product_sub_tabs']",
13
- disabled: false
14
- ) do
15
- <<-HTML
16
- <% if can? :admin, Spree::Review %>
17
- <%= tab(:reviews, label: 'review_management') %>
18
- <% end %>
19
- HTML
20
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Spree::Backend::Config.configure do |config|
4
- config.menu_items.detect { |menu_item|
5
- menu_item.label == :settings
6
- }.sections << :review_settings
7
- end
8
-
9
- Deface::Override.new(
10
- virtual_path: "spree/admin/shared/_settings_sub_menu",
11
- name: "converted_admin_configurations_menu",
12
- insert_bottom: "[data-hook='admin_settings_sub_tabs']",
13
- disabled: false
14
- ) do
15
- <<-HTML
16
- <% if can? :admin, Spree::ReviewsConfiguration %>
17
- <%= tab :reviews, url: spree.edit_admin_review_settings_path, match_path: /review_settings/ %>
18
- <% end %>
19
- HTML
20
- end
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'solidus_reviews/factories'