Sha256: 57ab5298d3eb97b3880e844d43bb6c244418f4f93fbfc879c3de11b433a066dd

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

require_relative '../test_helper'

class ViewHooksIntegrationTest < ActionDispatch::IntegrationTest

  def teardown
    ComfortableMexicanSofa::ViewHooks.remove(:navigation)
  end

  def test_hooks_rendering
    Comfy::Admin::Cms::SitesController.append_view_path(File.expand_path('../fixtures/views', File.dirname(__FILE__)))
    ComfortableMexicanSofa::ViewHooks.add(:navigation, '/nav_hook')

    r :get, comfy_admin_cms_sites_path
    assert_response :success
    assert_match /hook_content/, response.body
  end

  def test_hooks_rendering_with_multiples
    Comfy::Admin::Cms::SitesController.append_view_path(File.expand_path('../fixtures/views', File.dirname(__FILE__)))
    ComfortableMexicanSofa::ViewHooks.add(:navigation, '/nav_hook')
    ComfortableMexicanSofa::ViewHooks.add(:navigation, '/nav_hook_2')

    r :get, comfy_admin_cms_sites_path
    assert_response :success
    assert_match /hook_content/, response.body
    assert_match /<hook_content_2>/, response.body
  end

  def test_hooks_rendering_with_proper_order
    Comfy::Admin::Cms::SitesController.append_view_path(File.expand_path('../fixtures/views', File.dirname(__FILE__)))
    ComfortableMexicanSofa::ViewHooks.add(:navigation, '/nav_hook_2', 0)
    ComfortableMexicanSofa::ViewHooks.add(:navigation, '/nav_hook', 1)

    r :get, comfy_admin_cms_sites_path
    assert_response :success
    assert_match /<hook_content_2>hook_content/, response.body
  end

  def test_hooks_rendering_with_no_hook
    ComfortableMexicanSofa::ViewHooks.remove(:navigation)

    r :get, comfy_admin_cms_sites_path
    assert_response :success
    assert_no_match /hook_content/, response.body
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-2.0.2 test/integration/view_hooks_test.rb
comfortable_mexican_sofa-2.0.1 test/integration/view_hooks_test.rb
comfortable_mexican_sofa-2.0.0 test/integration/view_hooks_test.rb