Sha256: c28445c6b290e10a4ee309e38eaeae33af364b651d2ddb99e2a266b9f225f0ef

Contents?: true

Size: 1.55 KB

Versions: 7

Compression:

Stored size: 1.55 KB

Contents

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

describe PagePart do
  dataset :home_page
  
  test_helper :validations
  
  before do
    @original_filter = Radiant::Config['defaults.page.filter']
    @part = @model = PagePart.new(page_part_params)
  end

  after do
    Radiant::Config['defaults.page.filter'] = @original_filter
  end
  
  it "should take the filter from the default filter" do
    Radiant::Config['defaults.page.filter'] = "Textile"
    part = PagePart.new :name => 'new-part'
    part.filter_id.should == "Textile"
  end

  it "shouldn't override existing page_parts filters with the default filter" do
    part = PagePart.find(:first, :conditions => {:filter_id => nil})
    Radiant::Config['defaults.page.filter'] = "Textile"
    part.reload
    part.filter_id.should_not == "Textile"
  end
  
  it 'should validate length of' do
    {
      :name => 100,
      :filter_id => 25
    }.each do |field, max|
      assert_invalid field, ('this must not be longer than %d characters' % max), 'x' * (max + 1)
      assert_valid field, 'x' * max
    end
  end
  
  it 'should validate presence of' do
    [:name].each do |field|
      assert_invalid field, 'this must not be blank', '', ' ', nil
    end
  end
end

describe PagePart, 'filter' do
  dataset :markup_pages
  
  specify 'getting and setting' do
    @part = page_parts(:textile_body)
    original = @part.filter
    original.should be_kind_of(TextileFilter)
    
    @part.filter.should equal(original)
    
    @part.filter_id = 'Markdown'
    @part.filter.should be_kind_of(MarkdownFilter)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
radiant-1.0.1 spec/models/page_part_spec.rb
radiant-1.0.0 spec/models/page_part_spec.rb
radiant-1.0.0.rc5 spec/models/page_part_spec.rb
radiant-1.0.0.rc4 spec/models/page_part_spec.rb
radiant-1.0.0.rc3 spec/models/page_part_spec.rb
radiant-1.0.0.rc2 spec/models/page_part_spec.rb
radiant-1.0.0.rc1 spec/models/page_part_spec.rb