fix spec (#10061)

fix spec (#10061)

diff --git a/spec/serializers/topic_view_serializer_spec.rb b/spec/serializers/topic_view_serializer_spec.rb
index f6249b2..55a9652 100644
--- a/spec/serializers/topic_view_serializer_spec.rb
+++ b/spec/serializers/topic_view_serializer_spec.rb
@@ -312,22 +312,36 @@ describe TopicViewSerializer do
   context "published_page" do
     fab!(:published_page) { Fabricate(:published_page, topic: topic) }
 
-    it "doesn't return the published page if not enabled" do
-      json = serialize_topic(topic, admin)
-      expect(json[:published_page]).to be_blank
-    end
+    context "page publishing is disabled" do
+      before do
+        SiteSetting.enable_page_publishing = false
+      end
 
-    it "doesn't return the published page unless staff" do
-      SiteSetting.enable_page_publishing = true
-      json = serialize_topic(topic, user)
-      expect(json[:published_page]).to be_blank
+      it "doesn't return the published page if not enabled" do
+        json = serialize_topic(topic, admin)
+        expect(json[:published_page]).to be_blank
+      end
     end
 
-    it "returns the published page if enabled and staff" do
-      SiteSetting.enable_page_publishing = true
-      json = serialize_topic(topic, admin)
-      expect(json[:published_page]).to be_present
-      expect(json[:published_page][:slug]).to eq("published-page-test")
+    context "page publishing is enabled" do
+      before do
+        SiteSetting.enable_page_publishing = true
+      end
+
+      context "not staff" do
+        it "doesn't return the published page" do
+          json = serialize_topic(topic, user)
+          expect(json[:published_page]).to be_blank
+        end
+      end
+
+      context "staff" do
+        it "returns the published page" do
+          json = serialize_topic(topic, admin)
+          expect(json[:published_page]).to be_present
+          expect(json[:published_page][:slug]).to eq(published_page.slug)
+        end
+      end
     end
   end
 

GitHub sha: 9518d6b5

This commit appears in #10061 which was merged by jjaffeux.