Revert "REFACTOR: remove unnecessary parentheses attempt 2 (follow-up on 154f503d)"

Revert “REFACTOR: remove unnecessary parentheses attempt 2 (follow-up on 154f503d)”

This reverts commit 7db2dc717e672e831657183b3b069307aaa2a842.

Commit breaks post edits for regular users.

diff --git a/app/models/post.rb b/app/models/post.rb
index 0441bcb..8e03538 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -215,7 +215,8 @@ class Post < ActiveRecord::Base
   end
 
   def matches_recent_post?
-    $redis.get(unique_post_key)&.to_i != id
+    post_id = $redis.get(unique_post_key)
+    post_id != (nil) && post_id.to_i != (id)
   end
 
   def raw_hash

GitHub sha: d2a7f295

2 Likes

DEV: Improve specs for validating a unique post.

Really?! Why didn’t any tests break then?

Because of stubs :stuck_out_tongue: Plus we didn’t really have a test for editing an existing post.

2 Likes

At last more people are on my anti stub :oncoming_automobile: :stuck_out_tongue_winking_eye:

1 Like