aboutsummaryrefslogtreecommitdiffstats
path: root/spec/dummy/db/seeds
diff options
context:
space:
mode:
authorJamie Winsor <jamie@enmasse.com>2011-08-01 11:27:28 -0700
committerJamie Winsor <jamie@enmasse.com>2011-08-03 18:01:32 -0700
commit21b19db5a30fcb6db83f4ac9302cc94c6320a0db (patch)
tree62a3b89d0f4c9b239bfd76ec77cfc3269ac041ef /spec/dummy/db/seeds
parent3454a9c3007a4bfd10ccd0ff39dc594ebb2a0184 (diff)
downloadrefinerycms-blog-21b19db5a30fcb6db83f4ac9302cc94c6320a0db.tar.gz
refinerycms-blog-21b19db5a30fcb6db83f4ac9302cc94c6320a0db.tar.bz2
refinerycms-blog-21b19db5a30fcb6db83f4ac9302cc94c6320a0db.zip
refactor engine testing scenario
Engine is now tested standalone by leveraging a dummy rails app Enable Guard for speedy testing Move factories to the more standard location `spec/factories/*` Update README with a Testing section Rename migrations to contain datetimestamps for their version to fix migration order issues when migrating the dummy application
Diffstat (limited to 'spec/dummy/db/seeds')
-rw-r--r--spec/dummy/db/seeds/pages.rb63
1 files changed, 63 insertions, 0 deletions
diff --git a/spec/dummy/db/seeds/pages.rb b/spec/dummy/db/seeds/pages.rb
new file mode 100644
index 0000000..668687f
--- /dev/null
+++ b/spec/dummy/db/seeds/pages.rb
@@ -0,0 +1,63 @@
+module Refinery
+ ::Refinery::Page.reset_column_information
+
+ # Check whether all columns are applied yet by seo_meta.
+ unless !defined?(::SeoMeta) || ::SeoMeta.attributes.keys.all? { |k|
+ ::Refinery::Page.translation_class.instance_methods.include?(k)
+ }
+ # Make pages model seo_meta because not all columns are accessible.
+ ::Refinery::Page.translation_class.send :is_seo_meta
+ end
+
+ page_position = -1
+
+ unless ::Refinery::Page.where(:menu_match => "^/$").any?
+ home_page = ::Refinery::Page.create!({:title => "Home",
+ :deletable => false,
+ :link_url => "/",
+ :menu_match => "^/$",
+ :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
+ })
+ else
+ page_position += 1
+ end
+
+ unless ::Refinery::Page.by_title("About").any?
+ about_us_page = ::Refinery::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
+ })
+ else
+ page_position += 1
+ end
+end