Sha256: 6a8162f858b548829b60c341450f3db2531b43a983e868bc4fc5a6ecadf8ad0d

Contents?: true

Size: 1.58 KB

Versions: 17

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'
 
describe ContentType do
  
  before(:each) do
    Site.any_instance.stubs(:create_default_pages!).returns(true)
  end
  
  context 'when validating' do
    
    it 'should have a valid factory' do
      content_type = Factory.build(:content_type)
      content_type.content_custom_fields.build :label => 'anything', :kind => 'String'
      content_type.should be_valid
    end
  
    # Validations ##
  
    %w{site name}.each do |field|
      it "should validate presence of #{field}" do
        content_type = Factory.build(:content_type, field.to_sym => nil)
        content_type.should_not be_valid
        content_type.errors[field.to_sym].should == ["can't be blank"]
      end
    end
  
    it 'should validate presence of slug' do
      content_type = Factory.build(:content_type, :name => nil, :slug => nil)
      content_type.should_not be_valid
      content_type.errors[:slug].should == ["can't be blank"]
    end
  
    it 'should validate uniqueness of slug' do
      content_type = Factory.build(:content_type)
      content_type.content_custom_fields.build :label => 'anything', :kind => 'String'
      content_type.save
      (content_type = Factory.build(:content_type, :site => content_type.site)).should_not be_valid
      content_type.errors[:slug].should == ["is already taken"]
    end
    
    it 'should validate size of content custom fields' do
      content_type = Factory.build(:content_type)
      content_type.should_not be_valid
      content_type.errors[:content_custom_fields].should == ["is too small (minimum element number is 1)"]
    end
    
  end
  
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
locomotive_cms-0.0.3.3 spec/models/content_type_spec.rb
locomotive_cms-0.0.3.1 spec/models/content_type_spec.rb
locomotive_cms-0.0.2.9 spec/models/content_type_spec.rb
locomotive_cms-0.0.2.8 spec/models/content_type_spec.rb
locomotive_cms-0.0.2.7 spec/models/content_type_spec.rb
locomotive_cms-0.0.2.6 spec/models/content_type_spec.rb
locomotive_cms-0.0.2.5 spec/models/content_type_spec.rb
locomotive_cms-0.0.2.4 spec/models/content_type_spec.rb
locomotive_cms-0.0.2.3 spec/models/content_type_spec.rb
locomotive_cms-0.0.2.2 spec/models/content_type_spec.rb
locomotive_cms-0.0.2.1 spec/models/content_type_spec.rb
locomotive_cms-0.0.2 spec/models/content_type_spec.rb
locomotive_cms-0.0.1.4 spec/models/content_type_spec.rb
locomotive_cms-0.0.1.3 spec/models/content_type_spec.rb
locomotive_cms-0.0.1.2 spec/models/content_type_spec.rb
locomotive_cms-0.0.1.1 spec/models/content_type_spec.rb
locomotive_cms-0.0.1 spec/models/content_type_spec.rb