public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
create default section when creating site

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2208 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Mon Sep 18 00:47:47 -0700 2006
commit  f8d6671da882bca212cafb9662c389965bbe02ee
tree    bb6d9b47a4e892851f6a5d8a5e55ab6a40d6f7a4
parent  e80c19e18e8177e7f480f226284f8a8c538e9b0a
...
86
87
88
89
 
90
91
...
86
87
88
 
89
90
91
0
@@ -86,6 +86,6 @@ class Section < ActiveRecord::Base
0
 
0
     def create_path
0
       # nasty regex because i want to keep alpha numerics AND /'s
0
- self.path = self.class.permalink_for(name.to_s) if path.blank?
0
+ self.path = self.class.permalink_for(name.to_s) if path.nil?
0
     end
0
 end
...
53
54
55
 
56
57
58
...
53
54
55
56
57
58
59
0
@@ -53,6 +53,7 @@ class Site < ActiveRecord::Base
0
   validates_format_of :host, :with => Format::DOMAIN
0
   validates_uniqueness_of :host
0
   validate :check_permalink_style
0
+ after_create { |s| s.sections.create(:name => 'Home', :path => '') }
0
   attr_reader :permalink_variables
0
 
0
   with_options :order => 'contents.created_at', :class_name => 'Comment' do |comment|
...
31
32
33
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
36
37
...
31
32
33
 
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
0
@@ -31,7 +31,20 @@ context "Site" do
0
     sites(:first).update_attribute :filter, ''
0
     assert_equal '', sites(:first).reload.filter
0
   end
0
-
0
+
0
+ specify "should create site with default home section" do
0
+ site = nil
0
+ assert_difference Site, :count do
0
+ assert_difference Section, :count do
0
+ site = Site.create! :host => 'foo.com'
0
+ end
0
+ end
0
+ assert_equal 'Home', site.sections.first.name
0
+ assert_equal '', site.sections.first.path
0
+ assert_equal 1, site.sections.size
0
+ assert site.sections.first.home?
0
+ end
0
+
0
   specify "should generate search url" do
0
     assert_equal '/search?q=abc', sites(:first).search_url('abc')
0
     assert_equal '/search?q=abc&page=2', sites(:first).search_url('abc', 2)

Comments

    No one has commented yet.