Sha256: 276454ae7aa03cec640ce5f9732f55d6ef78f970da179703de99b5255ac5931b

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

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

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

5 entries across 5 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.0.14 test/unit/cms_snippet_test.rb
comfortable_mexican_sofa-1.0.13 test/unit/cms_snippet_test.rb
comfortable_mexican_sofa-1.0.12 test/unit/cms_snippet_test.rb
comfortable_mexican_sofa-1.0.11 test/unit/cms_snippet_test.rb
comfortable_mexican_sofa-1.0.10 test/unit/cms_snippet_test.rb