From 982ca4b5904d4d2d4253428e1c2e33f2ad90c40a Mon Sep 17 00:00:00 2001
From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org>
Date: Fri, 3 Jan 2014 17:44:11 +0000
Subject: [PATCH] Issue #2154005 by olli: Views UI does not render preview for
 feeds.

---
 .../Drupal/views/Plugin/views/display/Feed.php    | 11 +++++++++--
 .../lib/Drupal/views_ui/Tests/PreviewTest.php     | 15 +++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php
index 7915204e8ad3..ddcc1fab1dca 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views\Plugin\views\display;
 
+use Drupal\Component\Utility\String;
 use Drupal\views\ViewExecutable;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -86,11 +87,17 @@ public function execute() {
    * Overrides \Drupal\views\Plugin\views\display\PathPluginBase::preview().
    */
   public function preview() {
+    $output = $this->view->render();
+
     if (!empty($this->view->live_preview)) {
-      return '<pre>' . check_plain($this->view->render()) . '</pre>';
+      $output = array(
+        '#prefix' => '<pre>',
+        '#markup' => String::checkPlain($output),
+        '#suffix' => '</pre>',
+      );
     }
 
-    return $this->view->render();
+    return $output;
   }
 
   /**
diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php
index 7f134134c0c1..77cc434638f1 100644
--- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php
+++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php
@@ -77,6 +77,21 @@ function testPreviewUI() {
     $this->assertText('Test header text', 'Rendered header text found');
     $this->assertText('Test footer text', 'Rendered footer text found.');
     $this->assertText('Test empty text', 'Rendered empty text found.');
+
+    // Test feed preview.
+    $view = array();
+    $view['label'] = $this->randomName(16);
+    $view['id'] = strtolower($this->randomName(16));
+    $view['page[create]'] = 1;
+    $view['page[title]'] = $this->randomName(16);
+    $view['page[path]'] = $this->randomName(16);
+    $view['page[feed]'] = 1;
+    $view['page[feed_properties][path]'] = $this->randomName(16);
+    $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
+    $this->clickLink(t('Feed'));
+    $this->drupalPostForm(NULL, array(), t('Update preview'));
+    $result = $this->xpath('//div[@id="views-live-preview"]/pre');
+    $this->assertTrue(strpos($result[0], '<title>' . $view['page[title]'] . '</title>'), 'The Feed RSS preview was rendered.');
   }
 
   /**
-- 
GitLab