Sha256: 1b2fdae14f45c0a79dcebacdfe27c82b04323096f7ad5d32ef988a77aaceb942

Contents?: true

Size: 979 Bytes

Versions: 31

Compression:

Stored size: 979 Bytes

Contents

require 'spec_helper'

describe Layout do

  let(:layout){ FactoryGirl.build(:layout) }

  describe 'name' do
    it 'is invalid when blank' do
      layout = FactoryGirl.build(:layout, name: '')
      layout.valid?
      expect(layout.errors[:name]).to include("this must not be blank")
    end

    it 'should validate uniqueness of' do
      layout = FactoryGirl.build(:layout, name: 'Normal', content: "Content!")
      layout.save!
      other = FactoryGirl.build(:layout, name: 'Normal', content: "Content!")
      expect{other.save!}.to raise_error(ActiveRecord::RecordInvalid)
    end

    it 'should validate length of' do
      layout = FactoryGirl.build(:layout, name: 'x' * 100)
      expect(layout.errors[:name]).to be_blank
      layout = FactoryGirl.build(:layout, name: 'x' * 101)
      expect{layout.save!}.to raise_error(ActiveRecord::RecordInvalid)
      expect(layout.errors[:name]).to include("this must not be longer than 100 characters")
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
trusty-cms-3.1.11 spec/models/layout_spec.rb
trusty-cms-3.1.10 spec/models/layout_spec.rb
trusty-cms-3.1.9 spec/models/layout_spec.rb
trusty-cms-3.1.8 spec/models/layout_spec.rb
trusty-cms-3.1.7 spec/models/layout_spec.rb
trusty-cms-3.1.6 spec/models/layout_spec.rb
trusty-cms-3.1.5 spec/models/layout_spec.rb
trusty-cms-3.1.3 spec/models/layout_spec.rb
trusty-cms-3.1.2 spec/models/layout_spec.rb
trusty-cms-3.0.11 spec/models/layout_spec.rb
trusty-cms-3.1.1 spec/models/layout_spec.rb
trusty-cms-3.0.10 spec/models/layout_spec.rb
trusty-cms-3.1.0 spec/models/layout_spec.rb
trusty-cms-3.0.9 spec/models/layout_spec.rb
trusty-cms-3.0.8 spec/models/layout_spec.rb
trusty-cms-3.0.7 spec/models/layout_spec.rb
trusty-cms-2.0.28 spec/models/layout_spec.rb
trusty-cms-3.0.6 spec/models/layout_spec.rb
trusty-cms-2.0.27 spec/models/layout_spec.rb
trusty-cms-3.0.4 spec/models/layout_spec.rb