Sha256: 5714f7f870401b4b64349bc2dcd817d3561c0651a39afa24226b1de6e13242a7

Contents?: true

Size: 1.48 KB

Versions: 32

Compression:

Stored size: 1.48 KB

Contents

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

class ViewMethodsTest < ActionView::TestCase
  
  class ::HelpersTestController < ActionController::Base
    helper { def hello; 'hello' end }
    def test_cms_snippet_content
      render :inline => '<%= cms_snippet_content(:default) %>'
    end
    def test_cms_page_content
      @cms_page = Cms::Page.root
      render :inline => '<%= cms_page_content(:default_field_text) %>'
    end
  end
  
  # Simulating a call and getting resulting output
  def action_result(action)
    HelpersTestController.action(action).call(ActionController::TestRequest.new.env).last.body
  end
  
  def test_cms_snippet_content
    assert_equal 'default_snippet_content', action_result('test_cms_snippet_content')
  end
  
  def test_cms_snippet_content_with_tags
    cms_snippets(:default).update_attribute(:content, '{{cms:helper:hello}}')
    assert_equal 'hello', action_result('test_cms_snippet_content')
  end
  
  def test_cms_snippet_content_with_file_tag
    cms_snippets(:default).update_attribute(:content, '{{cms:file:sample.jpg}}')
    assert_equal cms_files(:default).file.url, action_result('test_cms_snippet_content')
  end
  
  def test_cms_page_content
    assert_equal 'default_field_text_content', action_result('test_cms_page_content')
  end
  
  def test_cms_page_content_with_tags
    cms_blocks(:default_field_text).update_attribute(:content, '{{cms:helper:hello}}')
    assert_equal 'hello', action_result('test_cms_page_content')
  end
  
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.6.23 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.22 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.21 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.20 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.19 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.18 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.17 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.16 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.15 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.14 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.13 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.12 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.11 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.10 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.9 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.8 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.7 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.6 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.5 test/unit/view_methods_test.rb
comfortable_mexican_sofa-1.6.4 test/unit/view_methods_test.rb