project setup

* added refinerycms(-blog) as depencies
* removed capybara (we won't do any browsertests here)
* initialized refinery in dummy app
This commit is contained in:
Marc Remolt
2011-06-01 21:07:20 +02:00
parent 3ec27fdfe6
commit 1a68663552
46 changed files with 1263 additions and 211 deletions

View File

@@ -0,0 +1,23 @@
class CreateRefinerycmsCoreSchema < ActiveRecord::Migration
def self.up
create_table ::Slug.table_name, :force => true do |t|
t.string "name"
t.integer "sluggable_id"
t.integer "sequence", :default => 1, :null => false
t.string "sluggable_type", :limit => 40
t.string "scope", :limit => 40
t.datetime "created_at"
end
add_index ::Slug.table_name, ["name", "sluggable_type", "scope", "sequence"], :name => "index_#{::Slug.table_name}_on_n_s_s_and_s", :unique => true
add_index ::Slug.table_name, ["sluggable_id"], :name => "index_#{::Slug.table_name}_on_sluggable_id"
end
def self.down
[::Slug].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@@ -0,0 +1,13 @@
class AddLocaleToSlugs < ActiveRecord::Migration
def self.up
add_column :slugs, :locale, :string
add_index :slugs, :locale
end
def self.down
remove_column :slugs, :locale
remove_index :slugs, :locale
end
end

View File

@@ -0,0 +1,24 @@
class CreateRefinerycmsSettingsSchema < ActiveRecord::Migration
def self.up
create_table ::RefinerySetting.table_name, :force => true do |t|
t.string "name"
t.text "value"
t.boolean "destroyable", :default => true
t.datetime "created_at"
t.datetime "updated_at"
t.string "scoping"
t.boolean "restricted", :default => false
t.string "callback_proc_as_string"
end
add_index ::RefinerySetting.table_name, ["name"], :name => "index_#{::RefinerySetting.table_name}_on_name"
end
def self.down
[::RefinerySetting].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@@ -0,0 +1,9 @@
class AddValueTypeToRefinerySettings < ActiveRecord::Migration
def self.up
add_column ::RefinerySetting.table_name, :form_value_type, :string
end
def self.down
remove_column ::RefinerySetting.table_name, :form_value_type
end
end

View File

@@ -0,0 +1,43 @@
class CreateRefinerycmsAuthenticationSchema < ActiveRecord::Migration
def self.up
# Postgres apparently requires the roles_users table to exist before creating the roles table.
create_table ::RolesUsers.table_name, :id => false, :force => true do |t|
t.integer "user_id"
t.integer "role_id"
end
create_table ::Role.table_name, :force => true do |t|
t.string "title"
end
create_table ::UserPlugin.table_name, :force => true do |t|
t.integer "user_id"
t.string "name"
t.integer "position"
end
add_index ::UserPlugin.table_name, ["name"], :name => "index_#{::UserPlugin.table_name}_on_title"
add_index ::UserPlugin.table_name, ["user_id", "name"], :name => "index_unique_#{::UserPlugin.table_name}", :unique => true
create_table ::User.table_name, :force => true do |t|
t.string "login", :null => false
t.string "email", :null => false
t.string "crypted_password", :null => false
t.string "password_salt", :null => false
t.string "persistence_token"
t.datetime "created_at"
t.datetime "updated_at"
t.string "perishable_token"
end
add_index ::User.table_name, ["id"], :name => "index_#{::User.table_name}_on_id"
end
def self.down
[::User].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@@ -0,0 +1,11 @@
class AddMissingIndexesToRolesUsers < ActiveRecord::Migration
def self.up
add_index ::RolesUsers.table_name, [:role_id, :user_id]
add_index ::RolesUsers.table_name, [:user_id, :role_id]
end
def self.down
remove_index ::RolesUsers.table_name, :column => [:role_id, :user_id]
remove_index ::RolesUsers.table_name, :column => [:user_id, :role_id]
end
end

View File

@@ -0,0 +1,27 @@
class ChangeToDeviseUsersTable < ActiveRecord::Migration
def self.up
add_column ::User.table_name, :current_sign_in_at, :datetime
add_column ::User.table_name, :last_sign_in_at, :datetime
add_column ::User.table_name, :current_sign_in_ip, :string
add_column ::User.table_name, :last_sign_in_ip, :string
add_column ::User.table_name, :sign_in_count, :integer
add_column ::User.table_name, :remember_token, :string
add_column ::User.table_name, :reset_password_token, :string
rename_column ::User.table_name, :crypted_password, :encrypted_password
rename_column ::User.table_name, :login, :username
end
def self.down
remove_column ::User.table_name, :current_sign_in_at
remove_column ::User.table_name, :last_sign_in_at
remove_column ::User.table_name, :current_sign_in_ip
remove_column ::User.table_name, :last_sign_in_ip
remove_column ::User.table_name, :sign_in_count
remove_column ::User.table_name, :remember_token
remove_column ::User.table_name, :reset_password_token
rename_column ::User.table_name, :encrypted_password, :crypted_password
rename_column ::User.table_name, :username, :login
end
end

View File

@@ -0,0 +1,9 @@
class AddRememberCreatedAtToUsers < ActiveRecord::Migration
def self.up
add_column :users, :remember_created_at, :datetime
end
def self.down
remove_column :users, :remember_created_at
end
end

View File

@@ -0,0 +1,13 @@
class RemovePasswordSaltFromUsers < ActiveRecord::Migration
def self.up
remove_column :users, :password_salt
# Make the current password invalid :(
User.all.each do |u|
u.update_attribute(:encrypted_password, u.encrypted_password[29..-1])
end
end
def self.down
add_column :users, :password_salt, :string
end
end

View File

@@ -0,0 +1,23 @@
class CreateRefinerycmsImagesSchema < ActiveRecord::Migration
def self.up
create_table ::Image.table_name, :force => true do |t|
t.string "image_mime_type"
t.string "image_name"
t.integer "image_size"
t.integer "image_width"
t.integer "image_height"
t.datetime "created_at"
t.datetime "updated_at"
t.string "image_uid"
t.string "image_ext"
end
end
def self.down
[::Image].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@@ -0,0 +1,52 @@
class CreateRefinerycmsPagesSchema < ActiveRecord::Migration
def self.up
create_table ::PagePart.table_name, :force => true do |t|
t.integer "page_id"
t.string "title"
t.text "body"
t.integer "position"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index ::PagePart.table_name, ["id"], :name => "index_#{::PagePart.table_name}_on_id"
add_index ::PagePart.table_name, ["page_id"], :name => "index_#{::PagePart.table_name}_on_page_id"
create_table ::Page.table_name, :force => true do |t|
t.string "title"
t.integer "parent_id"
t.integer "position"
t.string "path"
t.datetime "created_at"
t.datetime "updated_at"
t.string "meta_keywords"
t.text "meta_description"
t.boolean "show_in_menu", :default => true
t.string "link_url"
t.string "menu_match"
t.boolean "deletable", :default => true
t.string "custom_title"
t.string "custom_title_type", :default => "none"
t.boolean "draft", :default => false
t.string "browser_title"
t.boolean "skip_to_first_child", :default => false
t.integer "lft"
t.integer "rgt"
t.integer "depth"
end
add_index ::Page.table_name, ["depth"], :name => "index_#{::Page.table_name}_on_depth"
add_index ::Page.table_name, ["id"], :name => "index_#{::Page.table_name}_on_id"
add_index ::Page.table_name, ["lft"], :name => "index_#{::Page.table_name}_on_lft"
add_index ::Page.table_name, ["parent_id"], :name => "index_#{::Page.table_name}_on_parent_id"
add_index ::Page.table_name, ["rgt"], :name => "index_#{::Page.table_name}_on_rgt"
end
def self.down
[::Page, ::PagePart].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@@ -0,0 +1,29 @@
class TranslatePagePlugin < ActiveRecord::Migration
def self.up
PagePart.create_translation_table!({
:body => :text
}, {
:migrate_data => true
})
Page.create_translation_table!({
:title => :string,
:meta_keywords => :string,
:meta_description => :text,
:browser_title => :string
}, {
:migrate_data => true
})
if (seed_file = Rails.root.join('db', 'seeds', 'pages.rb')).file?
load seed_file.to_s unless Page.where(:link_url => '/').any?
end
Slug.update_all(:locale => ::I18n.locale)
end
def self.down
Page.drop_translation_table! :migrate_data => true
PagePart.drop_translation_table! :migrate_data => true
end
end

View File

@@ -0,0 +1,11 @@
class RemoveCachedSlugFromPages < ActiveRecord::Migration
def self.up
if ::Page.column_names.map(&:to_s).include?('cached_slug')
remove_column ::Page.table_name, :cached_slug
end
end
def self.down
# Don't add this column back, it breaks stuff.
end
end

View File

@@ -0,0 +1,26 @@
class TranslateCustomTitleOnPages < ActiveRecord::Migration
def self.up
unless ::Page::Translation.column_names.map(&:to_sym).include?(:custom_title)
add_column ::Page::Translation.table_name, :custom_title, :string
# Re-save custom_title
::Page.all.each do |page|
page.update_attribute(:custom_title, page.untranslated_attributes['custom_title'])
end
end
end
def self.down
# Re-save custom_title
::Page.all.each do |page|
::Page.update_all({
:custom_title => page.attributes['custom_title']
}, {
:id => page.id.to_s
}) unless page.attributes['custom_title'].nil?
end
remove_column ::Page::Translation.table_name, :custom_title
end
end

View File

@@ -0,0 +1,13 @@
class RemoveTranslatedFieldsFromPages < ActiveRecord::Migration
def self.up
::Page.translated_attribute_names.map(&:to_sym).each do |column_name|
remove_column ::Page.table_name, column_name if ::Page.column_names.map(&:to_sym).include?(column_name)
end
end
def self.down
::Page.translated_attribute_names.map(&:to_sym).each do |column_name|
add_column ::Page.table_name, column_name, Page::Translation.columns.detect{|c| c.name.to_sym == column_name}.type
end
end
end

View File

@@ -0,0 +1,88 @@
class CreateSeoMeta < ActiveRecord::Migration
def self.up
create_table :seo_meta do |t|
t.integer :seo_meta_id
t.string :seo_meta_type
t.string :browser_title
t.string :meta_keywords
t.text :meta_description
t.timestamps
end
add_index :seo_meta, :id
add_index :seo_meta, [:seo_meta_id, :seo_meta_type]
# Grab the attributes of the records that currently exist
existing_translations = ::Page::Translation.all.map(&:attributes)
# Remove columns
::SeoMeta.attributes.keys.each do |field|
if ::Page::Translation.column_names.map(&:to_sym).include?(field)
remove_column ::Page::Translation.table_name, field
end
end
# Reset column information because otherwise the old columns will still exist.
::Page::Translation.reset_column_information
# Re-attach seo_meta
::Page::Translation.module_eval do
is_seo_meta
end
# Migrate data
existing_translations.each do |translation|
::Page::Translation.find(translation['id']).update_attributes(
::SeoMeta.attributes.keys.inject({}) {|attributes, name|
attributes.merge(name => translation[name.to_s])
}
)
end
# Reset column information again because otherwise the old columns will still exist.
::Page.reset_column_information
end
def self.down
# Grab the attributes of the records that currently exist
existing_translations = ::Page::Translation.all.map(&:attributes)
# Add columns back to your model
::SeoMeta.attributes.each do |field, field_type|
unless ::Page::Translation.column_names.map(&:to_sym).include?(field)
add_column ::Page::Translation.table_name, field, field_type
end
end
# Reset column information because otherwise the new columns won't exist yet.
::Page::Translation.reset_column_information
# Migrate data
existing_translations.each do |translation|
::Page::Translation.update_all(
::SeoMeta.attributes.keys.inject({}) {|attributes, name|
attributes.merge(name => translation[name.to_s])
}, :id => translation['id']
)
end
::SeoMeta.attributes.keys.each do |k|
::Page::Translation.module_eval %{
def #{k}
end
def #{k}=(*args)
end
}
end
# Reset column information again because otherwise the old columns will still exist.
::Page.reset_column_information
drop_table :seo_meta
end
end

View File

@@ -0,0 +1,21 @@
class CreateRefinerycmsResourcesSchema < ActiveRecord::Migration
def self.up
create_table ::Resource.table_name, :force => true do |t|
t.string "file_mime_type"
t.string "file_name"
t.integer "file_size"
t.datetime "created_at"
t.datetime "updated_at"
t.string "file_uid"
t.string "file_ext"
end
end
def self.down
[::Resource].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@@ -0,0 +1,54 @@
class CreateBlogStructure < ActiveRecord::Migration
def self.up
create_table :blog_posts, :id => true do |t|
t.string :title
t.text :body
t.boolean :draft
t.datetime :published_at
t.timestamps
end
add_index :blog_posts, :id
create_table :blog_comments, :id => true do |t|
t.integer :blog_post_id
t.boolean :spam
t.string :name
t.string :email
t.text :body
t.string :state
t.timestamps
end
add_index :blog_comments, :id
create_table :blog_categories, :id => true do |t|
t.string :title
t.timestamps
end
add_index :blog_categories, :id
create_table :blog_categories_blog_posts, :id => false do |t|
t.integer :blog_category_id
t.integer :blog_post_id
end
add_index :blog_categories_blog_posts, [:blog_category_id, :blog_post_id], :name => 'index_blog_categories_blog_posts_on_bc_and_bp'
load(Rails.root.join('db', 'seeds', 'refinerycms_blog.rb').to_s)
end
def self.down
UserPlugin.destroy_all({:name => "refinerycms_blog"})
Page.delete_all({:link_url => "/blog"})
drop_table :blog_posts
drop_table :blog_comments
drop_table :blog_categories
drop_table :blog_categories_blog_posts
end
end

View File

@@ -0,0 +1,11 @@
class AddUserIdToBlogPosts < ActiveRecord::Migration
def self.up
add_column :blog_posts, :user_id, :integer
end
def self.down
remove_column :blog_posts, :user_id
end
end

216
spec/dummy/db/schema.rb Normal file
View File

@@ -0,0 +1,216 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110601190333) do
create_table "blog_categories", :force => true do |t|
t.string "title"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "blog_categories", ["id"], :name => "index_blog_categories_on_id"
create_table "blog_categories_blog_posts", :id => false, :force => true do |t|
t.integer "blog_category_id"
t.integer "blog_post_id"
end
add_index "blog_categories_blog_posts", ["blog_category_id", "blog_post_id"], :name => "index_blog_categories_blog_posts_on_bc_and_bp"
create_table "blog_comments", :force => true do |t|
t.integer "blog_post_id"
t.boolean "spam"
t.string "name"
t.string "email"
t.text "body"
t.string "state"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "blog_comments", ["id"], :name => "index_blog_comments_on_id"
create_table "blog_posts", :force => true do |t|
t.string "title"
t.text "body"
t.boolean "draft"
t.datetime "published_at"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "user_id"
end
add_index "blog_posts", ["id"], :name => "index_blog_posts_on_id"
create_table "images", :force => true do |t|
t.string "image_mime_type"
t.string "image_name"
t.integer "image_size"
t.integer "image_width"
t.integer "image_height"
t.datetime "created_at"
t.datetime "updated_at"
t.string "image_uid"
t.string "image_ext"
end
create_table "page_part_translations", :force => true do |t|
t.integer "page_part_id"
t.string "locale"
t.text "body"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "page_part_translations", ["page_part_id"], :name => "index_page_part_translations_on_page_part_id"
create_table "page_parts", :force => true do |t|
t.integer "page_id"
t.string "title"
t.text "body"
t.integer "position"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "page_parts", ["id"], :name => "index_page_parts_on_id"
add_index "page_parts", ["page_id"], :name => "index_page_parts_on_page_id"
create_table "page_translations", :force => true do |t|
t.integer "page_id"
t.string "locale"
t.string "title"
t.string "custom_title"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "page_translations", ["page_id"], :name => "index_page_translations_on_page_id"
create_table "pages", :force => true do |t|
t.integer "parent_id"
t.integer "position"
t.string "path"
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "show_in_menu", :default => true
t.string "link_url"
t.string "menu_match"
t.boolean "deletable", :default => true
t.string "custom_title_type", :default => "none"
t.boolean "draft", :default => false
t.boolean "skip_to_first_child", :default => false
t.integer "lft"
t.integer "rgt"
t.integer "depth"
end
add_index "pages", ["depth"], :name => "index_pages_on_depth"
add_index "pages", ["id"], :name => "index_pages_on_id"
add_index "pages", ["lft"], :name => "index_pages_on_lft"
add_index "pages", ["parent_id"], :name => "index_pages_on_parent_id"
add_index "pages", ["rgt"], :name => "index_pages_on_rgt"
create_table "refinery_settings", :force => true do |t|
t.string "name"
t.text "value"
t.boolean "destroyable", :default => true
t.datetime "created_at"
t.datetime "updated_at"
t.string "scoping"
t.boolean "restricted", :default => false
t.string "callback_proc_as_string"
t.string "form_value_type"
end
add_index "refinery_settings", ["name"], :name => "index_refinery_settings_on_name"
create_table "resources", :force => true do |t|
t.string "file_mime_type"
t.string "file_name"
t.integer "file_size"
t.datetime "created_at"
t.datetime "updated_at"
t.string "file_uid"
t.string "file_ext"
end
create_table "roles", :force => true do |t|
t.string "title"
end
create_table "roles_users", :id => false, :force => true do |t|
t.integer "user_id"
t.integer "role_id"
end
add_index "roles_users", ["role_id", "user_id"], :name => "index_roles_users_on_role_id_and_user_id"
add_index "roles_users", ["user_id", "role_id"], :name => "index_roles_users_on_user_id_and_role_id"
create_table "seo_meta", :force => true do |t|
t.integer "seo_meta_id"
t.string "seo_meta_type"
t.string "browser_title"
t.string "meta_keywords"
t.text "meta_description"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "seo_meta", ["id"], :name => "index_seo_meta_on_id"
add_index "seo_meta", ["seo_meta_id", "seo_meta_type"], :name => "index_seo_meta_on_seo_meta_id_and_seo_meta_type"
create_table "slugs", :force => true do |t|
t.string "name"
t.integer "sluggable_id"
t.integer "sequence", :default => 1, :null => false
t.string "sluggable_type", :limit => 40
t.string "scope", :limit => 40
t.datetime "created_at"
t.string "locale"
end
add_index "slugs", ["locale"], :name => "index_slugs_on_locale"
add_index "slugs", ["name", "sluggable_type", "scope", "sequence"], :name => "index_slugs_on_n_s_s_and_s", :unique => true
add_index "slugs", ["sluggable_id"], :name => "index_slugs_on_sluggable_id"
create_table "user_plugins", :force => true do |t|
t.integer "user_id"
t.string "name"
t.integer "position"
end
add_index "user_plugins", ["name"], :name => "index_user_plugins_on_title"
add_index "user_plugins", ["user_id", "name"], :name => "index_unique_user_plugins", :unique => true
create_table "users", :force => true do |t|
t.string "username", :null => false
t.string "email", :null => false
t.string "encrypted_password", :null => false
t.string "persistence_token"
t.datetime "created_at"
t.datetime "updated_at"
t.string "perishable_token"
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.integer "sign_in_count"
t.string "remember_token"
t.string "reset_password_token"
t.datetime "remember_created_at"
end
add_index "users", ["id"], :name => "index_users_on_id"
end

