Permalink
Browse files

Since we don't want Typo users to mess with command line, we have alw…

…ays setup the blog model and initial data when trying to reach it at first load from the browser. Since we moved the initial schema generation to schema.rb and initial data to seed.rb, this didn't work anymore.

This commit adds a call to rake db:seed when loading the initial schema and moves the initial page creation into the setup controller after creating the first user. For some reasons, I need to force the User, Page and Article model reload before creating anything.

Not sure how I can test this.

This solves issue #84.
  • Loading branch information...
fdv committed Dec 27, 2012
1 parent c3e111e commit 3f90a0698ef651cb53e8781044148871d62e3f17
Showing with 16 additions and 6 deletions.
  1. +8 −0 app/controllers/setup_controller.rb
  2. +7 −0 app/models/trigger.rb
  3. +0 −6 db/seeds.rb
  4. +1 −0 spec/controllers/setup_controller_spec.rb
@@ -54,6 +54,14 @@ def update_or_create_first_post_with_user user
user: user)
end
end
+
+ def create_first_page user
+ Page.create(name: "about",
+ title: "about",
+ user: user,
+ body: "This is an example of a Typo page. You can edit this to write information about yourself or your site so readers know who you are. You can create as many pages as this one as you like and manage all of your content inside Typo.")
+
+ end
def check_config
return unless this_blog.configured?
View
@@ -21,6 +21,13 @@ def fire
end
if @needed_migrations
Migrator.migrate
+ if @current_version == 0
+ load "#{Rails.root}/Rakefile"
+ Rake::Task['db:seed'].invoke
+ User.reset_column_information
+ Article.reset_column_information
+ Page.reset_column_information
+ end
end
end
end
View
@@ -11,12 +11,6 @@
category = Category.create(name: 'General', position: 1,
permalink: 'general')
-Page.create(name: "about",
- title: "about",
- user_id: 1,
- body: "This is an example of a Typo page. You can edit this to write information about yourself or your site so readers know who you are. You can create as many pages as this one as you like and manage all of your content inside Typo.")
-
-
PageSidebar.create(active_position: 0, staged_position: 0)
CategorySidebar.create(active_position: 1)
ArchivesSidebar.create(active_position: 2)
@@ -30,6 +30,7 @@
admin.should_not be_nil
admin.email.should == 'foo@bar.net'
Article.find(:first).user.should == admin
+ Page.find(:first).user.should == admin
end
it "should log in admin user" do

0 comments on commit 3f90a06

Please sign in to comment.