DEV: Test with :private_message_topic.

DEV: Test with :private_message_topic.
From 02689b07cea24e55e35c474d60647875da17e90f Mon Sep 17 00:00:00 2001
From: Dan Ungureanu <dan@ungureanu.me>
Date: Wed, 5 Dec 2018 10:55:39 +0200
Subject: [PATCH] DEV: Test with :private_message_topic.


diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb
index a1fa4f2..a2d512b 100644
--- a/spec/models/post_spec.rb
+++ b/spec/models/post_spec.rb
@@ -4,10 +4,10 @@ describe Post do
 
   let(:user) { Fabricate(:user) }
 
-  let(:topic) { Fabricate(:topic) }
+  let(:topic) { Fabricate(:private_message_topic, topic_allowed_users: [ Fabricate.build(:topic_allowed_user, user: user) ]) }
   let(:post) { Fabricate(:post, topic: topic, user: user) }
 
-  let(:topic2) { Fabricate(:topic) }
+  let(:topic2) { Fabricate(:private_message_topic, topic_allowed_users: [ Fabricate.build(:topic_allowed_user, user: user) ]) }
   let(:post2) { Fabricate(:post, topic: topic2, user: user) }
 
   before do
diff --git a/spec/requests/encrypt_controller_spec.rb b/spec/requests/encrypt_controller_spec.rb
index 2449663..d7de995 100644
--- a/spec/requests/encrypt_controller_spec.rb
+++ b/spec/requests/encrypt_controller_spec.rb
@@ -8,7 +8,16 @@ describe ::DiscourseEncrypt::EncryptController do
   let(:user2) { Fabricate(:user, username: 'user2') }
   let(:other_user) { Fabricate(:user, username: 'other') }
 
-  let(:topic) { Fabricate(:topic) }
+  let(:topic) {
+    Fabricate(
+      :private_message_topic,
+      topic_allowed_users: [
+        Fabricate.build(:topic_allowed_user, user: user),
+        Fabricate.build(:topic_allowed_user, user: user2)
+      ]
+    )
+  }
+
   let(:other_topic) { Fabricate(:topic) }
 
   before do
diff --git a/spec/serializers/topic_serializers_spec.rb b/spec/serializers/topic_serializers_spec.rb
index 28f43e7..dc99dc7 100644
--- a/spec/serializers/topic_serializers_spec.rb
+++ b/spec/serializers/topic_serializers_spec.rb
@@ -8,8 +8,8 @@ require 'rails_helper'
 
     let(:user) { Fabricate(:user) }
 
-    let(:topic) { Fabricate(:topic) }
-    let(:unencrypted_topic) { Fabricate(:topic) }
+  let(:topic) { Fabricate(:private_message_topic, topic_allowed_users: [ Fabricate.build(:topic_allowed_user, user: user) ]) }
+  let(:unencrypted_topic) { Fabricate(:private_message_topic, topic_allowed_users: [ Fabricate.build(:topic_allowed_user, user: user) ]) }
 
     before do
       topic.custom_fields['encrypted_title'] = '-- the encrypted title --'
diff --git a/spec/serializers/topic_view_serializer_spec.rb b/spec/serializers/topic_view_serializer_spec.rb
index 5da0fef..b986d60 100644
--- a/spec/serializers/topic_view_serializer_spec.rb
+++ b/spec/serializers/topic_view_serializer_spec.rb
@@ -6,10 +6,10 @@ describe TopicViewSerializer do
 
   let(:user) { Fabricate(:user) }
 
-  let(:topic) { Fabricate(:topic) }
+  let(:topic) { Fabricate(:private_message_topic, topic_allowed_users: [ Fabricate.build(:topic_allowed_user, user: user) ]) }
   let(:topic_view) { TopicView.new(topic.id, user) }
 
-  let(:unencrypted_topic) { Fabricate(:topic) }
+  let(:unencrypted_topic) { Fabricate(:private_message_topic, topic_allowed_users: [ Fabricate.build(:topic_allowed_user, user: user) ]) }
   let(:unencrypted_topic_view) { TopicView.new(unencrypted_topic.id, user) }
 
   before do

GitHub

2 Likes