Permalink
Browse files

Do not generate elements if creating pages with factory girl.

This dramatically speeds up the tests. Dropped from 3:45 to 1:28!
  • Loading branch information...
1 parent f6475ea commit 9a74171b2565336e4da2201f7ddbdc3324435f82 @tvdeyen tvdeyen committed Aug 28, 2012
View
2 spec/controllers/admin/elements_controller_spec.rb
@@ -76,7 +76,7 @@ module Alchemy
context "with cells" do
before do
- @page = FactoryGirl.create(:public_page)
+ @page = FactoryGirl.create(:public_page, :do_not_autogenerate => false)
@cell = FactoryGirl.create(:cell, :name => 'header', :page => @page)
Page.any_instance.stub(:can_have_cells?).and_return(true)
Cell.stub!(:definition_for).and_return({'name' => 'header', 'elements' => ['article']})
View
4 spec/controllers/pages_controller_spec.rb
@@ -12,7 +12,7 @@
context "requested for a page containing a feed" do
before(:each) do
- @page = FactoryGirl.create(:public_page, :parent_id => @default_language_root.id, :page_layout => 'news', :name => 'News', :language => @default_language)
+ @page = FactoryGirl.create(:public_page, :parent_id => @default_language_root.id, :page_layout => 'news', :name => 'News', :language => @default_language, :do_not_autogenerate => false)
end
it "should render a rss feed" do
@@ -104,7 +104,7 @@
before(:each) do
@catalog = FactoryGirl.create(:public_page, :name => "Catalog", :parent_id => @default_language_root.id, :language => @default_language)
@products = FactoryGirl.create(:public_page, :name => "Products", :parent_id => @catalog.id, :language => @default_language)
- @product = FactoryGirl.create(:public_page, :name => "Screwdriver", :parent_id => @products.id, :language => @default_language)
+ @product = FactoryGirl.create(:public_page, :name => "Screwdriver", :parent_id => @products.id, :language => @default_language, :do_not_autogenerate => false)
@product.elements.find_by_name('article').contents.essence_texts.first.essence.update_column(:body, 'screwdriver')
controller.stub!(:configuration) { |arg| arg == :url_nesting ? true : false }
end
View
3 spec/factories.rb
@@ -54,6 +54,9 @@
parent_id { (Alchemy::Page.find_by_language_root(true) || FactoryGirl.create(:language_root_page)).id }
page_layout "standard"
+ # This speeds up creating of pages dramatically. Pass :do_not_autogenerate => false to generate elements
+ do_not_autogenerate true
+
factory :language_root_page do
name 'Startseite'
page_layout 'intro'
View
4 spec/integration/pages_controller_spec.rb
@@ -8,15 +8,15 @@ module Alchemy
let(:default_language_root) { FactoryGirl.create(:language_root_page, :language => default_language, :name => 'Home') }
let(:public_page_1) { FactoryGirl.create(:public_page, :visible => true, :name => 'Page 1') }
let(:public_child) { FactoryGirl.create(:public_page, :name => 'Public Child', :parent_id => public_page_1.id) }
- let(:search_page) { FactoryGirl.create(:public_page, :name => 'Suche', :page_layout => 'search') }
+ let(:search_page) { FactoryGirl.create(:public_page, :name => 'Suche', :page_layout => 'search', :do_not_autogenerate => false) }
let(:element) { FactoryGirl.create(:element, :page => public_page_1) }
before { default_language_root }
describe "#show" do
it "should include all its elements and contents" do
- p = FactoryGirl.create(:public_page)
+ p = FactoryGirl.create(:public_page, :do_not_autogenerate => false)
article = p.elements.find_by_name('article')
article.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop', :public => true)
visit "/alchemy/#{p.urlname}"
View
2 spec/models/element_spec.rb
@@ -160,7 +160,7 @@ module Alchemy
'elements' => ['column_headline', 'unique_headline'],
'autogenerate' => ['unique_headline', 'column_headline', 'column_headline', 'column_headline']
})
- @page = FactoryGirl.create(:page, :page_layout => 'columns')
+ @page = FactoryGirl.create(:page, :page_layout => 'columns', :do_not_autogenerate => false)
end
it "should be readable" do
View
7 spec/models/page_spec.rb
@@ -11,7 +11,7 @@ module Alchemy
let(:language_root) { FactoryGirl.create(:language_root_page) }
let(:page) { mock(:page, :page_layout => 'foo') }
let(:public_page) { FactoryGirl.create(:public_page) }
- let(:news_page) { FactoryGirl.create(:public_page, :page_layout => 'news') }
+ let(:news_page) { FactoryGirl.create(:public_page, :page_layout => 'news', :do_not_autogenerate => false) }
describe ".layout_description" do
@@ -38,6 +38,7 @@ module Alchemy
end
it "should return all rss feed elements" do
+ news_page.feed_elements.should_not be_empty
news_page.feed_elements.should == Element.find_all_by_name('news')
end
@@ -306,7 +307,7 @@ module Alchemy
'name' => "header",
'elements' => ["header"]
}])
- @page = FactoryGirl.create(:public_page)
+ @page = FactoryGirl.create(:public_page, :do_not_autogenerate => false)
end
it "should return elements grouped by cell" do
@@ -431,7 +432,7 @@ module Alchemy
context "a normal page" do
before do
- @page = FactoryGirl.build(:page, :language_code => nil, :language => klingonian)
+ @page = FactoryGirl.build(:page, :language_code => nil, :language => klingonian, :do_not_autogenerate => false)
end
it "should get the language code for language" do

0 comments on commit 9a74171

Please sign in to comment.