Verified Commit 3e486f78 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3441920 by scott_euser, catch, smustgrave, quietone: Support #attached...

Issue #3441920 by scott_euser, catch, smustgrave, quietone: Support #attached settings in ViewAjaxController
parent 91e32596
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -214,6 +214,10 @@ public function ajaxView(Request $request) {
        $response->addCommand(new PrependCommand(".js-view-dom-id-$dom_id", ['#type' => 'status_messages']));
        $request->query->set('ajax_page_state', $existing_page_state);

        if (!empty($preview['#attached'])) {
          $response->setAttachments($preview['#attached']);
        }

        return $response;
      }
      else {
+16 −1
Original line number Diff line number Diff line
@@ -209,6 +209,14 @@ public function testAjaxView() {
    $this->assertSame($response->getView(), $executable);

    $this->assertViewResultCommand($response);

    // Test that the ajax controller for Views contains the
    // Drupal Settings.
    $this->assertEquals([
      'drupalSettings' => [
        'testSetting' => ['Setting'],
      ],
    ], $response->getAttachments());
  }

  /**
@@ -389,7 +397,14 @@ protected function setupValidMocks($use_ajax = self::USE_AJAX) {
      ->willReturn(TRUE);
    $executable->expects($this->atMost(1))
      ->method('preview')
      ->willReturn(['#markup' => 'View result']);
      ->willReturn([
        '#markup' => 'View result',
        '#attached' => [
          'drupalSettings' => [
            'testSetting' => ['Setting'],
          ],
        ],
      ]);

    $this->executableFactory->expects($this->once())
      ->method('get')