Sha256: e0ece2cf63f18eeee3a573e9e698b275793136cd25f84d0c716f997d60642f6e
Contents?: true
Size: 1.33 KB
Versions: 5
Compression:
Stored size: 1.33 KB
Contents
require 'rails_helper' describe SpudPagePartial, :type => :model do describe "validations" do it "should require a name" do p = FactoryGirl.build(:spud_page_partial,:name => nil) expect(p).to_not be_valid end it "should respond with a symbol_name based on name" do p = FactoryGirl.build(:spud_page_partial,:name => "Test Page") expect(p.symbol_name).to eq("test_page") end end describe "save hooks" do it "should save the symbol name" do p = FactoryGirl.create(:spud_page_partial, :name => "Test Page") expect(p.attributes["symbol_name"]).to eq("test_page") end it "should create a new revision if content is changed" do p = FactoryGirl.create(:spud_page_partial, :name => "Test Page", :content => 'Content') expect(SpudPagePartialRevision.where(:spud_page_id => p.spud_page_id).count).to eq(1) end it "should delete old revisions beyond max_revision count" do Spud::Cms.configure do |config| config.max_revisions = 2 end p = FactoryGirl.create(:spud_page_partial,:name => "Test Page",:content =>"Home Sweet Home",:spud_page_id => 1) p.content = "Nah" p.save p.content = "Another change" p.save expect(SpudPagePartialRevision.where(:spud_page_id => 1,:name => "Test Page").count).to eq(2) end end end
Version data entries
5 entries across 5 versions & 1 rubygems