5
spec/dummy/db/seeds.rb Normal file
View File

@@ -0,0 +1,5 @@
# Refinery seeds
Dir[Rails.root.join('db', 'seeds', '*.rb').to_s].each do |file|
puts "Loading db/seeds/#{file.split(File::SEPARATOR).last}"
load(file)
end

View File

@@ -0,0 +1,42 @@
page_position = -1
home_page = Page.create(:title => "Home",
:deletable => false,
:link_url => "/",
:position => (page_position += 1))
home_page.parts.create({
:title => "Body",
:body => "<p>Welcome to our site. This is just a place holder page while we gather our content.</p>",
:position => 0
})
home_page.parts.create({
:title => "Side Body",
:body => "<p>This is another block of content over here.</p>",
:position => 1
})
home_page_position = -1
page_not_found_page = home_page.children.create(:title => "Page not found",
:menu_match => "^/404$",
:show_in_menu => false,
:deletable => false,
:position => (home_page_position += 1))
page_not_found_page.parts.create({
:title => "Body",
:body => "<h2>Sorry, there was a problem...</h2><p>The page you requested was not found.</p><p><a href='/'>Return to the home page</a></p>",
:position => 0
})
about_us_page = Page.create(:title => "About",
:deletable => true,
:position => (page_position += 1))
about_us_page.parts.create({
:title => "Body",
:body => "<p>This is just a standard text page example. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin metus dolor, hendrerit sit amet, aliquet nec, posuere sed, purus. Nullam et velit iaculis odio sagittis placerat. Duis metus tellus, pellentesque ut, luctus id, egestas a, lorem. Praesent vitae mauris. Aliquam sed nulla. Sed id nunc vitae leo suscipit viverra. Proin at leo ut lacus consequat rhoncus. In hac habitasse platea dictumst. Nunc quis tortor sed libero hendrerit dapibus.\n\nInteger interdum purus id erat. Duis nec velit vitae dolor mattis euismod. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse pellentesque dignissim lacus. Nulla semper euismod arcu. Suspendisse egestas, erat a consectetur dapibus, felis orci cursus eros, et sollicitudin purus urna et metus. Integer eget est sed nunc euismod vestibulum. Integer nulla dui, tristique in, euismod et, interdum imperdiet, enim. Mauris at lectus. Sed egestas tortor nec mi.</p>",
:position => 0
})
about_us_page.parts.create({
:title => "Side Body",
:body => "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus fringilla nisi a elit. Duis ultricies orci ut arcu. Ut ac nibh. Duis blandit rhoncus magna. Pellentesque semper risus ut magna. Etiam pulvinar tellus eget diam. Morbi blandit. Donec pulvinar mauris at ligula. Sed pellentesque, ipsum id congue molestie, lectus risus egestas pede, ac viverra diam lacus ac urna. Aenean elit.</p>",
:position => 1
})

View File

@@ -0,0 +1,16 @@
User.find(:all).each do |user|
user.plugins.create(:name => "refinerycms_blog",
:position => (user.plugins.maximum(:position) || -1) +1)
end
page = Page.create(
:title => "Blog",
:link_url => "/blog",
:deletable => false,
:position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
:menu_match => "^/blogs?(\/|\/.+?|)$"
)
Page.default_parts.each do |default_page_part|
page.parts.create(:title => default_page_part, :body => nil)
end