spec/models/page_spec.rb in radiantcms-couchrest_model-0.1.4 vs spec/models/page_spec.rb in radiantcms-couchrest_model-0.1.5

- old
+ new

@@ -32,38 +32,38 @@ { :title => 255, :slug => 100, :breadcrumb => 160 }.each do |field, max| - assert_invalid field, ('this must not be longer than %d characters' % max), 'x' * (max + 1) + assert_invalid field, ('%d-character limit' % max), 'x' * (max + 1) assert_valid field, 'x' * max end end it 'should validate presence of' do [:title, :slug, :breadcrumb].each do |field| - assert_invalid field, 'this must not be blank', '', ' ', nil + assert_invalid field, 'required', '', ' ', nil end end it 'should validate format of' do @page.parent = pages(:home) assert_valid :slug, 'abc', 'abcd-efg', 'abcd_efg', 'abc.html', '/', '123' - assert_invalid :slug, 'this does not match the expected format', 'abcd efg', ' abcd', 'abcd/efg' + assert_invalid :slug, 'invalid format', 'abcd efg', ' abcd', 'abcd/efg' end it 'should validate numericality of' do - assert_invalid :status_id, 'this must not be blank', '', nil + assert_invalid :status_id, 'required', '', nil [:id, :status_id, :parent_id].each do |field| assert_valid field, '1', '2' - assert_invalid field, 'this must be a number', 'abcd', '1,2', '1.3' + assert_invalid field, 'must be a number', 'abcd', '1,2', '1.3' end end it 'should validate uniqueness of' do @page.parent = pages(:parent) - assert_invalid :slug, 'this slug is already in use by a sibling of this page', 'child', 'child-2', 'child-3' + assert_invalid :slug, 'slug already in use for child of parent', 'child', 'child-2', 'child-3' assert_valid :slug, 'child-4' end it 'should allow mass assignment for class name' do @page.attributes = { :class_name => 'ArchivePage' } @@ -175,12 +175,10 @@ @page.parts = [PagePart.new(:name => 'body', :content => 'Hello, world!')] @page.changed.should_not be_empty end end - # invalid, as published_at is set when form is submitted - it 'should set published_at when published' do @page = Page.new(page_params(:status_id => '1', :published_at => nil)) @page.published_at.should be_nil @page.status_id = Status[:published].id @@ -205,37 +203,11 @@ it 'should answer false when not published' do @page.status = Status[:draft] @page.published?.should be_false end - - it 'should answer false when not published but scheduled' do - @page.status = Status[:scheduled] - @page.published?.should be_false - end - it 'should change its status to scheduled when publishing in the future' do - @page = Page.new(page_params(:status_id => '100', :published_at => '2020-1-1')) - @page.save - @page.status_id.should == 90 - end - - it 'should change its status to draft when set to draft' do - @page = pages(:scheduled) - @page.status_id = Status[:draft].id - @page.save - @page.status_id.should == 1 - end - - it 'should be published status when published_at is in the past' do - #current time 01-29-2010 - scheduled_time = '2010-1-1' - @page = Page.new(page_params(:status_id => Status[:scheduled].id, :published_at => scheduled_time)) - @page.save - @page.status_id.should == Status[:published].id - end - it "should answer the page's url" do @page = pages(:parent) @page.url.should == '/parent/' @page.children.first.url.should == '/parent/child/' @@ -485,16 +457,9 @@ it 'should allow initialization with default filter' do @page = Page.new_with_defaults({ 'defaults.page.filter' => 'Textile', 'defaults.page.parts' => 'a, b, c' }) @page.parts.each do |part| part.filter_id.should == 'Textile' end - end - - it "should expose default page parts" do - override = PagePart.new(:name => 'override') - Page.stub!(:default_page_parts).and_return([override]) - @page = Page.new_with_defaults({}) - @page.parts.should eql([override]) end it 'should allow you to get the class name of a descendant class with a string' do ["", nil, "Page"].each do |value| Page.descendant_class(value).should == Page