solidus_reviews 1.2.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +6 -0
- data/.gem_release.yml +5 -0
- data/.gitignore +13 -6
- data/.rspec +1 -1
- data/.rubocop.yml +3 -321
- data/.rubocop_todo.yml +197 -0
- data/CHANGELOG.md +155 -0
- data/Gemfile +14 -17
- data/{LICENSE.md → LICENSE} +1 -1
- data/README.md +63 -41
- data/Rakefile +3 -20
- data/app/assets/stylesheets/spree/frontend/solidus_reviews.css +4 -0
- data/app/controllers/spree/feedback_reviews_controller.rb +2 -8
- data/app/controllers/spree/reviews_controller.rb +29 -2
- data/app/decorators/controllers/solidus_reviews/spree/{admin/products_controller_decorator.rb → products_controller_decorator.rb} +0 -4
- data/app/decorators/models/solidus_reviews/spree/product_decorator.rb +6 -5
- data/app/helpers/spree/reviews_helper.rb +6 -6
- data/app/models/spree/feedback_review.rb +2 -2
- data/app/models/spree/permission_sets/review_display.rb +11 -0
- data/app/models/spree/permission_sets/review_management.rb +11 -0
- data/app/models/spree/review.rb +25 -10
- data/app/models/spree/reviews_ability.rb +7 -2
- data/app/models/spree/reviews_configuration.rb +10 -1
- data/app/overrides/add_reviews_tab_to_admin.rb +12 -4
- data/app/overrides/add_reviews_to_admin_configuration_sidebar.rb +12 -5
- data/app/views/spree/admin/review_settings/edit.html.erb +7 -0
- data/app/views/spree/admin/reviews/edit.html.erb +4 -2
- data/app/views/spree/admin/reviews/index.html.erb +9 -5
- data/app/views/spree/api/reviews/_feedback_review.json.jbuilder +1 -1
- data/app/views/spree/api/reviews/_review.json.jbuilder +1 -1
- data/app/views/spree/reviews/_form.html.erb +6 -4
- data/app/views/spree/reviews/edit.html.erb +3 -0
- data/app/views/spree/shared/_review.html.erb +6 -4
- data/bin/console +17 -0
- data/bin/rails +5 -5
- data/bin/rails-engine +13 -0
- data/bin/rails-sandbox +16 -0
- data/bin/rake +7 -0
- data/bin/sandbox +86 -0
- data/bin/setup +8 -0
- data/config/locales/de-CH.yml +1 -1
- data/config/locales/de.yml +1 -1
- data/config/locales/en-GB.yml +2 -1
- data/config/locales/en.yml +2 -1
- data/config/locales/es.yml +2 -1
- data/config/locales/fr.yml +1 -1
- data/config/locales/it.yml +1 -1
- data/config/locales/pl.yml +1 -1
- data/config/locales/pt-BR.yml +1 -1
- data/config/locales/pt.yml +1 -1
- data/config/locales/ro.yml +1 -1
- data/config/locales/sv.yml +1 -1
- data/config/locales/tr.yml +1 -1
- data/config/locales/uk.yml +1 -1
- data/config/locales/zh-CN.yml +1 -1
- data/config/locales/zh-TW.yml +1 -1
- data/config/routes.rb +3 -1
- data/db/migrate/20120123141326_recalculate_ratings.rb +1 -2
- data/db/migrate/20190613165528_add_verified_purchaser_to_reviews.rb +2 -0
- data/lib/controllers/spree/api/feedback_reviews_controller.rb +91 -0
- data/lib/controllers/spree/api/reviews_controller.rb +16 -14
- data/lib/generators/solidus_reviews/install/install_generator.rb +8 -7
- data/lib/solidus_reviews/engine.rb +26 -0
- data/lib/solidus_reviews/version.rb +5 -0
- data/lib/solidus_reviews.rb +4 -4
- data/solidus_reviews.gemspec +31 -34
- data/spec/controllers/spree/admin/feedback_reviews_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/review_settings_controller_spec.rb +3 -4
- data/spec/controllers/spree/admin/reviews_controller_spec.rb +3 -3
- data/spec/controllers/spree/api/feedback_reviews_controller_spec.rb +136 -0
- data/spec/controllers/spree/api/reviews_controller_spec.rb +27 -25
- data/spec/controllers/spree/feedback_reviews_controller_spec.rb +8 -8
- data/spec/controllers/spree/reviews_controller_spec.rb +145 -8
- data/spec/features/admin_spec.rb +6 -6
- data/spec/features/reviews_spec.rb +33 -32
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spec/models/feedback_review_spec.rb +13 -13
- data/spec/models/product_spec.rb +13 -10
- data/spec/models/review_spec.rb +64 -41
- data/spec/models/reviews_ability_spec.rb +14 -14
- data/spec/models/reviews_configuration_spec.rb +21 -10
- data/spec/spec_helper.rb +18 -13
- data/spec/support/config.rb +7 -0
- data/spec/support/factories.rb +3 -0
- metadata +52 -213
- data/CONTRIBUTING.md +0 -28
- data/lib/spree_reviews/engine.rb +0 -22
- data/spec/controllers/spree/products_controller_spec.rb +0 -11
data/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/Gemfile
CHANGED
@@ -1,31 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
4
5
|
|
5
6
|
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
|
6
|
-
gem 'solidus',
|
7
|
-
gem 'solidus_auth_devise'
|
7
|
+
gem 'solidus', github: 'solidusio/solidus', branch: branch
|
8
8
|
|
9
|
-
# Needed to help Bundler figure out how to resolve dependencies,
|
10
|
-
# resolve them
|
11
|
-
|
12
|
-
|
13
|
-
else
|
14
|
-
gem 'rails', '~> 5.0'
|
15
|
-
end
|
9
|
+
# Needed to help Bundler figure out how to resolve dependencies,
|
10
|
+
# otherwise it takes forever to resolve them.
|
11
|
+
# See https://github.com/bundler/bundler/issues/6677
|
12
|
+
gem 'rails', '>0.a'
|
16
13
|
|
17
|
-
|
18
|
-
gem '
|
14
|
+
# Provides basic authentication functionality for testing parts of your engine
|
15
|
+
gem 'solidus_auth_devise'
|
19
16
|
|
20
17
|
case ENV['DB']
|
21
18
|
when 'mysql'
|
22
|
-
gem 'mysql2'
|
23
|
-
when '
|
24
|
-
gem 'pg'
|
19
|
+
gem 'mysql2'
|
20
|
+
when 'postgresql'
|
21
|
+
gem 'pg'
|
22
|
+
else
|
23
|
+
gem 'sqlite3'
|
25
24
|
end
|
26
25
|
|
27
|
-
|
28
|
-
gem 'factory_bot', '> 4.10.0'
|
29
|
-
end
|
26
|
+
gem 'rails-controller-testing', group: :test
|
30
27
|
|
31
28
|
gemspec
|
data/{LICENSE.md → LICENSE}
RENAMED
data/README.md
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
# Reviews
|
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
4
|
|
5
|
-
Straightforward review/rating functionality, updated for
|
6
|
-
[Solidus](https://solidus.io). While the Gem name has changed, the module
|
7
|
-
namespace and commands are still `spree` for now.
|
5
|
+
Straightforward review/rating functionality, updated for [Solidus](https://solidus.io).
|
8
6
|
|
9
|
-
|
7
|
+
While the gem's name has changed, the module namespace and commands are still `spree` for now.
|
10
8
|
|
11
9
|
## Installation
|
12
10
|
|
@@ -15,77 +13,101 @@ Add the following to your `Gemfile` to install from git:
|
|
15
13
|
```ruby
|
16
14
|
gem 'solidus_reviews', github: 'solidusio-contrib/solidus_reviews'
|
17
15
|
```
|
16
|
+
|
18
17
|
Now bundle up with:
|
19
18
|
|
20
|
-
|
19
|
+
```console
|
20
|
+
$ bundle
|
21
|
+
```
|
21
22
|
|
22
23
|
Next, run the rake task that copies the necessary migrations and assets to your project:
|
23
24
|
|
24
|
-
|
25
|
+
```console
|
26
|
+
$ rails g solidus_reviews:install
|
27
|
+
```
|
25
28
|
|
26
29
|
And finish with a migrate:
|
27
30
|
|
28
|
-
|
31
|
+
```console
|
32
|
+
$ rake db:migrate
|
33
|
+
```
|
29
34
|
|
30
35
|
Now you should be able to boot up your server with:
|
31
36
|
|
32
|
-
|
37
|
+
```console
|
38
|
+
$ rails s
|
39
|
+
```
|
33
40
|
|
34
41
|
That's all!
|
35
42
|
|
36
|
-
---
|
37
|
-
|
38
43
|
## Usage
|
39
44
|
|
40
|
-
|
45
|
+
The `Spree::ReviewsController` controller provides all the CRUD functionality for product reviews.
|
41
46
|
|
42
|
-
|
47
|
+
The `Spree::FeedbackReviewsController` allows user to express their feedback on a specific review.
|
48
|
+
You can think of these as meta-reviews (e.g. the classic "Was this useful?" modal).
|
43
49
|
|
44
|
-
|
45
|
-
- `app/views/spree/products/_rating.html.erb` -- display number of stars
|
46
|
-
- `app/views/spree/products/_shortrating.html.erb` -- shorter version of above
|
47
|
-
- `app/views/spree/products/_review.html.erb` -- display a single review
|
48
|
-
|
49
|
-
Administrator can edit and/or approve and/or delete reviews.
|
50
|
+
You can approve, edit and delete reviews and feedback reviews from the backend.
|
50
51
|
|
51
52
|
## Factories
|
52
53
|
|
53
|
-
If you want factories for our models available in your application, simply
|
54
|
-
|
54
|
+
If you want factories for our models available in your application, simply require our factories in
|
55
|
+
your `spec_helper.rb`:
|
55
56
|
|
56
57
|
```ruby
|
57
|
-
require
|
58
|
+
require 'solidus_reviews/factories'
|
58
59
|
```
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
Reviews table is quite obvious - and note the "approved" flag which is for the
|
63
|
-
administrator to update.
|
61
|
+
### Testing the extension
|
64
62
|
|
65
|
-
|
63
|
+
First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
|
66
64
|
|
67
|
-
|
65
|
+
app if it does not exist, then it will run specs. The dummy app can be regenerated by using
|
66
|
+
`bin/rake extension:test_app`.
|
68
67
|
|
69
|
-
|
68
|
+
```shell
|
69
|
+
bin/rake
|
70
|
+
```
|
70
71
|
|
71
|
-
|
72
|
-
run the tests:
|
72
|
+
To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
|
73
73
|
|
74
74
|
```shell
|
75
|
-
bundle exec
|
75
|
+
bundle exec rubocop
|
76
76
|
```
|
77
77
|
|
78
|
-
|
78
|
+
### Running the sandbox
|
79
79
|
|
80
|
-
|
80
|
+
To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
|
81
81
|
|
82
|
-
|
82
|
+
the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
|
83
|
+
`sandbox/bin/rails`.
|
84
|
+
|
85
|
+
Here's an example:
|
86
|
+
|
87
|
+
```
|
88
|
+
$ bin/rails server
|
89
|
+
=> Booting Puma
|
90
|
+
=> Rails 6.0.2.1 application starting in development
|
91
|
+
* Listening on tcp://127.0.0.1:3000
|
92
|
+
Use Ctrl-C to stop
|
93
|
+
```
|
94
|
+
|
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
|
83
107
|
|
84
|
-
|
108
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/solidusio-contrib/solidus_reviews>.
|
85
109
|
|
86
|
-
|
110
|
+
## License
|
87
111
|
|
88
|
-
[
|
89
|
-
[
|
90
|
-
[3]: https://github.com/solidusio-contrib/solidus_reviews/graphs/contributors
|
91
|
-
[4]: ./LICENSE.md
|
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).
|
data/Rakefile
CHANGED
@@ -1,23 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
|
3
|
+
require 'solidus_dev_support/rake_tasks'
|
4
|
+
SolidusDevSupport::RakeTasks.install
|
5
5
|
|
6
|
-
|
7
|
-
require 'spree/testing_support/extension_rake'
|
8
|
-
|
9
|
-
RSpec::Core::RakeTask.new
|
10
|
-
|
11
|
-
task :default do
|
12
|
-
if Dir["spec/dummy"].empty?
|
13
|
-
Rake::Task[:test_app].invoke
|
14
|
-
Dir.chdir("../../")
|
15
|
-
end
|
16
|
-
Rake::Task[:spec].invoke
|
17
|
-
end
|
18
|
-
|
19
|
-
desc 'Generates a dummy app for testing'
|
20
|
-
task :test_app do
|
21
|
-
ENV['LIB_NAME'] = 'solidus_reviews'
|
22
|
-
Rake::Task['extension:test_app'].invoke
|
23
|
-
end
|
6
|
+
task default: 'extension:specs'
|
@@ -16,13 +16,7 @@ class Spree::FeedbackReviewsController < Spree::StoreController
|
|
16
16
|
end
|
17
17
|
|
18
18
|
respond_to do |format|
|
19
|
-
format.html {
|
20
|
-
if SolidusSupport.solidus_gem_version < Gem::Version.new('2.0')
|
21
|
-
redirect_to(:back)
|
22
|
-
else
|
23
|
-
redirect_back(fallback_location: root_path)
|
24
|
-
end
|
25
|
-
}
|
19
|
+
format.html { redirect_back(fallback_location: root_path) }
|
26
20
|
format.js { render action: :create }
|
27
21
|
end
|
28
22
|
end
|
@@ -30,7 +24,7 @@ class Spree::FeedbackReviewsController < Spree::StoreController
|
|
30
24
|
protected
|
31
25
|
|
32
26
|
def load_review
|
33
|
-
@review ||= Spree::Review.
|
27
|
+
@review ||= Spree::Review.find_by!(id: params[:review_id])
|
34
28
|
end
|
35
29
|
|
36
30
|
def permitted_feedback_review_attributes
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
class Spree::ReviewsController < Spree::StoreController
|
4
4
|
helper Spree::BaseHelper
|
5
|
-
before_action :load_product, only: [:index, :new, :create]
|
5
|
+
before_action :load_product, only: [:index, :new, :create, :edit, :update]
|
6
6
|
|
7
7
|
def index
|
8
8
|
@approved_reviews = Spree::Review.approved.where(product: @product)
|
@@ -13,9 +13,17 @@ class Spree::ReviewsController < Spree::StoreController
|
|
13
13
|
authorize! :create, @review
|
14
14
|
end
|
15
15
|
|
16
|
+
def edit
|
17
|
+
@review = Spree::Review.find(params[:id])
|
18
|
+
if @review.product.nil?
|
19
|
+
flash[:error] = I18n.t('spree.error_no_product')
|
20
|
+
end
|
21
|
+
authorize! :update, @review
|
22
|
+
end
|
23
|
+
|
16
24
|
# save if all ok
|
17
25
|
def create
|
18
|
-
|
26
|
+
review_params[:rating].sub!(/\s*[^0-9]*\z/, '') if review_params[:rating].present?
|
19
27
|
|
20
28
|
@review = Spree::Review.new(review_params)
|
21
29
|
@review.product = @product
|
@@ -36,6 +44,25 @@ class Spree::ReviewsController < Spree::StoreController
|
|
36
44
|
end
|
37
45
|
end
|
38
46
|
|
47
|
+
def update
|
48
|
+
review_params[:rating].sub!(/\s*[^0-9]*\z/, '') if params[:review][:rating].present?
|
49
|
+
|
50
|
+
@review = Spree::Review.find(params[:id])
|
51
|
+
|
52
|
+
# Handle images
|
53
|
+
params[:review][:images]&.each do |image|
|
54
|
+
@review.images.new(attachment: image)
|
55
|
+
end
|
56
|
+
|
57
|
+
authorize! :update, @review
|
58
|
+
if @review.update(review_params)
|
59
|
+
flash[:notice] = I18n.t('spree.review_successfully_submitted')
|
60
|
+
redirect_to spree.product_path(@product)
|
61
|
+
else
|
62
|
+
render :edit
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
39
66
|
private
|
40
67
|
|
41
68
|
def load_product
|
@@ -7,10 +7,6 @@ module SolidusReviews
|
|
7
7
|
base.class_eval do
|
8
8
|
helper ::Spree::ReviewsHelper
|
9
9
|
end
|
10
|
-
|
11
|
-
[:avg_rating, :reviews_count].each do |attribute|
|
12
|
-
::Spree::PermittedAttributes.product_attributes << attribute
|
13
|
-
end
|
14
10
|
end
|
15
11
|
|
16
12
|
::Spree::ProductsController.prepend self
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module SolidusReviews
|
3
4
|
module Spree
|
4
5
|
module ProductDecorator
|
@@ -16,11 +17,11 @@ module SolidusReviews
|
|
16
17
|
reviews_count = reviews.reload.default_approval_filter.count
|
17
18
|
|
18
19
|
self.reviews_count = reviews_count
|
19
|
-
if reviews_count > 0
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
self.avg_rating = if reviews_count > 0
|
21
|
+
'%.1f' % (reviews.default_approval_filter.sum(:rating).to_f / reviews_count)
|
22
|
+
else
|
23
|
+
0
|
24
|
+
end
|
24
25
|
save
|
25
26
|
end
|
26
27
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Spree::ReviewsHelper
|
4
4
|
def star(the_class)
|
5
|
-
|
5
|
+
tag.span(" ✮ ".html_safe, class: the_class)
|
6
6
|
end
|
7
7
|
|
8
8
|
def mk_stars(m)
|
@@ -18,10 +18,10 @@ module Spree::ReviewsHelper
|
|
18
18
|
def display_verified_purchaser?(review)
|
19
19
|
Spree::Reviews::Config[:show_verified_purchaser] && review.user &&
|
20
20
|
Spree::LineItem.joins(:order, :variant)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
.where.not(spree_orders: { completed_at: nil })
|
22
|
+
.find_by(
|
23
|
+
spree_variants: { product_id: review.product_id },
|
24
|
+
spree_orders: { user_id: review.user_id }
|
25
|
+
).present?
|
26
26
|
end
|
27
27
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class Spree::FeedbackReview <
|
3
|
+
class Spree::FeedbackReview < ApplicationRecord
|
4
4
|
belongs_to :user, class_name: Spree.user_class.to_s, optional: true
|
5
5
|
|
6
|
-
belongs_to :review,
|
6
|
+
belongs_to :review, touch: true
|
7
7
|
validates :review, presence: true
|
8
8
|
|
9
9
|
validates :rating, numericality: { only_integer: true,
|
data/app/models/spree/review.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class Spree::Review <
|
3
|
+
class Spree::Review < ApplicationRecord
|
4
4
|
belongs_to :product, touch: true, optional: true
|
5
5
|
belongs_to :user, class_name: Spree.user_class.to_s, optional: true
|
6
|
-
has_many :feedback_reviews
|
6
|
+
has_many :feedback_reviews, dependent: :destroy
|
7
7
|
has_many :images, -> { order(:position) }, as: :viewable,
|
8
|
-
|
8
|
+
dependent: :destroy, class_name: "Spree::Image"
|
9
9
|
|
10
|
-
|
10
|
+
before_save :verify_purchaser
|
11
|
+
before_save :approve_review, unless: :approved?
|
11
12
|
after_save :recalculate_product_rating, if: :approved?
|
12
13
|
after_destroy :recalculate_product_rating
|
13
14
|
|
@@ -28,6 +29,7 @@ class Spree::Review < ActiveRecord::Base
|
|
28
29
|
|
29
30
|
def feedback_stars
|
30
31
|
return 0 if feedback_reviews.size <= 0
|
32
|
+
|
31
33
|
((feedback_reviews.sum(:rating) / feedback_reviews.size) + 0.5).floor
|
32
34
|
end
|
33
35
|
|
@@ -36,19 +38,32 @@ class Spree::Review < ActiveRecord::Base
|
|
36
38
|
end
|
37
39
|
|
38
40
|
def email
|
39
|
-
user
|
41
|
+
user&.email
|
40
42
|
end
|
41
43
|
|
42
44
|
def verify_purchaser
|
43
45
|
return unless user_id && product_id
|
44
46
|
|
45
47
|
verified_purchase = Spree::LineItem.joins(:order, :variant)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
.where.not(spree_orders: { completed_at: nil })
|
49
|
+
.find_by(
|
50
|
+
spree_variants: { product_id: product_id },
|
51
|
+
spree_orders: { user_id: user_id }
|
52
|
+
).present?
|
51
53
|
|
52
54
|
self.verified_purchaser = verified_purchase
|
53
55
|
end
|
56
|
+
|
57
|
+
def star_only?
|
58
|
+
[title, review].all?(&:blank?) && rating.present?
|
59
|
+
end
|
60
|
+
|
61
|
+
def approve_review
|
62
|
+
# Checks if we should auto approve the review.
|
63
|
+
if Spree::Reviews::Config[:approve_star_only]
|
64
|
+
self.approved = true if star_only?
|
65
|
+
elsif Spree::Reviews::Config[:approve_star_only_for_verified_purchaser]
|
66
|
+
self.approved = true if star_only? && verified_purchaser?
|
67
|
+
end
|
68
|
+
end
|
54
69
|
end
|