workarea-reviews 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +20 -0
- data/.eslintignore +2 -0
- data/.eslintrc +24 -0
- data/.eslintrc.json +35 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
- data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/workflows/ci.yml +60 -0
- data/.gitignore +15 -0
- data/.rubocop.yml +3 -0
- data/.scss-lint.yml +188 -0
- data/.stylelintrc.json +8 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +745 -0
- data/CODE_OF_CONDUCT.md +3 -0
- data/CONTRIBUTING.md +3 -0
- data/Gemfile +8 -0
- data/LICENSE +52 -0
- data/README.md +107 -0
- data/Rakefile +53 -0
- data/app/assets/images/workarea/admin/icons/star.svg +1 -0
- data/app/assets/images/workarea/storefront/icons/empty_star.svg +1 -0
- data/app/assets/images/workarea/storefront/icons/half_star.svg +1 -0
- data/app/assets/images/workarea/storefront/icons/star.svg +1 -0
- data/app/assets/javascripts/workarea/storefront/reviews/modules/product_review_ajax_submit.js +39 -0
- data/app/assets/javascripts/workarea/storefront/reviews/modules/product_reviews_sort_menus.js +82 -0
- data/app/assets/javascripts/workarea/storefront/reviews/modules/rating_buttons.js +103 -0
- data/app/assets/javascripts/workarea/storefront/reviews/templates/sort_by_property.jst.ejs +11 -0
- data/app/assets/stylesheets/workarea/storefront/reviews/components/_rating.scss +28 -0
- data/app/assets/stylesheets/workarea/storefront/reviews/components/_reviews.scss +59 -0
- data/app/assets/stylesheets/workarea/storefront/reviews/components/_reviews_aggregate.scss +38 -0
- data/app/assets/stylesheets/workarea/storefront/reviews/components/_write_review.scss +63 -0
- data/app/controllers/workarea/admin/catalog_products_controller.decorator +9 -0
- data/app/controllers/workarea/admin/reports_controller.decorator +10 -0
- data/app/controllers/workarea/admin/reviews_controller.rb +51 -0
- data/app/controllers/workarea/storefront/review_requests_controller.rb +50 -0
- data/app/controllers/workarea/storefront/reviews_controller.rb +53 -0
- data/app/helpers/workarea/admin/reviews_helper.rb +13 -0
- data/app/helpers/workarea/storefront/reviews_helper.rb +22 -0
- data/app/helpers/workarea/storefront/reviews_schema_org_helper.rb +34 -0
- data/app/mailers/workarea/admin/status_report_mailer.decorator +8 -0
- data/app/mailers/workarea/storefront/review_mailer.rb +23 -0
- data/app/models/workarea/catalog/product.decorator +15 -0
- data/app/models/workarea/fulfillment.decorator +11 -0
- data/app/models/workarea/insights/most_active_reviewers.rb +34 -0
- data/app/models/workarea/insights/most_reviewed_products.rb +33 -0
- data/app/models/workarea/insights/top_rated_products.rb +33 -0
- data/app/models/workarea/review.rb +124 -0
- data/app/models/workarea/review/request.rb +62 -0
- data/app/models/workarea/search/admin/review.rb +72 -0
- data/app/models/workarea/search/storefront/product.decorator +9 -0
- data/app/models/workarea/sort.decorator +17 -0
- data/app/queries/workarea/reports/reviews_by_product.rb +86 -0
- data/app/queries/workarea/reports/reviews_by_user.rb +71 -0
- data/app/queries/workarea/review_request_params.rb +47 -0
- data/app/queries/workarea/review_summary.rb +11 -0
- data/app/queries/workarea/search/admin_reviews.rb +40 -0
- data/app/queries/workarea/search/category_browse.decorator +9 -0
- data/app/queries/workarea/search/product_search.decorator +9 -0
- data/app/seeds/workarea/review_seeds.rb +49 -0
- data/app/services/workarea/create_review.rb +99 -0
- data/app/view_models/workarea/admin/dashboards/reports_view_model.decorator +11 -0
- data/app/view_models/workarea/admin/product_view_model.decorator +7 -0
- data/app/view_models/workarea/admin/reports/reviews_by_product_view_model.rb +27 -0
- data/app/view_models/workarea/admin/review_view_model.rb +23 -0
- data/app/view_models/workarea/admin/reviews_search_view_model.rb +46 -0
- data/app/view_models/workarea/storefront/product_view_model.decorator +13 -0
- data/app/view_models/workarea/storefront/review_view_model.rb +14 -0
- data/app/views/workarea/admin/activities/_review_create.html.haml +12 -0
- data/app/views/workarea/admin/activities/_review_destroy.html.haml +10 -0
- data/app/views/workarea/admin/activities/_review_update.html.haml +10 -0
- data/app/views/workarea/admin/dashboards/_reviews_by_product_card.html.haml +17 -0
- data/app/views/workarea/admin/insights/_most_active_reviewers.html.haml +22 -0
- data/app/views/workarea/admin/insights/_most_reviewed_products.html.haml +22 -0
- data/app/views/workarea/admin/insights/_top_rated_products.html.haml +22 -0
- data/app/views/workarea/admin/reports/reviews_by_product.html.haml +44 -0
- data/app/views/workarea/admin/reviews/_aux_navigation.html.haml +5 -0
- data/app/views/workarea/admin/reviews/_catalog_products_aux_link.html.haml +5 -0
- data/app/views/workarea/admin/reviews/_dashboard_navigation.html.haml +1 -0
- data/app/views/workarea/admin/reviews/_menu.html.haml +3 -0
- data/app/views/workarea/admin/reviews/_summary.html.haml +12 -0
- data/app/views/workarea/admin/reviews/edit.html.haml +77 -0
- data/app/views/workarea/admin/reviews/index.html.haml +74 -0
- data/app/views/workarea/admin/status_report_mailer/_reviews.html.haml +5 -0
- data/app/views/workarea/storefront/products/_rating.html.haml +9 -0
- data/app/views/workarea/storefront/products/_reviews.html.haml +23 -0
- data/app/views/workarea/storefront/products/_reviews_aggregate.html.haml +22 -0
- data/app/views/workarea/storefront/products/_reviews_summary.html.haml +2 -0
- data/app/views/workarea/storefront/review_mailer/review_request.html.haml +24 -0
- data/app/views/workarea/storefront/review_requests/show.html.haml +45 -0
- data/app/views/workarea/storefront/reviews/new.html.haml +68 -0
- data/app/views/workarea/storefront/style_guides/_reviews_product_summary_docs.html.haml +13 -0
- data/app/views/workarea/storefront/style_guides/components/_reviews.html.haml +17 -0
- data/app/workers/workarea/create_review_requests.rb +33 -0
- data/app/workers/workarea/schedule_review_requests.rb +44 -0
- data/app/workers/workarea/send_review_requests.rb +12 -0
- data/app/workers/workarea/update_product_review_data.rb +26 -0
- data/bin/rails +18 -0
- data/config/initializers/append_points.rb +75 -0
- data/config/initializers/assets.rb +1 -0
- data/config/initializers/configuration.rb +31 -0
- data/config/initializers/rack_attack.rb +11 -0
- data/config/initializers/recaptcha.rb +19 -0
- data/config/initializers/scheduled_jobs.rb +8 -0
- data/config/locales/en.yml +150 -0
- data/config/routes.rb +25 -0
- data/lib/tasks/verify.rake +16 -0
- data/lib/workarea/mailer_previews/storefront/review_mailer_preview.rb +10 -0
- data/lib/workarea/reviews.rb +13 -0
- data/lib/workarea/reviews/engine.rb +16 -0
- data/lib/workarea/reviews/version.rb +5 -0
- data/package.json +9 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/config/application.rb +25 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +55 -0
- data/test/dummy/config/environments/production.rb +86 -0
- data/test/dummy/config/environments/test.rb +43 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/new_framework_defaults.rb +21 -0
- data/test/dummy/config/initializers/session_store.rb +5 -0
- data/test/dummy/config/initializers/workarea.rb +5 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/puma.rb +47 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/seeds.rb +2 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/factories/reviews.rb +32 -0
- data/test/fixtures/reviews.csv +5 -0
- data/test/helpers/workarea/storefront/reviews_helper_test.rb +20 -0
- data/test/integration/workarea/admin/reviews_integration_test.rb +37 -0
- data/test/integration/workarea/storefront/review_requests_integration_test.rb +63 -0
- data/test/integration/workarea/storefront/reviews_integration_test.rb +82 -0
- data/test/javascripts/fixtures/product_review_ajax_submit.html.haml +4 -0
- data/test/javascripts/product_review_ajax_submit_spec.js +28 -0
- data/test/javascripts/spec_helper.js +23 -0
- data/test/models/workarea/insights/most_active_reviewers_test.rb +32 -0
- data/test/models/workarea/insights/most_reviewed_products_test.rb +32 -0
- data/test/models/workarea/insights/top_rated_products_test.rb +49 -0
- data/test/models/workarea/review/request_test.rb +18 -0
- data/test/models/workarea/review_test.rb +105 -0
- data/test/models/workarea/search/storefront/product_test.decorator +14 -0
- data/test/queries/workarea/reports/reviews_by_product_test.rb +104 -0
- data/test/queries/workarea/reports/reviews_by_user_test.rb +102 -0
- data/test/queries/workarea/review_request_params_test.rb +64 -0
- data/test/services/workarea/create_review_test.rb +131 -0
- data/test/system/workarea/admin/review_system_test.rb +96 -0
- data/test/system/workarea/admin/reviews_by_product_system_test.rb +60 -0
- data/test/system/workarea/storefront/review_request_system_test.rb +34 -0
- data/test/system/workarea/storefront/review_system_test.rb +113 -0
- data/test/teaspoon_env.rb +10 -0
- data/test/test_helper.rb +11 -0
- data/test/workers/workarea/create_review_requests_test.rb +38 -0
- data/test/workers/workarea/schedule_review_requests_test.rb +115 -0
- data/test/workers/workarea/send_review_requests_test.rb +30 -0
- data/workarea-reviews.gemspec +22 -0
- data/yarn.lock +3265 -0
- metadata +265 -0
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
class CreateReviewTest < TestCase
|
5
|
+
setup :user, :product
|
6
|
+
|
7
|
+
def user
|
8
|
+
@user ||= create_user
|
9
|
+
end
|
10
|
+
|
11
|
+
def product
|
12
|
+
@product ||= create_product
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_for
|
16
|
+
create = CreateReview.for(user: user, product: product)
|
17
|
+
|
18
|
+
assert_equal(user.id.to_s, create.review.user_id)
|
19
|
+
assert_equal(product.id.to_s, create.review.product_id)
|
20
|
+
assert(create.user.present?)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_save
|
24
|
+
create = CreateReview.for(user: user, product: product)
|
25
|
+
refute(create.save)
|
26
|
+
assert(create.errors[:body].present?)
|
27
|
+
assert(create.errors[:rating].present?)
|
28
|
+
|
29
|
+
create = CreateReview.for(
|
30
|
+
user: user,
|
31
|
+
product: product,
|
32
|
+
params: { body: 'foo bar', rating: 3 }
|
33
|
+
)
|
34
|
+
assert(create.save)
|
35
|
+
|
36
|
+
create = CreateReview.for(
|
37
|
+
product: product,
|
38
|
+
params: { body: 'foo bar', rating: 3 }
|
39
|
+
)
|
40
|
+
refute(create.save)
|
41
|
+
assert(create.errors[:first_name].present?)
|
42
|
+
assert(create.errors[:last_name].present?)
|
43
|
+
|
44
|
+
create = CreateReview.for(
|
45
|
+
product: product,
|
46
|
+
params: {
|
47
|
+
body: 'foo bar',
|
48
|
+
rating: 3,
|
49
|
+
first_name: 'Bob',
|
50
|
+
last_name: 'Clams'
|
51
|
+
}
|
52
|
+
)
|
53
|
+
assert(create.save)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_verified?
|
57
|
+
create_order(
|
58
|
+
user_id: user.id,
|
59
|
+
email: user.email,
|
60
|
+
placed_at: Time.now,
|
61
|
+
items: [{ product_id: product.id, sku: product.skus.first, quantity: 1 }]
|
62
|
+
)
|
63
|
+
|
64
|
+
create = CreateReview.for(
|
65
|
+
user: user,
|
66
|
+
product: product,
|
67
|
+
params: { body: 'foobar', rating: 4 }
|
68
|
+
)
|
69
|
+
|
70
|
+
assert(create.verified?)
|
71
|
+
assert(create.save)
|
72
|
+
assert(create.review.verified?)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_canceling_review_requests
|
76
|
+
order = create_order(
|
77
|
+
user_id: user.id,
|
78
|
+
email: user.email,
|
79
|
+
placed_at: Time.now,
|
80
|
+
items: [{ product_id: product.id, sku: product.skus.first, quantity: 1 }]
|
81
|
+
)
|
82
|
+
|
83
|
+
review_request = create_review_request(
|
84
|
+
user_id: user.id,
|
85
|
+
product_id: product.id,
|
86
|
+
order_id: order.id
|
87
|
+
)
|
88
|
+
|
89
|
+
CreateReview.for(user: user, product: product, params: {}).save
|
90
|
+
refute(review_request.reload.canceled?)
|
91
|
+
|
92
|
+
CreateReview.for(
|
93
|
+
user: user,
|
94
|
+
product: product,
|
95
|
+
params: { body: 'foobar', rating: 4 }
|
96
|
+
).save
|
97
|
+
|
98
|
+
assert(review_request.reload.canceled?)
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_title
|
102
|
+
create_with_title = CreateReview.for(
|
103
|
+
product: product,
|
104
|
+
params: {
|
105
|
+
title: 'Baz',
|
106
|
+
body: 'foo bar',
|
107
|
+
rating: 3,
|
108
|
+
first_name: 'Bob',
|
109
|
+
last_name: 'Clams'
|
110
|
+
}
|
111
|
+
)
|
112
|
+
create_without_title = CreateReview.for(
|
113
|
+
product: product,
|
114
|
+
params: {
|
115
|
+
body: 'foo bar',
|
116
|
+
rating: 3,
|
117
|
+
first_name: 'Bob',
|
118
|
+
last_name: 'Clams'
|
119
|
+
}
|
120
|
+
)
|
121
|
+
|
122
|
+
assert(create_with_title.save)
|
123
|
+
assert_equal('Baz', create_with_title.review.title)
|
124
|
+
assert_equal('foo bar', create_with_title.review.body)
|
125
|
+
|
126
|
+
assert(create_without_title.save)
|
127
|
+
assert_equal('foo bar', create_without_title.review.title)
|
128
|
+
assert_equal('foo bar', create_without_title.review.body)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Admin
|
5
|
+
class ReviewSystemTest < SystemTest
|
6
|
+
include Admin::IntegrationTest
|
7
|
+
|
8
|
+
setup :review
|
9
|
+
|
10
|
+
def review
|
11
|
+
@review ||= create_review(
|
12
|
+
product_id: product.id,
|
13
|
+
user_id: user.id,
|
14
|
+
rating: 3,
|
15
|
+
title: 'Integration Review',
|
16
|
+
approved: false
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def user
|
21
|
+
@user ||= create_user
|
22
|
+
end
|
23
|
+
|
24
|
+
def product
|
25
|
+
@product ||= create_product
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_managing_reviews
|
29
|
+
visit admin.reviews_path
|
30
|
+
click_link t('workarea.storefront.reviews.review_for', product: product.name)
|
31
|
+
|
32
|
+
click_button 'save_review'
|
33
|
+
assert(page.has_content?('Success'))
|
34
|
+
|
35
|
+
assert(page.has_current_path?(admin.reviews_path))
|
36
|
+
|
37
|
+
click_link t('workarea.storefront.reviews.review_for', product: product.name)
|
38
|
+
click_link t('workarea.admin.actions.delete')
|
39
|
+
|
40
|
+
assert(page.has_current_path?(admin.reviews_path))
|
41
|
+
refute(page.has_content?('Integration Review'))
|
42
|
+
|
43
|
+
visit admin.activity_path
|
44
|
+
assert(
|
45
|
+
page.has_content?(
|
46
|
+
t('workarea.admin.activities.review_destroy_html', name: 'Integration Review')
|
47
|
+
)
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_sorting_by_rating
|
52
|
+
reviews = Array.new(3) do |i|
|
53
|
+
create_review(
|
54
|
+
rating: 5 - i,
|
55
|
+
product_id: create_product(name: "Test #{i}").id
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
visit admin.reviews_path
|
60
|
+
assert(page.has_ordered_text?('Test 2', 'Test 1', 'Test 0'))
|
61
|
+
|
62
|
+
select 'Highest Rating', from: :sort
|
63
|
+
assert(page.has_ordered_text?('Test 0', 'Test 1', 'Test 2'))
|
64
|
+
|
65
|
+
select 'Lowest Rating', from: :sort
|
66
|
+
assert(page.has_ordered_text?('Test 2', 'Test 1', 'Test 0'))
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_importing_and_exporting
|
70
|
+
reviews = Array.new(2) { |i| create_review(product_id: create_product.id) }
|
71
|
+
file = create_tempfile(DataFile::Csv.new.serialize(reviews), extension: 'csv')
|
72
|
+
|
73
|
+
visit admin.reviews_path
|
74
|
+
click_link t('workarea.admin.shared.bulk_actions.import')
|
75
|
+
attach_file 'import[file]', file.path
|
76
|
+
click_button 'create_import'
|
77
|
+
|
78
|
+
assert_current_path(admin.reviews_path)
|
79
|
+
assert(page.has_content?('Success'))
|
80
|
+
|
81
|
+
click_button t('workarea.admin.shared.bulk_actions.export')
|
82
|
+
|
83
|
+
Workarea.config.data_file_formats[1..-1].each do |format|
|
84
|
+
click_link format.upcase
|
85
|
+
assert(page.has_content?(format.upcase))
|
86
|
+
end
|
87
|
+
|
88
|
+
fill_in 'export[emails_list]', with: 'bcrouse@weblinc.com'
|
89
|
+
click_button 'create_export'
|
90
|
+
|
91
|
+
assert_current_path(admin.reviews_path)
|
92
|
+
assert(page.has_content?('Success'))
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Admin
|
5
|
+
class ReviewsByProductSystemTest < Workarea::SystemTest
|
6
|
+
include Admin::IntegrationTest
|
7
|
+
|
8
|
+
def test_report
|
9
|
+
create_product(id: 'foo', name: 'Foo')
|
10
|
+
|
11
|
+
create_review(product_id: 'foo', rating: 4, approved: false)
|
12
|
+
create_review(product_id: 'foo', rating: 3)
|
13
|
+
create_review(product_id: 'bar', rating: 1, approved: false)
|
14
|
+
create_review(product_id: 'bar', rating: 1, approved: false)
|
15
|
+
create_review(product_id: 'bar', rating: 2)
|
16
|
+
create_review(product_id: 'bar', rating: 2, approved: false)
|
17
|
+
|
18
|
+
visit admin.reviews_by_product_report_path
|
19
|
+
assert(page.has_content?('Foo'))
|
20
|
+
assert(page.has_content?('bar'))
|
21
|
+
assert(page.has_content?('2'))
|
22
|
+
assert(page.has_content?('3.5'))
|
23
|
+
assert(page.has_content?('3.08'))
|
24
|
+
assert(page.has_content?('4'))
|
25
|
+
assert(page.has_content?('1.5'))
|
26
|
+
assert(page.has_content?('2.5'))
|
27
|
+
|
28
|
+
click_link t('workarea.admin.fields.average_rating')
|
29
|
+
assert(page.has_content?("#{t('workarea.admin.fields.average_rating')} ↓"))
|
30
|
+
assert(page.has_ordered_text?('Foo', 'bar'))
|
31
|
+
|
32
|
+
click_link t('workarea.admin.fields.reviews')
|
33
|
+
assert(page.has_content?("#{t('workarea.admin.fields.reviews')} ↓"))
|
34
|
+
assert(page.has_ordered_text?('bar', 'Foo'))
|
35
|
+
|
36
|
+
click_link t('workarea.admin.fields.reviews')
|
37
|
+
assert(page.has_content?("#{t('workarea.admin.fields.reviews')} ↑"))
|
38
|
+
assert(page.has_ordered_text?('Foo', 'bar'))
|
39
|
+
|
40
|
+
select t('workarea.admin.reports.reviews_by_product.filters.unapproved'), from: :results_filter
|
41
|
+
|
42
|
+
assert(page.has_content?('Foo'))
|
43
|
+
assert(page.has_content?('1'))
|
44
|
+
assert(page.has_content?('4'))
|
45
|
+
assert(page.has_content?('bar'))
|
46
|
+
assert(page.has_content?('3'))
|
47
|
+
assert(page.has_content?('1.33'))
|
48
|
+
|
49
|
+
select t('workarea.admin.reports.reviews_by_product.filters.approved'), from: :results_filter
|
50
|
+
|
51
|
+
assert(page.has_content?('Foo'))
|
52
|
+
assert(page.has_content?('1'))
|
53
|
+
assert(page.has_content?('3'))
|
54
|
+
assert(page.has_content?('bar'))
|
55
|
+
assert(page.has_content?('1'))
|
56
|
+
assert(page.has_content?('2'))
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Storefront
|
5
|
+
class ReviewRequestSystemTest < Workarea::SystemTest
|
6
|
+
def test_completing_a_review_request
|
7
|
+
order = create_placed_order
|
8
|
+
product = create_product
|
9
|
+
user = create_user(first_name: 'Bob', last_name: 'Clams')
|
10
|
+
|
11
|
+
review_request = create_review_request(
|
12
|
+
product_id: product.id,
|
13
|
+
order_id: order.id,
|
14
|
+
email: order.email,
|
15
|
+
user_id: user.id
|
16
|
+
)
|
17
|
+
|
18
|
+
visit storefront.review_request_path(review_request.token)
|
19
|
+
|
20
|
+
assert(page.has_content?(product.name))
|
21
|
+
|
22
|
+
within '#review_request_form' do
|
23
|
+
execute_script("$('#review_rating_4').trigger('click')")
|
24
|
+
fill_in 'review[title]', with: 'Pretty decent product'
|
25
|
+
fill_in 'review[body]', with: 'It works well.'
|
26
|
+
click_button 'submit_review'
|
27
|
+
end
|
28
|
+
|
29
|
+
assert_current_path(storefront.product_path(product))
|
30
|
+
assert(page.has_content?('Success'))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Storefront
|
5
|
+
class ReviewSystemTest < Workarea::SystemTest
|
6
|
+
def product
|
7
|
+
@product ||= create_product(name: 'Test')
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_showing_reviews_on_browse_page
|
11
|
+
create_review(product_id: product.id, rating: 4)
|
12
|
+
category = create_category(product_ids: [product.id])
|
13
|
+
|
14
|
+
visit storefront.category_path(category)
|
15
|
+
assert_includes(page.html, '4.0 out of 5 stars')
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_showing_reviews_on_search_results
|
19
|
+
create_product(name: 'Another Test')
|
20
|
+
create_review(product_id: product.id, rating: 4)
|
21
|
+
|
22
|
+
visit storefront.search_path(q: 'test')
|
23
|
+
assert_includes(page.html, '4.0 out of 5 stars')
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_showing_reviews_on_a_product_detail_page
|
27
|
+
create_review(product_id: product.id, rating: 3)
|
28
|
+
create_review(
|
29
|
+
product_id: product.id,
|
30
|
+
rating: 3,
|
31
|
+
title: 'Integration Review First'
|
32
|
+
)
|
33
|
+
create_review(
|
34
|
+
product_id: product.id,
|
35
|
+
rating: 3,
|
36
|
+
title: 'Integration Review Second'
|
37
|
+
)
|
38
|
+
|
39
|
+
visit storefront.product_path(product)
|
40
|
+
|
41
|
+
assert_includes(page.html, '3.0')
|
42
|
+
assert(page.has_content?('(3)'))
|
43
|
+
assert(
|
44
|
+
page.has_ordered_text?(
|
45
|
+
'Integration Review Second',
|
46
|
+
'Integration Review First'
|
47
|
+
)
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_showing_review_from_verified_purchaser
|
52
|
+
create_review(
|
53
|
+
product_id: product.id,
|
54
|
+
rating: 3,
|
55
|
+
title: 'Integration Review',
|
56
|
+
verified: true
|
57
|
+
)
|
58
|
+
|
59
|
+
visit storefront.product_path(product)
|
60
|
+
assert(page.has_content?('Integration Review'))
|
61
|
+
assert(page.has_content?(t('workarea.storefront.reviews.verified_purchaser')))
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_writing_a_product_review
|
65
|
+
create_user(
|
66
|
+
email: 'test@workarea.com',
|
67
|
+
password: 'w3bl1nc',
|
68
|
+
name: 'Ben Crouse'
|
69
|
+
)
|
70
|
+
|
71
|
+
visit storefront.login_path
|
72
|
+
|
73
|
+
within '#login_form' do
|
74
|
+
fill_in 'email', with: 'test@workarea.com'
|
75
|
+
fill_in 'password', with: 'w3bl1nc'
|
76
|
+
click_button 'login'
|
77
|
+
end
|
78
|
+
|
79
|
+
visit storefront.product_path(product)
|
80
|
+
click_link 'Write a Review'
|
81
|
+
|
82
|
+
within '#review_form' do
|
83
|
+
# svg blocks input
|
84
|
+
execute_script("$('#review_rating_4').trigger('click')")
|
85
|
+
fill_in 'review[title]', with: 'Pretty decent product'
|
86
|
+
fill_in 'review[body]', with: 'It works well.'
|
87
|
+
click_button 'submit_review'
|
88
|
+
end
|
89
|
+
|
90
|
+
assert(page.has_content?('Success'))
|
91
|
+
assert_no_selector('#review_form')
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_writing_a_product_review_as_a_guest
|
95
|
+
visit storefront.product_path(product)
|
96
|
+
click_link 'Write a Review'
|
97
|
+
|
98
|
+
within '#review_form' do
|
99
|
+
# svg blocks input
|
100
|
+
execute_script("$('#review_rating_4').trigger('click')")
|
101
|
+
fill_in 'review[title]', with: 'Pretty decent product'
|
102
|
+
fill_in 'review[body]', with: 'It works well.'
|
103
|
+
fill_in 'review[first_name]', with: 'Ben'
|
104
|
+
fill_in 'review[last_name]', with: 'Crouse'
|
105
|
+
click_button 'submit_review'
|
106
|
+
end
|
107
|
+
|
108
|
+
assert(page.has_content?('Success'))
|
109
|
+
assert_no_selector('#review_form')
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|