engine/spec/support/factories.rb

145 lines
3.5 KiB
Ruby
Raw Normal View History

2011-08-25 21:28:56 +00:00
FactoryGirl.define do
## Site ##
2011-11-20 11:25:01 +00:00
factory :site, :class => Locomotive::Site do
2011-08-25 21:28:56 +00:00
name 'Acme Website'
subdomain 'acme'
2011-08-25 21:28:56 +00:00
created_at Time.now
factory "test site" do
name 'Locomotive test website'
subdomain 'test'
2011-08-25 21:28:56 +00:00
after_build do |site_test|
site_test.memberships.build :account => Locomotive::Account.where(:name => "Admin").first || Factory("admin user"), :role => 'admin'
2011-08-25 21:28:56 +00:00
end
factory "another site" do
name "Locomotive test website #2"
subdomain "test2"
2011-08-25 21:28:56 +00:00
end
end
factory "existing site" do
name "Locomotive site with existing models"
subdomain "models"
after_build do |site_with_models|
site_with_models.content_types.build(
:slug => 'projects',
:name => 'Existing name',
:description => 'Existing description',
:order_by => 'created_at')
end
end
factory "valid site" do
# after_build { |valid_site| valid_site.stubs(:valid?).returns(true) }
end
end
# Accounts ##
2011-11-20 11:25:01 +00:00
factory :account, :class => Locomotive::Account do
2011-08-25 21:28:56 +00:00
name 'Bart Simpson'
email 'bart@simpson.net'
password 'easyone'
password_confirmation 'easyone'
locale 'en'
factory "admin user" do
name "Admin"
email "admin@locomotiveapp.org"
end
factory "frenchy user" do
name "Jean Claude"
email "jean@frenchy.fr"
locale 'fr'
end
factory "brazillian user" do
name "Jose Carlos"
email "jose@carlos.com.br"
locale 'pt-BR'
end
factory "italian user" do
name "Paolo Rossi"
email "paolo@paolo-rossi.it"
locale 'it'
end
end
## Memberships ##
2011-11-20 11:25:01 +00:00
factory :membership, :class => Locomotive::Membership do
2011-08-25 21:28:56 +00:00
role 'admin'
account { Locomotive::Account.where(:name => "Bart Simpson").first || Factory('admin user') }
2011-08-25 21:28:56 +00:00
factory :admin do
role 'admin'
account { Factory('admin user', :locale => 'en') }
end
factory :designer do
role 'designer'
account { Factory('frenchy user', :locale => 'en') }
end
factory :author do
role 'author'
account { Factory('brazillian user', :locale => 'en') }
end
end
## Pages ##
2011-11-20 11:25:01 +00:00
factory :page, :class => Locomotive::Page do
2011-08-25 21:28:56 +00:00
title 'Home page'
slug 'index'
published true
site { Locomotive::Site.where(:subdomain => "acme").first || Factory(:site) }
2011-08-25 21:28:56 +00:00
factory :sub_page do
title 'Subpage'
slug 'subpage'
published true
site { Locomotive::Site.where(:subdomain => "acme").first || Factory(:site) }
parent { Locomotive::Page.where(:slug => "index").first || Factory(:page) }
2011-08-25 21:28:56 +00:00
end
end
## Snippets ##
2011-11-20 11:25:01 +00:00
factory :snippet, :class => Locomotive::Snippet do
2011-08-25 21:28:56 +00:00
name 'My website title'
slug 'header'
template %{<title>Acme</title>}
site { Locomotive::Site.where(:subdomain => "acme").first || Factory(:site) }
2010-08-01 09:55:01 +00:00
end
2011-08-25 21:28:56 +00:00
## Assets ##
2011-11-20 11:25:01 +00:00
factory :asset, :class => Locomotive::ContentAsset do
site { Locomotive::Site.where(:subdomain => "acme").first || Factory(:site) }
2011-08-25 21:28:56 +00:00
end
## Theme assets ##
2011-11-20 11:25:01 +00:00
factory :theme_asset, :class => Locomotive::ThemeAsset do
site { Locomotive::Site.where(:subdomain => "acme").first || Factory(:site) }
2011-08-25 21:28:56 +00:00
end
## Content types ##
2011-11-20 11:25:01 +00:00
factory :content_type, :class => Locomotive::ContentType do
2011-08-25 21:28:56 +00:00
name 'My project'
site { Locomotive::Site.where(:subdomain => "acme").first || Factory(:site) }
end
factory :content_entry, :class => Locomotive::ContentEntry do
end
end