Sha256: 6e2a7be9ae95fb28a4c4999d557e94930c6aaaa4ff11e4b0fb7cdf1a5b76b82c

Contents?: true

Size: 1.64 KB

Versions: 7

Compression:

Stored size: 1.64 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 %r{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 %r{hook_content}, response.body
    assert_match %r{<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 %r{<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 %r{hook_content}, response.body
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-2.0.9 test/integration/view_hooks_test.rb
comfortable_mexican_sofa-2.0.8 test/integration/view_hooks_test.rb
comfortable_mexican_sofa-2.0.7 test/integration/view_hooks_test.rb
comfortable_mexican_sofa-2.0.6 test/integration/view_hooks_test.rb
comfortable_mexican_sofa-2.0.5 test/integration/view_hooks_test.rb
comfortable_mexican_sofa-2.0.4 test/integration/view_hooks_test.rb
comfortable_mexican_sofa-2.0.3 test/integration/view_hooks_test.rb