Skip to content

Commit

Permalink
Added a defaults.page.filter config setting for setting a default pag…
Browse files Browse the repository at this point in the history
…e filter.
  • Loading branch information
AlexJWayne committed Jun 22, 2008
1 parent 80781ac commit 318687e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/page.rb
Expand Up @@ -197,7 +197,7 @@ def new_with_defaults(config = Radiant::Config)
default_parts = config['defaults.page.parts'].to_s.strip.split(/\s*,\s*/)
page = new
default_parts.each do |name|
page.parts << PagePart.new(:name => name)
page.parts << PagePart.new(:name => name, :filter_id => config['defaults.page.filter'])
end
default_status = config['defaults.page.status']
page.status = Status[default_status] if default_status
Expand Down
1 change: 1 addition & 0 deletions lib/radiant/setup.rb
Expand Up @@ -49,6 +49,7 @@ def load_default_configuration
step { Radiant::Config['admin.subtitle'] = 'Publishing for Small Teams' }
step { Radiant::Config['defaults.page.parts' ] = 'body, extended' }
step { Radiant::Config['defaults.page.status' ] = 'draft' }
step { Radiant::Config['defaults.page.filter' ] = nil }
end
end

Expand Down
9 changes: 8 additions & 1 deletion spec/models/page_spec.rb
Expand Up @@ -428,7 +428,14 @@ def headers
it 'should allow initialization with default page status' do
@page = Page.new_with_defaults({ 'defaults.page.status' => 'published' })
@page.status.should == Status[:published]
end
end

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 allow you to get the class name of a descendant class with a string' do
["", nil, "Page"].each do |value|
Expand Down

0 comments on commit 318687e

Please sign in to comment.