workarea-reviews 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b0b2d9372daaeb9ee3c57719b48614dd6d7669fb4565ef41c27b42d6fe62be8
4
- data.tar.gz: 8c96afdcc3148cd43dc0abff152e827eda68884338a0d6b6c825ef01dca2e579
3
+ metadata.gz: a07fba40d273a1fd46dfa4575601eefe0eb742fafe6da2be58c2ca07fba3b51f
4
+ data.tar.gz: 9a5f40859ec940937ac073bfc976ea1e899d05864f3cdf2e2b261b25a2963410
5
5
  SHA512:
6
- metadata.gz: 19b6581073824b8c0c095c82a5e9c00cc24245ce3835e3cf182bcbf7ed862ad67c4bd152dc290fb6c7c79a37c2bf0cb4056198dee55d5cdb06c143ab0d467e56
7
- data.tar.gz: 4c6513727fe2685630ab37f9468de14c267a7d3695b955e6188835920874d053e2e17c184d06810ca443d12a9a6919d129dfa6b872884bfa01beb165bdee4f7d
6
+ metadata.gz: 49005ddc4805c46ff4bcb725a1c6b30d53f616b912880c6c64404c57334e31281824ea1fe3109204981fbec7db255bc327be890d2fd536ef17a9a80e42e9efb6
7
+ data.tar.gz: 27fc7ae007ceb0b676576a8a93e270869aa8c362d76054e15faa0863911be3872eed903604132d15382fdd52cdc5f251f21ed514b6a515a4b93c24187d2290ee
@@ -1,3 +1,14 @@
1
+ Workarea Reviews 3.1.2 (2020-10-30)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Handle reviews with user_ids that do not match a user
5
+
6
+ REVIEWS-6
7
+
8
+ Matt Duffy
9
+
10
+
11
+
1
12
  Workarea Reviews 3.1.1 (2020-01-07)
2
13
  --------------------------------------------------------------------------------
3
14
 
@@ -2,12 +2,18 @@ module Workarea
2
2
  module Storefront
3
3
  class ReviewViewModel < ApplicationViewModel
4
4
  def requires_public_info?
5
- anonymous? || user.public_info.blank?
5
+ anonymous? || user&.public_info.blank?
6
+ end
7
+
8
+ def anonymous?
9
+ model.anonymous? || user.nil?
6
10
  end
7
11
 
8
12
  def user
9
- return if anonymous?
10
- @user ||= User.find(user_id)
13
+ return if model.anonymous?
14
+ return @user if defined?(@user)
15
+
16
+ @user = User.find(user_id) rescue nil
11
17
  end
12
18
  end
13
19
  end
@@ -1,5 +1,5 @@
1
1
  module Workarea
2
2
  module Reviews
3
- VERSION = '3.1.1'.freeze
3
+ VERSION = '3.1.2'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,46 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Storefront
5
+ class ReviewViewModelTest < TestCase
6
+ def test_requires_public_info?
7
+ review = Review.new
8
+ assert(ReviewViewModel.wrap(review).requires_public_info?)
9
+
10
+ user = create_user(first_name: nil, last_name: nil)
11
+ review.user_id = user.id
12
+ assert(ReviewViewModel.wrap(review).requires_public_info?)
13
+
14
+ user.update!(first_name: 'Bob', last_name: 'Clams')
15
+ refute(ReviewViewModel.wrap(review).requires_public_info?)
16
+
17
+ user.destroy!
18
+ assert(ReviewViewModel.wrap(review).requires_public_info?)
19
+ end
20
+
21
+ def test_anonymous?
22
+ review = Review.new
23
+ assert(ReviewViewModel.wrap(review).anonymous?)
24
+
25
+ user = create_user
26
+ review.user_id = user.id
27
+ refute(ReviewViewModel.wrap(review).anonymous?)
28
+
29
+ user.destroy!
30
+ assert(ReviewViewModel.wrap(review).anonymous?)
31
+ end
32
+
33
+ def test_user
34
+ review = Review.new
35
+ assert_nil(ReviewViewModel.wrap(review).user)
36
+
37
+ user = create_user
38
+ review.user_id = user.id
39
+ assert_equal(user, ReviewViewModel.wrap(review).user)
40
+
41
+ user.destroy!
42
+ assert_nil(ReviewViewModel.wrap(review).user)
43
+ end
44
+ end
45
+ end
46
+ end
data/yarn.lock CHANGED
@@ -184,9 +184,9 @@ acorn-jsx@^5.0.0:
184
184
  integrity sha512-tiNTrP1MP0QrChmD2DdupCr6HWSFeKVw5d/dHTu4Y7rkAkRhU/Dt7dphAfIUyxtHpl/eBVip5uTNSpQJHylpAw==
185
185
 
186
186
  acorn@^6.0.7:
187
- version "6.3.0"
188
- resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.3.0.tgz#0087509119ffa4fc0a0041d1e93a417e68cb856e"
189
- integrity sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==
187
+ version "6.4.1"
188
+ resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.1.tgz#531e58ba3f51b9dacb9a6646ca4debf5b14ca474"
189
+ integrity sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==
190
190
 
191
191
  ajv@^6.10.2, ajv@^6.9.1:
192
192
  version "6.10.2"
@@ -1773,9 +1773,9 @@ locate-path@^2.0.0:
1773
1773
  path-exists "^3.0.0"
1774
1774
 
1775
1775
  lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15:
1776
- version "4.17.15"
1777
- resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
1778
- integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
1776
+ version "4.17.19"
1777
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
1778
+ integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
1779
1779
 
1780
1780
  log-symbols@^2.2.0:
1781
1781
  version "2.2.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workarea-reviews
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Crouse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-08 00:00:00.000000000 Z
11
+ date: 2020-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: workarea
@@ -234,6 +234,7 @@ files:
234
234
  - test/system/workarea/storefront/review_system_test.rb
235
235
  - test/teaspoon_env.rb
236
236
  - test/test_helper.rb
237
+ - test/view_models/workarea/storefront/review_view_model_test.rb
237
238
  - test/workers/workarea/create_review_requests_test.rb
238
239
  - test/workers/workarea/schedule_review_requests_test.rb
239
240
  - test/workers/workarea/send_review_requests_test.rb
@@ -258,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
259
  - !ruby/object:Gem::Version
259
260
  version: '0'
260
261
  requirements: []
261
- rubygems_version: 3.0.6
262
+ rubygems_version: 3.0.3
262
263
  signing_key:
263
264
  specification_version: 4
264
265
  summary: Reviews plugin for the Workarea ecommerce platform