solidus_reviews 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -318
- data/.rubocop_todo.yml +221 -0
- data/CHANGELOG.md +100 -0
- data/Gemfile +11 -10
- data/README.md +29 -44
- data/app/controllers/spree/feedback_reviews_controller.rb +2 -8
- data/app/controllers/spree/reviews_controller.rb +1 -1
- data/app/decorators/models/solidus_reviews/spree/product_decorator.rb +6 -5
- data/app/helpers/spree/reviews_helper.rb +5 -5
- data/app/models/spree/feedback_review.rb +1 -1
- data/app/models/spree/review.rb +9 -8
- data/app/models/spree/reviews_ability.rb +2 -2
- data/app/views/spree/api/reviews/_feedback_review.json.jbuilder +1 -1
- data/app/views/spree/api/reviews/_review.json.jbuilder +1 -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/reviews_controller.rb +16 -14
- data/lib/generators/solidus_reviews/install/install_generator.rb +1 -1
- data/lib/solidus_reviews.rb +4 -2
- data/lib/{spree_reviews → solidus_reviews}/engine.rb +3 -3
- data/lib/solidus_reviews/version.rb +5 -0
- data/solidus_reviews.gemspec +14 -23
- 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/reviews_controller_spec.rb +27 -25
- data/spec/controllers/spree/feedback_reviews_controller_spec.rb +7 -7
- data/spec/controllers/spree/products_controller_spec.rb +1 -1
- data/spec/controllers/spree/reviews_controller_spec.rb +6 -7
- data/spec/features/admin_spec.rb +6 -6
- data/spec/features/reviews_spec.rb +32 -31
- data/spec/models/feedback_review_spec.rb +13 -13
- data/spec/models/product_spec.rb +13 -10
- data/spec/models/review_spec.rb +36 -40
- data/spec/models/reviews_ability_spec.rb +14 -14
- data/spec/models/reviews_configuration_spec.rb +9 -10
- data/spec/spec_helper.rb +4 -19
- data/spec/support/config.rb +7 -0
- data/spec/support/factories.rb +3 -0
- metadata +18 -180
- data/CONTRIBUTING.md +0 -28
@@ -2,90 +2,91 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
describe 'Reviews', js: true do
|
6
|
+
let!(:someone) { create(:user, email: 'ryan@spree.com') }
|
7
|
+
let!(:review) { create(:review, :approved, user: someone) }
|
8
|
+
let!(:unapproved_review) { create(:review, product: review.product) }
|
9
9
|
|
10
|
-
|
11
|
-
Spree::Reviews::Config
|
10
|
+
before do
|
11
|
+
stub_spree_preferences(Spree::Reviews::Config, include_unapproved_reviews: false)
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'product with no review' do
|
15
|
-
|
16
|
-
|
15
|
+
let!(:product_no_reviews) { create(:product) }
|
16
|
+
|
17
|
+
it 'informs that no reviews has been written yet' do
|
17
18
|
visit spree.product_path(product_no_reviews)
|
18
19
|
expect(page).to have_text I18n.t('spree.no_reviews_available')
|
19
20
|
end
|
20
21
|
|
21
22
|
# Regression test for #103
|
22
23
|
context "shows correct number of previews" do
|
23
|
-
|
24
|
+
before do
|
24
25
|
FactoryBot.create_list :review, 3, product: product_no_reviews, approved: true
|
25
|
-
Spree::Reviews::Config
|
26
|
+
stub_spree_preferences(Spree::Reviews::Config, preview_size: 2)
|
26
27
|
end
|
27
28
|
|
28
|
-
|
29
|
+
it "displayed reviews are limited by the set preview size" do
|
29
30
|
visit spree.product_path(product_no_reviews)
|
30
|
-
expect(page.all(".review").count).to
|
31
|
+
expect(page.all(".review").count).to be(2)
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
35
36
|
context 'when anonymous user' do
|
36
|
-
|
37
|
-
Spree::Reviews::Config
|
37
|
+
before do
|
38
|
+
stub_spree_preferences(Spree::Reviews::Config, require_login: true)
|
38
39
|
end
|
39
40
|
|
40
41
|
context 'visit product with review' do
|
41
|
-
|
42
|
+
before do
|
42
43
|
visit spree.product_path(review.product)
|
43
44
|
end
|
44
45
|
|
45
|
-
|
46
|
+
it 'sees review title' do
|
46
47
|
expect(page).to have_text review.title
|
47
48
|
end
|
48
49
|
|
49
|
-
|
50
|
+
it 'can not create review' do
|
50
51
|
expect(page).not_to have_text I18n.t('spree.write_your_own_review')
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
55
56
|
context 'when logged in user' do
|
56
|
-
|
57
|
+
let!(:user) { create(:user) }
|
57
58
|
|
58
|
-
|
59
|
+
before do
|
59
60
|
sign_in_as! user
|
60
61
|
end
|
61
62
|
|
62
63
|
context 'visit product with review' do
|
63
|
-
|
64
|
+
before do
|
64
65
|
visit spree.product_path(review.product)
|
65
66
|
end
|
66
67
|
|
67
|
-
|
68
|
+
it 'can see review title' do
|
68
69
|
expect(page).to have_text review.title
|
69
70
|
end
|
70
71
|
|
71
72
|
context 'with unapproved content allowed' do
|
72
|
-
|
73
|
-
Spree::Reviews::Config
|
74
|
-
Spree::Reviews::Config
|
73
|
+
before do
|
74
|
+
stub_spree_preferences(Spree::Reviews::Config, include_unapproved_reviews: true)
|
75
|
+
stub_spree_preferences(Spree::Reviews::Config, display_unapproved_reviews: true)
|
75
76
|
visit spree.product_path(review.product)
|
76
77
|
end
|
77
78
|
|
78
|
-
|
79
|
+
it 'can see unapproved content when allowed' do
|
79
80
|
expect(unapproved_review.approved?).to eq(false)
|
80
81
|
expect(page).to have_text unapproved_review.title
|
81
82
|
end
|
82
83
|
end
|
83
84
|
|
84
|
-
|
85
|
+
it 'can see create new review button' do
|
85
86
|
expect(page).to have_text I18n.t('spree.write_your_own_review')
|
86
87
|
end
|
87
88
|
|
88
|
-
|
89
|
+
it 'can create new review' do
|
89
90
|
click_on I18n.t('spree.write_your_own_review')
|
90
91
|
|
91
92
|
expect(page).to have_text I18n.t('spree.leave_us_a_review_for', name: review.product.name)
|
@@ -108,14 +109,14 @@ feature 'Reviews', js: true do
|
|
108
109
|
end
|
109
110
|
|
110
111
|
context 'visit product with review where show_identifier is false' do
|
111
|
-
|
112
|
-
|
112
|
+
let!(:user) { create(:user) }
|
113
|
+
let!(:review) { create(:review, :approved, :hide_identifier, review: 'review text', user: user) }
|
113
114
|
|
114
|
-
|
115
|
+
before do
|
115
116
|
visit spree.product_path(review.product)
|
116
117
|
end
|
117
118
|
|
118
|
-
|
119
|
+
it 'show anonymous review' do
|
119
120
|
expect(page).to have_text I18n.t('spree.anonymous')
|
120
121
|
expect(page).to have_text 'review text'
|
121
122
|
end
|
@@ -13,30 +13,30 @@ describe Spree::FeedbackReview do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'does not validate with a nil review' do
|
16
|
-
expect(build(:feedback_review, review: nil)).
|
16
|
+
expect(build(:feedback_review, review: nil)).not_to be_valid
|
17
17
|
end
|
18
18
|
|
19
19
|
context 'rating' do
|
20
20
|
it 'does not validate when no rating is specified' do
|
21
|
-
expect(build(:feedback_review, rating: nil)).
|
21
|
+
expect(build(:feedback_review, rating: nil)).not_to be_valid
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'does not validate when the rating is not a number' do
|
25
|
-
expect(build(:feedback_review, rating: 'not_a_number')).
|
25
|
+
expect(build(:feedback_review, rating: 'not_a_number')).not_to be_valid
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'does not validate when the rating is a float' do
|
29
|
-
expect(build(:feedback_review, rating: 2.718)).
|
29
|
+
expect(build(:feedback_review, rating: 2.718)).not_to be_valid
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'does not validate when the rating is less than 1' do
|
33
|
-
expect(build(:feedback_review, rating: 0)).
|
34
|
-
expect(build(:feedback_review, rating: -5)).
|
33
|
+
expect(build(:feedback_review, rating: 0)).not_to be_valid
|
34
|
+
expect(build(:feedback_review, rating: -5)).not_to be_valid
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'does not validate when the rating is greater than 5' do
|
38
|
-
expect(build(:feedback_review, rating: 6)).
|
39
|
-
expect(build(:feedback_review, rating: 8)).
|
38
|
+
expect(build(:feedback_review, rating: 6)).not_to be_valid
|
39
|
+
expect(build(:feedback_review, rating: 8)).not_to be_valid
|
40
40
|
end
|
41
41
|
|
42
42
|
(1..5).each do |i|
|
@@ -54,11 +54,11 @@ describe Spree::FeedbackReview do
|
|
54
54
|
let!(:feedback_review_3) { create(:feedback_review, created_at: 5.days.ago) }
|
55
55
|
|
56
56
|
it 'properly runs most_recent_first queries' do
|
57
|
-
expect(
|
57
|
+
expect(described_class.most_recent_first.to_a).to eq([feedback_review_2, feedback_review_3, feedback_review_1])
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'defaults to most_recent_first queries' do
|
61
|
-
expect(
|
61
|
+
expect(described_class.all.to_a).to eq([feedback_review_2, feedback_review_3, feedback_review_1])
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -71,9 +71,9 @@ describe Spree::FeedbackReview do
|
|
71
71
|
let!(:fr_feedback_review_1) { create(:feedback_review, locale: 'fr', created_at: 10.days.ago) }
|
72
72
|
|
73
73
|
it 'properly runs localized queries' do
|
74
|
-
expect(
|
75
|
-
expect(
|
76
|
-
expect(
|
74
|
+
expect(described_class.localized('en').to_a).to eq([en_feedback_review_2, en_feedback_review_3, en_feedback_review_1])
|
75
|
+
expect(described_class.localized('es').to_a).to eq([es_feedback_review_1])
|
76
|
+
expect(described_class.localized('fr').to_a).to eq([fr_feedback_review_1])
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
data/spec/models/product_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe Spree::Product do
|
|
7
7
|
it { is_expected.to respond_to(:reviews) }
|
8
8
|
it { is_expected.to respond_to(:stars) }
|
9
9
|
|
10
|
-
|
10
|
+
describe '#stars' do
|
11
11
|
let(:product) { build(:product) }
|
12
12
|
|
13
13
|
it 'rounds' do
|
@@ -27,7 +27,7 @@ describe Spree::Product do
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
describe '#recalculate_rating' do
|
31
31
|
let!(:product) { create(:product) }
|
32
32
|
|
33
33
|
context 'when there are approved reviews' do
|
@@ -36,11 +36,8 @@ describe Spree::Product do
|
|
36
36
|
let!(:unapproved_review_1) { create(:review, product: product, approved: false, rating: 4) }
|
37
37
|
|
38
38
|
context "including unapproved reviews" do
|
39
|
-
before
|
40
|
-
Spree::Reviews::Config
|
41
|
-
end
|
42
|
-
after(:all) do
|
43
|
-
Spree::Reviews::Config[:include_unapproved_reviews] = false
|
39
|
+
before do
|
40
|
+
stub_spree_preferences(Spree::Reviews::Config, include_unapproved_reviews: true)
|
44
41
|
end
|
45
42
|
|
46
43
|
it "updates the product average rating and ignores unapproved reviews" do
|
@@ -55,6 +52,10 @@ describe Spree::Product do
|
|
55
52
|
end
|
56
53
|
|
57
54
|
context "only approved reviews" do
|
55
|
+
before do
|
56
|
+
stub_spree_preferences(Spree::Reviews::Config, include_unapproved_reviews: false)
|
57
|
+
end
|
58
|
+
|
58
59
|
it "updates the product average rating and ignores unapproved reviews" do
|
59
60
|
product.avg_rating = 0
|
60
61
|
product.reviews_count = 0
|
@@ -70,10 +71,12 @@ describe Spree::Product do
|
|
70
71
|
context "without unapproved reviews" do
|
71
72
|
let!(:unapproved_review_1) { create(:review, product: product, approved: false, rating: 4) }
|
72
73
|
|
74
|
+
before do
|
75
|
+
stub_spree_preferences(Spree::Reviews::Config, include_unapproved_reviews: false)
|
76
|
+
end
|
77
|
+
|
73
78
|
it "updates the product average rating and ignores unapproved reviews" do
|
74
|
-
product.avg_rating
|
75
|
-
product.reviews_count = 20
|
76
|
-
product.save!
|
79
|
+
product.update_columns(avg_rating: 3, reviews_count: 20)
|
77
80
|
|
78
81
|
product.recalculate_rating
|
79
82
|
expect(product.avg_rating).to eq(0)
|
data/spec/models/review_spec.rb
CHANGED
@@ -18,25 +18,25 @@ describe Spree::Review do
|
|
18
18
|
|
19
19
|
context 'rating' do
|
20
20
|
it 'does not validate when no rating is specified' do
|
21
|
-
expect(build(:review, rating: nil)).
|
21
|
+
expect(build(:review, rating: nil)).not_to be_valid
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'does not validate when the rating is not a number' do
|
25
|
-
expect(build(:review, rating: 'not_a_number')).
|
25
|
+
expect(build(:review, rating: 'not_a_number')).not_to be_valid
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'does not validate when the rating is a float' do
|
29
|
-
expect(build(:review, rating: 2.718)).
|
29
|
+
expect(build(:review, rating: 2.718)).not_to be_valid
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'does not validate when the rating is less than 1' do
|
33
|
-
expect(build(:review, rating: 0)).
|
34
|
-
expect(build(:review, rating: -5)).
|
33
|
+
expect(build(:review, rating: 0)).not_to be_valid
|
34
|
+
expect(build(:review, rating: -5)).not_to be_valid
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'does not validate when the rating is greater than 5' do
|
38
|
-
expect(build(:review, rating: 6)).
|
39
|
-
expect(build(:review, rating: 8)).
|
38
|
+
expect(build(:review, rating: 6)).not_to be_valid
|
39
|
+
expect(build(:review, rating: 8)).not_to be_valid
|
40
40
|
end
|
41
41
|
|
42
42
|
(1..5).each do |i|
|
@@ -47,7 +47,7 @@ describe Spree::Review do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
context 'review body' do
|
50
|
-
it '
|
50
|
+
it 'is valid without a body' do
|
51
51
|
expect(build(:review, review: nil)).to be_valid
|
52
52
|
end
|
53
53
|
end
|
@@ -60,11 +60,11 @@ describe Spree::Review do
|
|
60
60
|
let!(:review_3) { create(:review, created_at: 5.days.ago) }
|
61
61
|
|
62
62
|
it 'properly runs most_recent_first queries' do
|
63
|
-
expect(
|
63
|
+
expect(described_class.most_recent_first.to_a).to eq([review_2, review_3, review_1])
|
64
64
|
end
|
65
65
|
|
66
66
|
it 'defaults to most_recent_first queries' do
|
67
|
-
expect(
|
67
|
+
expect(described_class.all.to_a).to eq([review_2, review_3, review_1])
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -72,19 +72,14 @@ describe Spree::Review do
|
|
72
72
|
let!(:review_1) { create(:review, created_at: 10.days.ago) }
|
73
73
|
let!(:review_2) { create(:review, created_at: 2.days.ago) }
|
74
74
|
let!(:review_3) { create(:review, created_at: 5.days.ago) }
|
75
|
-
let!(:review_4) { create(:review, created_at: 1.
|
76
|
-
|
77
|
-
before do
|
78
|
-
reset_spree_preferences
|
79
|
-
Spree::Reviews::Config.preference_store = Spree::Reviews::Config.default_preferences
|
80
|
-
end
|
75
|
+
let!(:review_4) { create(:review, created_at: 1.day.ago) }
|
81
76
|
|
82
77
|
it 'properly runs oldest_first queries' do
|
83
|
-
expect(
|
78
|
+
expect(described_class.oldest_first.to_a).to eq([review_1, review_3, review_2, review_4])
|
84
79
|
end
|
85
80
|
|
86
81
|
it 'uses oldest_first for preview' do
|
87
|
-
expect(
|
82
|
+
expect(described_class.preview.to_a).to eq([review_1, review_3, review_2])
|
88
83
|
end
|
89
84
|
end
|
90
85
|
|
@@ -97,9 +92,9 @@ describe Spree::Review do
|
|
97
92
|
let!(:fr_review_1) { create(:review, locale: 'fr', created_at: 10.days.ago) }
|
98
93
|
|
99
94
|
it 'properly runs localized queries' do
|
100
|
-
expect(
|
101
|
-
expect(
|
102
|
-
expect(
|
95
|
+
expect(described_class.localized('en').to_a).to eq([en_review_2, en_review_3, en_review_1])
|
96
|
+
expect(described_class.localized('es').to_a).to eq([es_review_1])
|
97
|
+
expect(described_class.localized('fr').to_a).to eq([fr_review_1])
|
103
98
|
end
|
104
99
|
end
|
105
100
|
|
@@ -109,26 +104,26 @@ describe Spree::Review do
|
|
109
104
|
let!(:approved_review_3) { create(:review, approved: true, created_at: 5.days.ago) }
|
110
105
|
|
111
106
|
let!(:unapproved_review_1) { create(:review, approved: false, created_at: 7.days.ago) }
|
112
|
-
let!(:unapproved_review_2) { create(:review, approved: false, created_at: 1.
|
107
|
+
let!(:unapproved_review_2) { create(:review, approved: false, created_at: 1.day.ago) }
|
113
108
|
|
114
109
|
it 'properly runs approved and unapproved queries' do
|
115
|
-
expect(
|
116
|
-
expect(
|
117
|
-
|
118
|
-
Spree::Reviews::Config
|
119
|
-
expect(
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
Spree::Reviews::Config
|
126
|
-
expect(
|
110
|
+
expect(described_class.approved.to_a).to eq([approved_review_2, approved_review_3, approved_review_1])
|
111
|
+
expect(described_class.not_approved.to_a).to eq([unapproved_review_2, unapproved_review_1])
|
112
|
+
|
113
|
+
stub_spree_preferences(Spree::Reviews::Config, include_unapproved_reviews: true)
|
114
|
+
expect(described_class.default_approval_filter.to_a).to eq([unapproved_review_2,
|
115
|
+
approved_review_2,
|
116
|
+
approved_review_3,
|
117
|
+
unapproved_review_1,
|
118
|
+
approved_review_1])
|
119
|
+
|
120
|
+
stub_spree_preferences(Spree::Reviews::Config, include_unapproved_reviews: false)
|
121
|
+
expect(described_class.default_approval_filter.to_a).to eq([approved_review_2, approved_review_3, approved_review_1])
|
127
122
|
end
|
128
123
|
end
|
129
124
|
end
|
130
125
|
|
131
|
-
|
126
|
+
describe '#recalculate_product_rating' do
|
132
127
|
let(:product) { create(:product) }
|
133
128
|
let!(:review) { create(:review, product: product) }
|
134
129
|
|
@@ -141,7 +136,7 @@ describe Spree::Review do
|
|
141
136
|
end
|
142
137
|
|
143
138
|
it 'if not approved' do
|
144
|
-
expect(review).
|
139
|
+
expect(review).not_to receive(:recalculate_product_rating)
|
145
140
|
review.save!
|
146
141
|
end
|
147
142
|
|
@@ -152,8 +147,9 @@ describe Spree::Review do
|
|
152
147
|
end
|
153
148
|
end
|
154
149
|
|
155
|
-
|
150
|
+
describe '#feedback_stars' do
|
156
151
|
let!(:review) { create(:review) }
|
152
|
+
|
157
153
|
before do
|
158
154
|
3.times do |i|
|
159
155
|
f = Spree::FeedbackReview.new
|
@@ -163,12 +159,12 @@ describe Spree::Review do
|
|
163
159
|
end
|
164
160
|
end
|
165
161
|
|
166
|
-
it '
|
162
|
+
it 'returns the average rating from feedback reviews' do
|
167
163
|
expect(review.feedback_stars).to eq 2
|
168
164
|
end
|
169
165
|
end
|
170
166
|
|
171
|
-
|
167
|
+
describe '#email' do
|
172
168
|
it 'returns email from user' do
|
173
169
|
user = build(:user, email: 'john@smith.com')
|
174
170
|
review = build(:review, user: user)
|
@@ -191,7 +187,7 @@ describe Spree::Review do
|
|
191
187
|
end
|
192
188
|
end
|
193
189
|
|
194
|
-
|
190
|
+
describe "#verify_purchaser" do
|
195
191
|
let(:order) { create(:completed_order_with_totals) }
|
196
192
|
let(:product) { order.products.first }
|
197
193
|
let(:user) { order.user }
|
@@ -5,12 +5,12 @@ require 'spec_helper'
|
|
5
5
|
require "cancan/matchers"
|
6
6
|
|
7
7
|
describe Spree::ReviewsAbility do
|
8
|
-
|
9
|
-
it '
|
10
|
-
Spree::Reviews::Config
|
11
|
-
expect(
|
12
|
-
Spree::Reviews::Config
|
13
|
-
expect(
|
8
|
+
describe '.allow_anonymous_reviews?' do
|
9
|
+
it 'depends on Spree::Reviews::Config[:require_login]' do
|
10
|
+
stub_spree_preferences(Spree::Reviews::Config, require_login: false)
|
11
|
+
expect(described_class.allow_anonymous_reviews?).to be true
|
12
|
+
stub_spree_preferences(Spree::Reviews::Config, require_login: true)
|
13
|
+
expect(described_class.allow_anonymous_reviews?).to be false
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -20,28 +20,28 @@ describe Spree::ReviewsAbility do
|
|
20
20
|
|
21
21
|
context 'when anonymous reviews are allowed' do
|
22
22
|
before do
|
23
|
-
Spree::Reviews::Config
|
23
|
+
stub_spree_preferences(Spree::Reviews::Config, require_login: false)
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'lets anyone create a review or feedback review' do
|
27
27
|
[user_without_email, user_with_email].each do |u|
|
28
|
-
expect(
|
29
|
-
expect(
|
28
|
+
expect(described_class.new(u)).to be_able_to(:create, Spree::Review.new)
|
29
|
+
expect(described_class.new(u)).to be_able_to(:create, Spree::FeedbackReview.new)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
context 'when anonymous reviews are not allowed' do
|
35
35
|
before do
|
36
|
-
Spree::Reviews::Config
|
36
|
+
stub_spree_preferences(Spree::Reviews::Config, require_login: true)
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'only allows users with an email to create a review or feedback review' do
|
40
|
-
expect(
|
41
|
-
expect(
|
40
|
+
expect(described_class.new(user_without_email)).not_to be_able_to(:create, Spree::Review.new)
|
41
|
+
expect(described_class.new(user_without_email)).not_to be_able_to(:create, Spree::FeedbackReview.new)
|
42
42
|
|
43
|
-
expect(
|
44
|
-
expect(
|
43
|
+
expect(described_class.new(user_with_email)).to be_able_to(:create, Spree::Review.new)
|
44
|
+
expect(described_class.new(user_with_email)).to be_able_to(:create, Spree::FeedbackReview.new)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|