Permalink
Browse files

New PageParts should have the default filter_id.

  • Loading branch information...
joevandyk committed Oct 22, 2008
1 parent d81da40 commit b732b61c79dd14d67060e841874ffb1ef81dbe52
Showing with 17 additions and 1 deletion.
  1. +5 −1 app/models/page_part.rb
  2. +12 −0 spec/models/page_part_spec.rb
View
@@ -13,5 +13,9 @@ class PagePart < ActiveRecord::Base
validates_numericality_of :id, :page_id, :allow_nil => true, :only_integer => true, :message => 'must be a number'
object_id_attr :filter, TextFilter
def after_initialize
self.filter_id ||= Radiant::Config['defaults.page.filter']
end
end
@@ -6,6 +6,18 @@
before :all do
@part = @model = PagePart.new(PagePartTestHelper::VALID_PAGE_PART_PARAMS)
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
Radiant::Config['defaults.page.filter'] = "Textile"
part = PagePart.find(:first, :conditions => "filter_id != 'Textile'") # Find first page part that doesn't have the default filter
part.filter_id.should_not == "Textile" # Filter shouldn't be the default one, obviously.
end
it 'should validate length of' do
{

0 comments on commit b732b61

Please sign in to comment.