Sha256: e20e3a2878cc0db65765e98660c111cc0e30e30cd67ceba134fe6a96a6199f19

Contents?: true

Size: 1.82 KB

Versions: 21

Compression:

Stored size: 1.82 KB

Contents

require File.expand_path('../../test_helper', File.dirname(__FILE__))

class PartialTest < ActiveSupport::TestCase
  
  def test_initialize_tag
    [
      '{{ cms:partial:partial_name }}',
      '{{cms:partial:path/to/partial}}'
    ].each do |tag_signature|
      assert tag = CmsTag::Partial.initialize_tag(cms_pages(:default), tag_signature)
    end
  end
  
  def test_initialize_tag_with_parameters
    assert tag = CmsTag::Partial.initialize_tag(cms_pages(:default), '{{cms:partial:path/to/partial:param1:param2}}')
    assert tag.label = 'path/to/partial'
    assert tag.params = 'param1:param2'
  end
  
  def test_initialize_tag_failure
    [
      '{{cms:partial}}',
      '{{cms:not_partial:label}}',
      '{not_a_tag}'
    ].each do |tag_signature|
      assert_nil CmsTag::Partial.initialize_tag(cms_pages(:default), tag_signature)
    end
  end
  
  def test_content_and_render
    tag = CmsTag::Partial.initialize_tag(cms_pages(:default), '{{cms:partial:path/to/partial}}')
    assert_equal "<%= render :partial => 'path/to/partial' %>", tag.content
    assert_equal "<%= render :partial => 'path/to/partial' %>", tag.render
    
    tag = CmsTag::Partial.initialize_tag(cms_pages(:default), '{{cms:partial:path/to/partial:param1}}')
    assert_equal "<%= render :partial => 'path/to/partial', :locals => {:param_1 => 'param1'} %>", tag.content
    assert_equal "<%= render :partial => 'path/to/partial', :locals => {:param_1 => 'param1'} %>", tag.render
    
    tag = CmsTag::Partial.initialize_tag(cms_pages(:default), '{{cms:partial:path/to/partial:param1:param2}}')
    assert_equal "<%= render :partial => 'path/to/partial', :locals => {:param_1 => 'param1', :param_2 => 'param2'} %>", tag.content
    assert_equal "<%= render :partial => 'path/to/partial', :locals => {:param_1 => 'param1', :param_2 => 'param2'} %>", tag.render
  end
  
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.0.32 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.31 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.30 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.29 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.28 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.27 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.26 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.25 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.24 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.23 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.22 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.21 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.20 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.19 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.18 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.17 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.16 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.15 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.14 test/unit/cms_tags/partial_test.rb
comfortable_mexican_sofa-1.0.13 test/unit/cms_tags/partial_test.rb