DEV: Fix incorrect test.

DEV: Fix incorrect test.

diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb
index de5c367..84418a6 100644
--- a/spec/models/post_spec.rb
+++ b/spec/models/post_spec.rb
@@ -139,6 +139,7 @@ describe Post do
         post = Fabricate(:post, post_args)
         post.custom_fields["post_notice_type"] = "returning"
         post.custom_fields["post_notice_time"] = 1.day.ago
+        post.save_custom_fields
         post
       }
 
@@ -149,10 +150,8 @@ describe Post do
 
       describe 'recovery' do
         it 'deletes notices' do
-          post.recover!
-
-          expect(post.custom_fields).not_to have_key("post_notice_type")
-          expect(post.custom_fields).not_to have_key("post_notice_time")
+          expect { post.recover! }
+            .to change { post.custom_fields.length }.from(2).to(0)
         end
       end
     end

GitHub sha: 83840751

@udan11 Note that custom fields need to be saved in order to be persisted in the database.

1 Like