Sha256: 9fbfd8b6e533a5c879b83cabffef6dc3f3437cdf41a1f6be322b0446fcef4a38

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'

class CmsSnippetTest < ActiveSupport::TestCase
  
  def test_fixtures_validity
    CmsSnippet.all.each do |snippet|
      assert snippet.valid?, snippet.errors.full_messages
    end
  end
  
  def test_validations
    snippet = CmsSnippet.new
    snippet.save
    assert snippet.invalid?
    assert_has_errors_on snippet, [:label, :slug]
  end
  
  def test_method_content
    assert_equal cms_snippets(:default).content, CmsSnippet.content_for('default')
    assert_equal '', CmsSnippet.content_for('nonexistent_snippet')
  end
  
  def test_load_from_file
    assert !CmsSnippet.load_from_file(cms_sites(:default), 'default')
    
    ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__))
    
    assert !CmsSnippet.load_from_file(cms_sites(:default), 'bogus')
    
    assert snippet = CmsSnippet.load_from_file(cms_sites(:default), 'default')
    assert_equal 'Default Snippet', snippet.label
    assert_equal 'Content for Default Snippet', snippet.content
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.0.9 test/unit/cms_snippet_test.rb
comfortable_mexican_sofa-1.0.7 test/unit/cms_snippet_test.rb
comfortable_mexican_sofa-1.0.6 test/unit/cms_snippet_test.rb
comfortable_mexican_sofa-1.0.5 test/unit/cms_snippet_test.rb
comfortable_mexican_sofa-1.0.4 test/unit/cms_snippet_test.rb
comfortable_mexican_sofa-1.0.3 test/unit/cms_snippet_test.rb