Ruby MRI 1.9.3 Compatability Fixes
This commit is contained in:
parent
aa5c5f0092
commit
bb48552b51
6
Gemfile
6
Gemfile
@ -33,7 +33,7 @@ gem 'mimetype-fu'
|
|||||||
gem 'actionmailer-with-request', :require => 'actionmailer_with_request'
|
gem 'actionmailer-with-request', :require => 'actionmailer_with_request'
|
||||||
gem 'heroku', '1.19.1'
|
gem 'heroku', '1.19.1'
|
||||||
gem 'httparty', '>= 0.6.1'
|
gem 'httparty', '>= 0.6.1'
|
||||||
gem 'RedCloth', '4.2.7'
|
gem 'RedCloth', '4.2.8'
|
||||||
gem 'delayed_job', '2.1.4'
|
gem 'delayed_job', '2.1.4'
|
||||||
gem 'delayed_job_mongoid', '1.0.2'
|
gem 'delayed_job_mongoid', '1.0.2'
|
||||||
gem 'rubyzip'
|
gem 'rubyzip'
|
||||||
@ -68,7 +68,7 @@ group :test do
|
|||||||
gem 'ZenTest'
|
gem 'ZenTest'
|
||||||
gem 'growl-glue'
|
gem 'growl-glue'
|
||||||
gem 'rspec-rails', '2.6.1'
|
gem 'rspec-rails', '2.6.1'
|
||||||
gem 'factory_girl_rails'
|
gem 'factory_girl_rails', '~> 1.1'
|
||||||
gem 'pickle'
|
gem 'pickle'
|
||||||
gem 'xpath', '~> 0.1.4'
|
gem 'xpath', '~> 0.1.4'
|
||||||
gem 'capybara'
|
gem 'capybara'
|
||||||
@ -76,7 +76,7 @@ group :test do
|
|||||||
|
|
||||||
gem 'spork', '~> 0.9.0.rc'
|
gem 'spork', '~> 0.9.0.rc'
|
||||||
gem 'launchy'
|
gem 'launchy'
|
||||||
gem 'mocha', :git => 'git://github.com/floehopper/mocha.git'
|
gem 'mocha', '0.9.12' # :git => 'git://github.com/floehopper/mocha.git'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :production do
|
group :production do
|
||||||
|
17
Gemfile.lock
17
Gemfile.lock
@ -1,10 +1,3 @@
|
|||||||
GIT
|
|
||||||
remote: git://github.com/floehopper/mocha.git
|
|
||||||
revision: afa87804ca2124ff5e77f007a84a26ee0667eec8
|
|
||||||
specs:
|
|
||||||
mocha (0.9.12)
|
|
||||||
metaclass (~> 0.0.1)
|
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
@ -12,7 +5,7 @@ GEM
|
|||||||
Platform (>= 0.4.0)
|
Platform (>= 0.4.0)
|
||||||
open4
|
open4
|
||||||
Platform (0.4.0)
|
Platform (0.4.0)
|
||||||
RedCloth (4.2.7)
|
RedCloth (4.2.8)
|
||||||
SystemTimer (1.2.3)
|
SystemTimer (1.2.3)
|
||||||
ZenTest (4.6.1)
|
ZenTest (4.6.1)
|
||||||
abstract (1.0.0)
|
abstract (1.0.0)
|
||||||
@ -170,10 +163,10 @@ GEM
|
|||||||
i18n (>= 0.4.0)
|
i18n (>= 0.4.0)
|
||||||
mime-types (~> 1.16)
|
mime-types (~> 1.16)
|
||||||
treetop (~> 1.4.8)
|
treetop (~> 1.4.8)
|
||||||
metaclass (0.0.1)
|
|
||||||
mime-types (1.16)
|
mime-types (1.16)
|
||||||
mimemagic (0.1.8)
|
mimemagic (0.1.8)
|
||||||
mimetype-fu (0.1.2)
|
mimetype-fu (0.1.2)
|
||||||
|
mocha (0.9.12)
|
||||||
mongo (1.3.1)
|
mongo (1.3.1)
|
||||||
bson (>= 1.3.1)
|
bson (>= 1.3.1)
|
||||||
mongoid (2.0.2)
|
mongoid (2.0.2)
|
||||||
@ -286,7 +279,7 @@ PLATFORMS
|
|||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
RedCloth (= 4.2.7)
|
RedCloth (= 4.2.8)
|
||||||
SystemTimer
|
SystemTimer
|
||||||
ZenTest
|
ZenTest
|
||||||
actionmailer-with-request
|
actionmailer-with-request
|
||||||
@ -306,7 +299,7 @@ DEPENDENCIES
|
|||||||
devise (= 1.3.4)
|
devise (= 1.3.4)
|
||||||
devise_bushido_authenticatable (= 1.0.0.alpha10)
|
devise_bushido_authenticatable (= 1.0.0.alpha10)
|
||||||
dragonfly (~> 0.9.1)
|
dragonfly (~> 0.9.1)
|
||||||
factory_girl_rails
|
factory_girl_rails (~> 1.1)
|
||||||
fog (= 0.8.2)
|
fog (= 0.8.2)
|
||||||
formtastic (~> 1.2.3)
|
formtastic (~> 1.2.3)
|
||||||
growl-glue
|
growl-glue
|
||||||
@ -321,7 +314,7 @@ DEPENDENCIES
|
|||||||
locomotive_liquid (= 2.2.2)
|
locomotive_liquid (= 2.2.2)
|
||||||
locomotive_mongoid_acts_as_tree (= 0.1.5.7)
|
locomotive_mongoid_acts_as_tree (= 0.1.5.7)
|
||||||
mimetype-fu
|
mimetype-fu
|
||||||
mocha!
|
mocha (= 0.9.12)
|
||||||
mongoid (~> 2.0.2)
|
mongoid (~> 2.0.2)
|
||||||
pickle
|
pickle
|
||||||
rack-cache
|
rack-cache
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<%
|
<%
|
||||||
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
||||||
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
||||||
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
|
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --require features --strict --tags ~@wip"
|
||||||
%>
|
%>
|
||||||
default: <%= std_opts %> features
|
default: <%= std_opts %> features
|
||||||
wip: --tags @wip:3 --wip features
|
wip: --tags @wip:3 --wip features
|
||||||
|
@ -5,7 +5,7 @@ Given /^I am not authenticated$/ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
Given /^I am an authenticated "([^"]*)"$/ do |role|
|
Given /^I am an authenticated "([^"]*)"$/ do |role|
|
||||||
@member = Site.first.memberships.where(:role => role.downcase).first || Factory(role.downcase.to_sym, :site => Site.first)
|
@member = Site.first.memberships.where(:role => role.downcase).first || FactoryGirl.create(role.downcase.to_sym, :site => Site.first)
|
||||||
|
|
||||||
Given %{I go to login}
|
Given %{I go to login}
|
||||||
And %{I fill in "Email" with "#{@member.account.email}"}
|
And %{I fill in "Email" with "#{@member.account.email}"}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Given %r{^I have a custom model named "([^"]*)" with$} do |name, fields|
|
Given %r{^I have a custom model named "([^"]*)" with$} do |name, fields|
|
||||||
site = Site.first
|
site = Site.first
|
||||||
content_type = Factory.build(:content_type, :site => site, :name => name)
|
content_type = FactoryGirl.build(:content_type, :site => site, :name => name)
|
||||||
fields.hashes.each do |field|
|
fields.hashes.each do |field|
|
||||||
if (target_name = field.delete('target')).present?
|
if (target_name = field.delete('target')).present?
|
||||||
target_content_type = site.content_types.where(:name => target_name).first
|
target_content_type = site.content_types.where(:name => target_name).first
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# helps create a simple content page (parent: "index") with a slug, contents, and template
|
# helps create a simple content page (parent: "index") with a slug, contents, and template
|
||||||
def create_content_page(page_slug, page_contents, template = nil)
|
def create_content_page(page_slug, page_contents, template = nil)
|
||||||
@home = @site.pages.where(:slug => "index").first || Factory(:page)
|
@home = @site.pages.where(:slug => "index").first || FactoryGirl.create(:page)
|
||||||
page = @site.pages.create(:slug => page_slug, :body => page_contents, :parent => @home, :title => "some title", :published => true, :raw_template => template)
|
page = @site.pages.create(:slug => page_slug, :body => page_contents, :parent => @home, :title => "some title", :published => true, :raw_template => template)
|
||||||
page.should be_valid
|
page.should be_valid
|
||||||
page
|
page
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
# - I have the site: "some site" set up with name: "Something", domain: "test2"
|
# - I have the site: "some site" set up with name: "Something", domain: "test2"
|
||||||
#
|
#
|
||||||
Given /^I have the site: "([^"]*)" set up(?: with #{capture_fields})?$/ do |site_factory, fields|
|
Given /^I have the site: "([^"]*)" set up(?: with #{capture_fields})?$/ do |site_factory, fields|
|
||||||
@site = Factory(site_factory, parse_fields(fields))
|
@site = FactoryGirl.create(site_factory, parse_fields(fields))
|
||||||
@site.should_not be_nil
|
@site.should_not be_nil
|
||||||
|
|
||||||
@admin = @site.memberships.first.account
|
@admin = @site.memberships.first.account
|
||||||
@ -13,8 +13,8 @@ Given /^I have the site: "([^"]*)" set up(?: with #{capture_fields})?$/ do |site
|
|||||||
end
|
end
|
||||||
|
|
||||||
Given /^I have a designer and an author$/ do
|
Given /^I have a designer and an author$/ do
|
||||||
Factory(:designer, :site => Site.first)
|
FactoryGirl.create(:designer, :site => Site.first)
|
||||||
Factory(:author, :site => Site.first)
|
FactoryGirl.create(:author, :site => Site.first)
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should be a administrator of the "([^"]*)" site$/ do |name|
|
Then /^I should be a administrator of the "([^"]*)" site$/ do |name|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# helps create a theme asset
|
# helps create a theme asset
|
||||||
def create_plain_text_asset(name, type)
|
def create_plain_text_asset(name, type)
|
||||||
asset = Factory.build(:theme_asset, {
|
asset = FactoryGirl.build(:theme_asset, {
|
||||||
:site => @site,
|
:site => @site,
|
||||||
:plain_text_name => name,
|
:plain_text_name => name,
|
||||||
:plain_text => 'Lorem ipsum',
|
:plain_text => 'Lorem ipsum',
|
||||||
|
@ -50,7 +50,7 @@ Gem::Specification.new do |s|
|
|||||||
s.add_dependency 'mimetype-fu'
|
s.add_dependency 'mimetype-fu'
|
||||||
s.add_dependency 'actionmailer-with-request'
|
s.add_dependency 'actionmailer-with-request'
|
||||||
s.add_dependency 'httparty', '>= 0.6.1'
|
s.add_dependency 'httparty', '>= 0.6.1'
|
||||||
s.add_dependency 'RedCloth', '4.2.7'
|
s.add_dependency 'RedCloth', '4.2.8'
|
||||||
s.add_dependency 'delayed_job', '2.1.4'
|
s.add_dependency 'delayed_job', '2.1.4'
|
||||||
s.add_dependency 'delayed_job_mongoid', '1.0.2'
|
s.add_dependency 'delayed_job_mongoid', '1.0.2'
|
||||||
s.add_dependency 'rubyzip'
|
s.add_dependency 'rubyzip'
|
||||||
|
@ -4,7 +4,7 @@ describe Admin::GlobalActionsCell do
|
|||||||
|
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:menu) { render_cell('admin/global_actions', :show, :current_admin => Factory.build('admin user'), :current_site_url => 'http://www.yahoo.fr') }
|
let(:menu) { render_cell('admin/global_actions', :show, :current_admin => FactoryGirl.build('admin user'), :current_site_url => 'http://www.yahoo.fr') }
|
||||||
|
|
||||||
describe 'show menu' do
|
describe 'show menu' do
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||||||
describe Admin::ApiContentsController do
|
describe Admin::ApiContentsController do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@site = Factory('existing site')
|
@site = FactoryGirl.create('existing site')
|
||||||
@site.content_types.first.tap do |content_type|
|
@site.content_types.first.tap do |content_type|
|
||||||
content_type.content_custom_fields.build :label => 'Name', :kind => 'string', :required => true
|
content_type.content_custom_fields.build :label => 'Name', :kind => 'string', :required => true
|
||||||
content_type.content_custom_fields.build :label => 'Description', :kind => 'text'
|
content_type.content_custom_fields.build :label => 'Description', :kind => 'text'
|
||||||
|
@ -1,136 +1,141 @@
|
|||||||
## Site ##
|
FactoryGirl.define do
|
||||||
Factory.define :site do |s|
|
|
||||||
s.name 'Acme Website'
|
|
||||||
s.subdomain 'acme'
|
|
||||||
s.created_at Time.now
|
|
||||||
end
|
|
||||||
|
|
||||||
Factory.define "test site", :parent => :site do |s|
|
## Site ##
|
||||||
s.name 'Locomotive test website'
|
factory :site do
|
||||||
s.subdomain 'test'
|
name 'Acme Website'
|
||||||
s.after_build do |site_test|
|
subdomain 'acme'
|
||||||
|
created_at Time.now
|
||||||
|
|
||||||
|
factory "test site" do
|
||||||
|
name 'Locomotive test website'
|
||||||
|
subdomain 'test'
|
||||||
|
|
||||||
|
after_build do |site_test|
|
||||||
site_test.memberships.build :account => Account.where(:name => "Admin").first || Factory("admin user"), :role => 'admin'
|
site_test.memberships.build :account => Account.where(:name => "Admin").first || Factory("admin user"), :role => 'admin'
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
Factory.define "another site", :parent => "test site" do |s|
|
factory "another site" do
|
||||||
s.name "Locomotive test website #2"
|
name "Locomotive test website #2"
|
||||||
s.subdomain "test2"
|
subdomain "test2"
|
||||||
end
|
end
|
||||||
|
|
||||||
Factory.define "existing site", :parent => "site" do |s|
|
end
|
||||||
s.name "Locomotive site with existing models"
|
|
||||||
s.subdomain "models"
|
factory "existing site" do
|
||||||
s.after_build do |site_with_models|
|
name "Locomotive site with existing models"
|
||||||
|
subdomain "models"
|
||||||
|
after_build do |site_with_models|
|
||||||
site_with_models.content_types.build(
|
site_with_models.content_types.build(
|
||||||
:slug => 'projects',
|
:slug => 'projects',
|
||||||
:name => 'Existing name',
|
:name => 'Existing name',
|
||||||
:description => 'Existing description',
|
:description => 'Existing description',
|
||||||
:order_by => 'created_at')
|
:order_by => 'created_at')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
factory "valid site" do
|
||||||
|
# after_build { |valid_site| valid_site.stubs(:valid?).returns(true) }
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Accounts ##
|
||||||
|
factory :account do
|
||||||
|
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 ##
|
||||||
|
factory :membership do
|
||||||
|
role 'admin'
|
||||||
|
account { Account.where(:name => "Bart Simpson").first || Factory('admin user') }
|
||||||
|
|
||||||
|
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 ##
|
||||||
|
factory :page do
|
||||||
|
title 'Home page'
|
||||||
|
slug 'index'
|
||||||
|
published true
|
||||||
|
site { Site.where(:subdomain => "acme").first || Factory(:site) }
|
||||||
|
|
||||||
|
factory :sub_page do
|
||||||
|
title 'Subpage'
|
||||||
|
slug 'subpage'
|
||||||
|
published true
|
||||||
|
site { Site.where(:subdomain => "acme").first || Factory(:site) }
|
||||||
|
parent { Page.where(:slug => "index").first || Factory(:page) }
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
## Snippets ##
|
||||||
|
factory :snippet do
|
||||||
|
name 'My website title'
|
||||||
|
slug 'header'
|
||||||
|
template %{<title>Acme</title>}
|
||||||
|
site { Site.where(:subdomain => "acme").first || Factory(:site) }
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
## Assets ##
|
||||||
|
factory :asset do
|
||||||
|
site { Site.where(:subdomain => "acme").first || Factory(:site) }
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
## Theme assets ##
|
||||||
|
factory :theme_asset do
|
||||||
|
site { Site.where(:subdomain => "acme").first || Factory(:site) }
|
||||||
|
end
|
||||||
|
|
||||||
|
## Content types ##
|
||||||
|
factory :content_type do
|
||||||
|
name 'My project'
|
||||||
|
site { Site.where(:subdomain => "acme").first || Factory(:site) }
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Factory.define "valid site", :parent => "site" do |s|
|
|
||||||
# s.after_build { |valid_site| valid_site.stubs(:valid?).returns(true) }
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
# Accounts ##
|
|
||||||
Factory.define :account do |a|
|
|
||||||
a.name 'Bart Simpson'
|
|
||||||
a.email 'bart@simpson.net'
|
|
||||||
a.password 'easyone'
|
|
||||||
a.password_confirmation 'easyone'
|
|
||||||
a.locale 'en'
|
|
||||||
end
|
|
||||||
|
|
||||||
Factory.define "admin user", :parent => :account do |a|
|
|
||||||
a.name "Admin"
|
|
||||||
a.email "admin@locomotiveapp.org"
|
|
||||||
end
|
|
||||||
|
|
||||||
Factory.define "frenchy user", :parent => :account do |a|
|
|
||||||
a.name "Jean Claude"
|
|
||||||
a.email "jean@frenchy.fr"
|
|
||||||
a.locale 'fr'
|
|
||||||
end
|
|
||||||
|
|
||||||
Factory.define "brazillian user", :parent => :account do |a|
|
|
||||||
a.name "Jose Carlos"
|
|
||||||
a.email "jose@carlos.com.br"
|
|
||||||
a.locale 'pt-BR'
|
|
||||||
end
|
|
||||||
|
|
||||||
Factory.define "italian user", :parent => :account do |a|
|
|
||||||
a.name "Paolo Rossi"
|
|
||||||
a.email "paolo@paolo-rossi.it"
|
|
||||||
a.locale 'it'
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
## Memberships ##
|
|
||||||
Factory.define :membership do |m|
|
|
||||||
m.role 'admin'
|
|
||||||
m.account { Account.where(:name => "Bart Simpson").first || Factory('admin user') }
|
|
||||||
end
|
|
||||||
|
|
||||||
Factory.define :admin, :parent => :membership do |m|
|
|
||||||
m.role 'admin'
|
|
||||||
m.account { Factory('admin user', :locale => 'en') }
|
|
||||||
end
|
|
||||||
|
|
||||||
Factory.define :designer, :parent => :membership do |m|
|
|
||||||
m.role 'designer'
|
|
||||||
m.account { Factory('frenchy user', :locale => 'en') }
|
|
||||||
end
|
|
||||||
|
|
||||||
Factory.define :author, :parent => :membership do |m|
|
|
||||||
m.role 'author'
|
|
||||||
m.account { Factory('brazillian user', :locale => 'en') }
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
## Pages ##
|
|
||||||
Factory.define :page do |p|
|
|
||||||
p.title 'Home page'
|
|
||||||
p.slug 'index'
|
|
||||||
p.published true
|
|
||||||
p.site { Site.where(:subdomain => "acme").first || Factory(:site) }
|
|
||||||
end
|
|
||||||
|
|
||||||
Factory.define :sub_page, :parent => :page do |p|
|
|
||||||
p.title 'Subpage'
|
|
||||||
p.slug 'subpage'
|
|
||||||
p.published true
|
|
||||||
p.site { Site.where(:subdomain => "acme").first || Factory(:site) }
|
|
||||||
p.parent { Page.where(:slug => "index").first || Factory(:page) }
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
## Snippets ##
|
|
||||||
Factory.define :snippet do |s|
|
|
||||||
s.name 'My website title'
|
|
||||||
s.slug 'header'
|
|
||||||
s.template %{<title>Acme</title>}
|
|
||||||
s.site { Site.where(:subdomain => "acme").first || Factory(:site) }
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
## Assets ##
|
|
||||||
Factory.define :asset do |a|
|
|
||||||
a.site { Site.where(:subdomain => "acme").first || Factory(:site) }
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
## Theme assets ##
|
|
||||||
Factory.define :theme_asset do |a|
|
|
||||||
a.site { Site.where(:subdomain => "acme").first || Factory(:site) }
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
## Content types ##
|
|
||||||
Factory.define :content_type do |t|
|
|
||||||
t.name 'My project'
|
|
||||||
t.site { Site.where(:subdomain => "acme").first || Factory(:site) }
|
|
||||||
end
|
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ describe 'Bushido support' do
|
|||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
configure_locomotive_with_bushido
|
configure_locomotive_with_bushido
|
||||||
@site = Factory.build('test site')
|
@site = FactoryGirl.build('test site')
|
||||||
@account = @site.memberships.first.account
|
@account = @site.memberships.first.account
|
||||||
Account.stubs(:first).returns(@account)
|
Account.stubs(:first).returns(@account)
|
||||||
end
|
end
|
||||||
@ -83,7 +83,7 @@ describe 'Bushido support' do
|
|||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
configure_locomotive_with_bushido
|
configure_locomotive_with_bushido
|
||||||
@site = Factory.build('valid site')
|
@site = FactoryGirl.build('valid site')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calls add_bushido_domains after saving a site' do
|
it 'calls add_bushido_domains after saving a site' do
|
||||||
|
@ -5,7 +5,7 @@ describe Locomotive::Export do
|
|||||||
context '#content_type' do
|
context '#content_type' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
site = Factory.build('another site')
|
site = FactoryGirl.build('another site')
|
||||||
Site.stubs(:find).returns(site)
|
Site.stubs(:find).returns(site)
|
||||||
project_type = build_project_type(site)
|
project_type = build_project_type(site)
|
||||||
project_type.contents.build(:title => 'Project #1', :description => 'Lorem ipsum', :active => true)
|
project_type.contents.build(:title => 'Project #1', :description => 'Lorem ipsum', :active => true)
|
||||||
@ -39,7 +39,7 @@ describe Locomotive::Export do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def build_project_type(site)
|
def build_project_type(site)
|
||||||
Factory.build(:content_type, :site => site, :highlighted_field_name => 'custom_field_1').tap do |content_type|
|
FactoryGirl.build(:content_type, :site => site, :highlighted_field_name => 'custom_field_1').tap do |content_type|
|
||||||
content_type.content_custom_fields.build :label => 'Title', :_alias => 'title', :kind => 'string'
|
content_type.content_custom_fields.build :label => 'Title', :_alias => 'title', :kind => 'string'
|
||||||
content_type.content_custom_fields.build :label => 'My Description', :_alias => 'description', :kind => 'text'
|
content_type.content_custom_fields.build :label => 'My Description', :_alias => 'description', :kind => 'text'
|
||||||
content_type.content_custom_fields.build :label => 'Active', :kind => 'boolean'
|
content_type.content_custom_fields.build :label => 'Active', :kind => 'boolean'
|
||||||
@ -49,7 +49,7 @@ describe Locomotive::Export do
|
|||||||
def build_team_type(site, project_type)
|
def build_team_type(site, project_type)
|
||||||
Object.send(:remove_const, 'TestProject') rescue nil
|
Object.send(:remove_const, 'TestProject') rescue nil
|
||||||
klass = Object.const_set('TestProject', Class.new { def self.embedded?; false; end })
|
klass = Object.const_set('TestProject', Class.new { def self.embedded?; false; end })
|
||||||
content_type = Factory.build(:content_type, :site => site, :name => 'team', :highlighted_field_name => 'custom_field_1')
|
content_type = FactoryGirl.build(:content_type, :site => site, :name => 'team', :highlighted_field_name => 'custom_field_1')
|
||||||
content_type.content_custom_fields.build :label => 'Name', :_alias => 'name', :kind => 'string'
|
content_type.content_custom_fields.build :label => 'Name', :_alias => 'name', :kind => 'string'
|
||||||
content_type.content_custom_fields.build :label => 'Projects', :kind => 'has_many', :_alias => 'projects', :target => 'TestProject'
|
content_type.content_custom_fields.build :label => 'Projects', :kind => 'has_many', :_alias => 'projects', :target => 'TestProject'
|
||||||
content_type.content_custom_fields.build :label => 'Bio', :_alias => 'bio', :kind => 'text'
|
content_type.content_custom_fields.build :label => 'Bio', :_alias => 'bio', :kind => 'text'
|
||||||
@ -62,7 +62,7 @@ describe Locomotive::Export do
|
|||||||
context '#zipfile' do
|
context '#zipfile' do
|
||||||
|
|
||||||
before(:all) do
|
before(:all) do
|
||||||
@site = Factory('another site')
|
@site = FactoryGirl.create('another site')
|
||||||
|
|
||||||
# first import a brand new site
|
# first import a brand new site
|
||||||
self.import_it
|
self.import_it
|
||||||
|
@ -95,9 +95,7 @@ describe 'Heroku support' do
|
|||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
configure_locomotive_with_heroku
|
configure_locomotive_with_heroku
|
||||||
# (@site = Factory.stub(:site)).stubs(:valid?).returns(true)
|
@site = FactoryGirl.build('valid site')
|
||||||
@site = Factory.build('valid site')
|
|
||||||
# (@site = Site.new(:name => 'foobar', :subdomain => 'acme')).stubs(:valid?).returns(true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calls add_heroku_domains after saving a site' do
|
it 'calls add_heroku_domains after saving a site' do
|
||||||
|
@ -2,15 +2,10 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe Locomotive::Import::Job do
|
describe Locomotive::Import::Job do
|
||||||
|
|
||||||
# before(:all) do
|
|
||||||
# # Site.destroy_all
|
|
||||||
# # Locomotive.configure_for_test(true)
|
|
||||||
# end
|
|
||||||
|
|
||||||
context 'when successful' do
|
context 'when successful' do
|
||||||
|
|
||||||
before(:all) do
|
before(:all) do
|
||||||
@site = Factory(:site)
|
@site = FactoryGirl.create(:site)
|
||||||
|
|
||||||
job = Locomotive::Import::Job.new(FixturedTheme.duplicate_and_open('default.zip'), @site, { :samples => true, :reset => true })
|
job = Locomotive::Import::Job.new(FixturedTheme.duplicate_and_open('default.zip'), @site, { :samples => true, :reset => true })
|
||||||
job.perform
|
job.perform
|
||||||
@ -115,7 +110,7 @@ describe Locomotive::Import::Job do
|
|||||||
|
|
||||||
context 'with an existing site' do
|
context 'with an existing site' do
|
||||||
before(:all) do
|
before(:all) do
|
||||||
@site = Factory("existing site")
|
@site = FactoryGirl.create('existing site')
|
||||||
|
|
||||||
job = Locomotive::Import::Job.new(FixturedTheme.duplicate_and_open('default.zip'), @site, { :samples => true, :reset => false })
|
job = Locomotive::Import::Job.new(FixturedTheme.duplicate_and_open('default.zip'), @site, { :samples => true, :reset => false })
|
||||||
job.perform
|
job.perform
|
||||||
|
@ -3,8 +3,8 @@ require 'spec_helper'
|
|||||||
describe Locomotive::Liquid::Drops::Content do
|
describe Locomotive::Liquid::Drops::Content do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@site = Factory.build(:site)
|
@site = FactoryGirl.build(:site)
|
||||||
content_type = Factory.build(:content_type)
|
content_type = FactoryGirl.build(:content_type)
|
||||||
content_type.content_custom_fields.build :label => 'anything', :kind => 'string'
|
content_type.content_custom_fields.build :label => 'anything', :kind => 'string'
|
||||||
content_type.content_custom_fields.build :label => 'published_at', :kind => 'date'
|
content_type.content_custom_fields.build :label => 'published_at', :kind => 'date'
|
||||||
@content = content_type.contents.build({
|
@content = content_type.contents.build({
|
||||||
|
@ -6,8 +6,8 @@ describe Locomotive::Liquid::Drops::Contents do
|
|||||||
# Reload the file (needed for spork)
|
# Reload the file (needed for spork)
|
||||||
load File.join(Rails.root, 'lib', 'locomotive', 'liquid', 'drops', 'contents.rb')
|
load File.join(Rails.root, 'lib', 'locomotive', 'liquid', 'drops', 'contents.rb')
|
||||||
|
|
||||||
@site = Factory.build(:site)
|
@site = FactoryGirl.build(:site)
|
||||||
@content_type = Factory.build(:content_type, :site => @site, :slug => 'projects')
|
@content_type = FactoryGirl.build(:content_type, :site => @site, :slug => 'projects')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'retrieves a content type from a slug' do
|
it 'retrieves a content type from a slug' do
|
||||||
|
@ -3,8 +3,8 @@ require 'spec_helper'
|
|||||||
describe Locomotive::Liquid::Drops::Page do
|
describe Locomotive::Liquid::Drops::Page do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
site = Factory.build(:site)
|
site = FactoryGirl.build(:site)
|
||||||
@home = Factory.build(:page, :site => site, :meta_keywords => 'Libidinous, Angsty', :meta_description => "Quite the combination.")
|
@home = FactoryGirl.build(:page, :site => site, :meta_keywords => 'Libidinous, Angsty', :meta_description => "Quite the combination.")
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#rendering tree' do
|
context '#rendering tree' do
|
||||||
@ -43,7 +43,7 @@ describe Locomotive::Liquid::Drops::Page do
|
|||||||
|
|
||||||
context '#parent' do
|
context '#parent' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@sub_page = Factory.build(:sub_page, :meta_keywords => 'Sub Libidinous, Angsty', :meta_description => "Sub Quite the combination.")
|
@sub_page = FactoryGirl.build(:sub_page, :meta_keywords => 'Sub Libidinous, Angsty', :meta_description => "Sub Quite the combination.")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders title of parent page' do
|
it 'renders title of parent page' do
|
||||||
@ -55,7 +55,7 @@ describe Locomotive::Liquid::Drops::Page do
|
|||||||
|
|
||||||
context '#breadcrumbs' do
|
context '#breadcrumbs' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@sub_page = Factory.build(:sub_page, :meta_keywords => 'Sub Libidinous, Angsty', :meta_description => "Sub Quite the combination.")
|
@sub_page = FactoryGirl.build(:sub_page, :meta_keywords => 'Sub Libidinous, Angsty', :meta_description => "Sub Quite the combination.")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders breadcrumbs of current page' do
|
it 'renders breadcrumbs of current page' do
|
||||||
@ -71,7 +71,7 @@ describe Locomotive::Liquid::Drops::Page do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'renders the content instance highlighted field instead for a templatized page' do
|
it 'renders the content instance highlighted field instead for a templatized page' do
|
||||||
templatized = Factory.build(:page, :title => 'Lorem ipsum template', :templatized => true)
|
templatized = FactoryGirl.build(:page, :title => 'Lorem ipsum template', :templatized => true)
|
||||||
|
|
||||||
content_instance = Locomotive::Liquid::Drops::Content.new(mock('content_instance', :highlighted_field_value => 'Locomotive rocks !'))
|
content_instance = Locomotive::Liquid::Drops::Content.new(mock('content_instance', :highlighted_field_value => 'Locomotive rocks !'))
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@ require 'spec_helper'
|
|||||||
describe Locomotive::Liquid::Drops::Site do
|
describe Locomotive::Liquid::Drops::Site do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@site = Factory.build(:site)
|
@site = FactoryGirl.build(:site)
|
||||||
page_1 = Factory.build(:page, :site => @site)
|
page_1 = FactoryGirl.build(:page, :site => @site)
|
||||||
page_2 = Factory.build(:page, :site => @site, :title => 'About us', :slug => 'about_us')
|
page_2 = FactoryGirl.build(:page, :site => @site, :title => 'About us', :slug => 'about_us')
|
||||||
@site.stubs(:pages).returns([page_1, page_2])
|
@site.stubs(:pages).returns([page_1, page_2])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ describe Locomotive::Liquid::Filters::Html do
|
|||||||
klass = Class.new
|
klass = Class.new
|
||||||
klass.class_eval do
|
klass.class_eval do
|
||||||
def registers
|
def registers
|
||||||
{ :site => Factory.build(:site, :id => fake_bson_id(42)) }
|
{ :site => FactoryGirl.build(:site, :id => fake_bson_id(42)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def fake_bson_id(id)
|
def fake_bson_id(id)
|
||||||
|
@ -3,10 +3,10 @@ require 'spec_helper'
|
|||||||
describe Locomotive::Liquid::Filters::Resize do
|
describe Locomotive::Liquid::Filters::Resize do
|
||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@site = Factory.create(:site)
|
@site = FactoryGirl.create(:site)
|
||||||
@theme_asset = Factory.create(:theme_asset, :source => FixturedAsset.open('5k.png'), :site => @site)
|
@theme_asset = FactoryGirl.create(:theme_asset, :source => FixturedAsset.open('5k.png'), :site => @site)
|
||||||
@theme_asset_path = "/sites/#{@theme_asset.site_id}/theme/images/5k.png"
|
@theme_asset_path = "/sites/#{@theme_asset.site_id}/theme/images/5k.png"
|
||||||
@asset = Factory.create(:asset, :source => FixturedAsset.open('5k.png'), :site => @site)
|
@asset = FactoryGirl.create(:asset, :source => FixturedAsset.open('5k.png'), :site => @site)
|
||||||
@asset_url = @asset.source.url
|
@asset_url = @asset.source.url
|
||||||
@asset_path = "/sites/#{@asset.site_id}/assets/#{@asset.id}/5k.png"
|
@asset_path = "/sites/#{@asset.site_id}/assets/#{@asset.id}/5k.png"
|
||||||
@context = Liquid::Context.new( { }, { 'asset_url' => @asset_url, 'theme_asset' => @theme_asset.to_liquid }, { :site => @site })
|
@context = Liquid::Context.new( { }, { 'asset_url' => @asset_url, 'theme_asset' => @theme_asset.to_liquid }, { :site => @site })
|
||||||
|
@ -27,8 +27,8 @@ describe Locomotive::Liquid::Tags::Editable::Content do
|
|||||||
context 'inheriting from a parent' do
|
context 'inheriting from a parent' do
|
||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@parent = Factory.build(:page)
|
@parent = FactoryGirl.build(:page)
|
||||||
@child = Factory.build(:page)
|
@child = FactoryGirl.build(:page)
|
||||||
|
|
||||||
@child.stubs(:parent).returns(@parent)
|
@child.stubs(:parent).returns(@parent)
|
||||||
end
|
end
|
||||||
@ -58,7 +58,7 @@ describe Locomotive::Liquid::Tags::Editable::Content do
|
|||||||
context 'reading from the same page' do
|
context 'reading from the same page' do
|
||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@page = Factory.build(:page)
|
@page = FactoryGirl.build(:page)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return the previously defined field' do
|
it 'should return the previously defined field' do
|
||||||
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||||||
describe Locomotive::Liquid::Tags::Nav do
|
describe Locomotive::Liquid::Tags::Nav do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@home = Factory.build(:page)
|
@home = FactoryGirl.build(:page)
|
||||||
home_children = [
|
home_children = [
|
||||||
Page.new(:title => 'Child #1', :fullpath => 'child_1', :slug => 'child_1', :published => true),
|
Page.new(:title => 'Child #1', :fullpath => 'child_1', :slug => 'child_1', :published => true),
|
||||||
Page.new(:title => 'Child #2', :fullpath => 'child_2', :slug => 'child_2', :published => true)
|
Page.new(:title => 'Child #2', :fullpath => 'child_2', :slug => 'child_2', :published => true)
|
||||||
@ -24,7 +24,7 @@ describe Locomotive::Liquid::Tags::Nav do
|
|||||||
pages = [@home]
|
pages = [@home]
|
||||||
pages.stubs(:root).returns(pages)
|
pages.stubs(:root).returns(pages)
|
||||||
pages.stubs(:minimal_attributes).returns(pages) # iso
|
pages.stubs(:minimal_attributes).returns(pages) # iso
|
||||||
@site = Factory.build(:site)
|
@site = FactoryGirl.build(:site)
|
||||||
@site.stubs(:pages).returns(pages)
|
@site.stubs(:pages).returns(pages)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ describe Locomotive::Liquid::Tags::Paginate do
|
|||||||
'projects' => options.has_key?(:collection) ? options[:collection] : PaginatedCollection.new(['Ruby on Rails', 'jQuery', 'mongodb', 'Liquid', 'sqlite3']),
|
'projects' => options.has_key?(:collection) ? options[:collection] : PaginatedCollection.new(['Ruby on Rails', 'jQuery', 'mongodb', 'Liquid', 'sqlite3']),
|
||||||
'current_page' => options[:page] || 1
|
'current_page' => options[:page] || 1
|
||||||
}, {
|
}, {
|
||||||
:page => Factory.build(:page)
|
:page => FactoryGirl.build(:page)
|
||||||
}, true)
|
}, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||||||
describe Locomotive::Liquid::Tags::SEO do
|
describe Locomotive::Liquid::Tags::SEO do
|
||||||
|
|
||||||
let(:site) do
|
let(:site) do
|
||||||
Factory.build(:site, :seo_title => 'Site title (SEO)', :meta_description => 'A short site description', :meta_keywords => 'test only cat dog')
|
FactoryGirl.build(:site, :seo_title => 'Site title (SEO)', :meta_description => 'A short site description', :meta_keywords => 'test only cat dog')
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'rendering' do
|
describe 'rendering' do
|
||||||
@ -80,7 +80,7 @@ describe Locomotive::Liquid::Tags::SEO do
|
|||||||
context "when content instance" do
|
context "when content instance" do
|
||||||
|
|
||||||
let(:content_type) do
|
let(:content_type) do
|
||||||
Factory.build(:content_type, :site => site).tap do |ct|
|
FactoryGirl.build(:content_type, :site => site).tap do |ct|
|
||||||
ct.content_custom_fields.build :label => 'anything', :kind => 'String'
|
ct.content_custom_fields.build :label => 'anything', :kind => 'String'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -6,10 +6,10 @@ describe 'Locomotive rendering system' do
|
|||||||
before(:each) do
|
before(:each) do
|
||||||
@controller = Locomotive::TestController.new
|
@controller = Locomotive::TestController.new
|
||||||
Site.any_instance.stubs(:create_default_pages!).returns(true)
|
Site.any_instance.stubs(:create_default_pages!).returns(true)
|
||||||
@site = Factory.build(:site)
|
@site = FactoryGirl.build(:site)
|
||||||
Site.stubs(:find).returns(@site)
|
Site.stubs(:find).returns(@site)
|
||||||
@controller.current_site = @site
|
@controller.current_site = @site
|
||||||
@page = Factory.build(:page, :site => nil, :published => true)
|
@page = FactoryGirl.build(:page, :site => nil, :published => true)
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#liquid_context' do
|
context '#liquid_context' do
|
||||||
@ -125,7 +125,7 @@ describe 'Locomotive rendering system' do
|
|||||||
context 'templatized page' do
|
context 'templatized page' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@content_type = Factory.build(:content_type, :site => nil)
|
@content_type = FactoryGirl.build(:content_type, :site => nil)
|
||||||
@content = @content_type.contents.build(:_visible => true)
|
@content = @content_type.contents.build(:_visible => true)
|
||||||
@page.templatized = true
|
@page.templatized = true
|
||||||
@page.content_type = @content_type
|
@page.content_type = @content_type
|
||||||
|
@ -26,7 +26,7 @@ describe Locomotive::Routing::SiteDispatcher do
|
|||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@request = Object.new
|
@request = Object.new
|
||||||
@site = Factory.build(:site)
|
@site = FactoryGirl.build(:site)
|
||||||
|
|
||||||
@controller.stubs(:request).returns(@request)
|
@controller.stubs(:request).returns(@request)
|
||||||
@request.stubs(:host).returns('host')
|
@request.stubs(:host).returns('host')
|
||||||
@ -48,7 +48,7 @@ describe Locomotive::Routing::SiteDispatcher do
|
|||||||
describe '#current_site' do
|
describe '#current_site' do
|
||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@site = Factory.build(:site)
|
@site = FactoryGirl.build(:site)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns the current site instance if available' do
|
it 'returns the current site instance if available' do
|
||||||
@ -157,8 +157,8 @@ describe Locomotive::Routing::SiteDispatcher do
|
|||||||
describe '#validate_site_membership' do
|
describe '#validate_site_membership' do
|
||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@account = Factory.build(:account)
|
@account = FactoryGirl.build(:account)
|
||||||
@site = Factory.build(:site)
|
@site = FactoryGirl.build(:site)
|
||||||
@request = ActionDispatch::Request.new({})
|
@request = ActionDispatch::Request.new({})
|
||||||
|
|
||||||
@controller.instance_variable_set('@_response', ActionDispatch::Response.new)
|
@controller.instance_variable_set('@_response', ActionDispatch::Response.new)
|
||||||
|
@ -3,12 +3,12 @@ require 'spec_helper'
|
|||||||
describe Ability do
|
describe Ability do
|
||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@site = Factory(:site)
|
@site = FactoryGirl.create(:site)
|
||||||
@account = Factory(:account)
|
@account = FactoryGirl.create(:account)
|
||||||
|
|
||||||
@admin = Factory(:membership, :account => Factory.stub(:account), :site => Factory.stub(:site))
|
@admin = FactoryGirl.create(:membership, :account => FactoryGirl.build(:account), :site => FactoryGirl.build(:site))
|
||||||
@designer = Factory(:membership, :account => Factory.stub(:account), :site => @site, :role => %(designer))
|
@designer = FactoryGirl.create(:membership, :account => FactoryGirl.build(:account), :site => @site, :role => %(designer))
|
||||||
@author = Factory(:membership, :account => Factory.stub(:account), :site => @site, :role => %(author))
|
@author = FactoryGirl.create(:membership, :account => FactoryGirl.build(:account), :site => @site, :role => %(author))
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'pages' do
|
context 'pages' do
|
||||||
|
@ -3,14 +3,14 @@ require 'spec_helper'
|
|||||||
describe Account do
|
describe Account do
|
||||||
|
|
||||||
it 'should have a valid factory' do
|
it 'should have a valid factory' do
|
||||||
Factory.build(:account).should be_valid
|
FactoryGirl.build(:account).should be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
## Validations ##
|
## Validations ##
|
||||||
|
|
||||||
%w{name email password}.each do |attr|
|
%w{name email password}.each do |attr|
|
||||||
it "should validate presence of #{attr}" do
|
it "should validate presence of #{attr}" do
|
||||||
account = Factory.build(:account, attr.to_sym => nil)
|
account = FactoryGirl.build(:account, attr.to_sym => nil)
|
||||||
account.should_not be_valid
|
account.should_not be_valid
|
||||||
account.errors[attr.to_sym].should include("can't be blank")
|
account.errors[attr.to_sym].should include("can't be blank")
|
||||||
end
|
end
|
||||||
@ -22,26 +22,26 @@ describe Account do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "should validate uniqueness of email" do
|
it "should validate uniqueness of email" do
|
||||||
Factory(:account)
|
FactoryGirl.create(:account)
|
||||||
(account = Factory.build(:account)).should_not be_valid
|
(account = FactoryGirl.build(:account)).should_not be_valid
|
||||||
account.errors[:email].should == ["is already taken"]
|
account.errors[:email].should == ["is already taken"]
|
||||||
end
|
end
|
||||||
|
|
||||||
## Associations ##
|
## Associations ##
|
||||||
|
|
||||||
it 'should own many sites' do
|
it 'should own many sites' do
|
||||||
account = Factory(:account)
|
account = FactoryGirl.create(:account)
|
||||||
site_1 = Factory(:site, :memberships => [Membership.new(:account => account)])
|
site_1 = FactoryGirl.create(:site, :memberships => [Membership.new(:account => account)])
|
||||||
site_2 = Factory(:site, :subdomain => 'foo', :memberships => [Membership.new(:account => account)])
|
site_2 = FactoryGirl.create(:site, :subdomain => 'foo', :memberships => [Membership.new(:account => account)])
|
||||||
account.reload.sites.to_a.should == [site_1, site_2]
|
account.reload.sites.to_a.should == [site_1, site_2]
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'deleting' do
|
describe 'deleting' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@account = Factory.build(:account)
|
@account = FactoryGirl.build(:account)
|
||||||
@site_1 = Factory.build(:site, :subdomain => 'foo', :memberships => [Factory.build(:membership, :account => @account)])
|
@site_1 = FactoryGirl.build(:site, :subdomain => 'foo', :memberships => [FactoryGirl.build(:membership, :account => @account)])
|
||||||
@site_2 = Factory.build(:site, :subdomain => 'bar', :memberships => [Factory.build(:membership, :account => @account)])
|
@site_2 = FactoryGirl.build(:site, :subdomain => 'bar', :memberships => [FactoryGirl.build(:membership, :account => @account)])
|
||||||
@account.stubs(:sites).returns([@site_1, @site_2])
|
@account.stubs(:sites).returns([@site_1, @site_2])
|
||||||
Site.any_instance.stubs(:save).returns(true)
|
Site.any_instance.stubs(:save).returns(true)
|
||||||
end
|
end
|
||||||
@ -65,7 +65,7 @@ describe Account do
|
|||||||
describe 'cross domain authentication' do
|
describe 'cross domain authentication' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@account = Factory.build(:account)
|
@account = FactoryGirl.build(:account)
|
||||||
@account.stubs(:save).returns(true)
|
@account.stubs(:save).returns(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ describe Asset do
|
|||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
Asset.any_instance.stubs(:site_id).returns('test')
|
Asset.any_instance.stubs(:site_id).returns('test')
|
||||||
@asset = Factory.build(:asset)
|
@asset = FactoryGirl.build(:asset)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should process picture' do
|
it 'should process picture' do
|
||||||
@ -28,7 +28,7 @@ describe Asset do
|
|||||||
describe 'vignette' do
|
describe 'vignette' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@asset = Factory.build(:asset, :source => FixturedAsset.open('5k.png'))
|
@asset = FactoryGirl.build(:asset, :source => FixturedAsset.open('5k.png'))
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not resize image smaller than 50x50' do
|
it 'does not resize image smaller than 50x50' do
|
||||||
|
@ -6,7 +6,7 @@ describe ContentInstance do
|
|||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
Site.any_instance.stubs(:create_default_pages!).returns(true)
|
Site.any_instance.stubs(:create_default_pages!).returns(true)
|
||||||
@content_type = Factory.build(:content_type)
|
@content_type = FactoryGirl.build(:content_type)
|
||||||
@content_type.content_custom_fields.build :label => 'Title', :kind => 'String'
|
@content_type.content_custom_fields.build :label => 'Title', :kind => 'String'
|
||||||
@content_type.content_custom_fields.build :label => 'Description', :kind => 'Text'
|
@content_type.content_custom_fields.build :label => 'Description', :kind => 'Text'
|
||||||
@content_type.content_custom_fields.build :label => 'Visible ?', :kind => 'Text', :_alias => 'visible'
|
@content_type.content_custom_fields.build :label => 'Visible ?', :kind => 'Text', :_alias => 'visible'
|
||||||
@ -111,8 +111,8 @@ describe ContentInstance do
|
|||||||
describe '#api' do
|
describe '#api' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@account_1 = Factory.build('admin user', :id => fake_bson_id('1'))
|
@account_1 = FactoryGirl.build('admin user', :id => fake_bson_id('1'))
|
||||||
@account_2 = Factory.build('frenchy user', :id => fake_bson_id('2'))
|
@account_2 = FactoryGirl.build('frenchy user', :id => fake_bson_id('2'))
|
||||||
|
|
||||||
@content_type.api_enabled = true
|
@content_type.api_enabled = true
|
||||||
@content_type.api_accounts = ['', @account_1.id, @account_2.id]
|
@content_type.api_accounts = ['', @account_1.id, @account_2.id]
|
||||||
|
@ -9,7 +9,7 @@ describe ContentType do
|
|||||||
context 'when validating' do
|
context 'when validating' do
|
||||||
|
|
||||||
it 'should have a valid factory' do
|
it 'should have a valid factory' do
|
||||||
content_type = Factory.build(:content_type)
|
content_type = FactoryGirl.build(:content_type)
|
||||||
content_type.content_custom_fields.build :label => 'anything', :kind => 'String'
|
content_type.content_custom_fields.build :label => 'anything', :kind => 'String'
|
||||||
content_type.should be_valid
|
content_type.should be_valid
|
||||||
end
|
end
|
||||||
@ -18,35 +18,35 @@ describe ContentType do
|
|||||||
|
|
||||||
%w{site name}.each do |field|
|
%w{site name}.each do |field|
|
||||||
it "requires the presence of #{field}" do
|
it "requires the presence of #{field}" do
|
||||||
content_type = Factory.build(:content_type, field.to_sym => nil)
|
content_type = FactoryGirl.build(:content_type, field.to_sym => nil)
|
||||||
content_type.should_not be_valid
|
content_type.should_not be_valid
|
||||||
content_type.errors[field.to_sym].should == ["can't be blank"]
|
content_type.errors[field.to_sym].should == ["can't be blank"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'requires the presence of slug' do
|
it 'requires the presence of slug' do
|
||||||
content_type = Factory.build(:content_type, :name => nil, :slug => nil)
|
content_type = FactoryGirl.build(:content_type, :name => nil, :slug => nil)
|
||||||
content_type.should_not be_valid
|
content_type.should_not be_valid
|
||||||
content_type.errors[:slug].should == ["can't be blank"]
|
content_type.errors[:slug].should == ["can't be blank"]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is not valid if slug is not unique' do
|
it 'is not valid if slug is not unique' do
|
||||||
content_type = Factory.build(:content_type)
|
content_type = FactoryGirl.build(:content_type)
|
||||||
content_type.content_custom_fields.build :label => 'anything', :kind => 'String'
|
content_type.content_custom_fields.build :label => 'anything', :kind => 'String'
|
||||||
content_type.save
|
content_type.save
|
||||||
(content_type = Factory.build(:content_type, :site => content_type.site)).should_not be_valid
|
(content_type = FactoryGirl.build(:content_type, :site => content_type.site)).should_not be_valid
|
||||||
content_type.errors[:slug].should == ["is already taken"]
|
content_type.errors[:slug].should == ["is already taken"]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is not valid if there is not at least one field' do
|
it 'is not valid if there is not at least one field' do
|
||||||
content_type = Factory.build(:content_type)
|
content_type = FactoryGirl.build(:content_type)
|
||||||
content_type.should_not be_valid
|
content_type.should_not be_valid
|
||||||
content_type.errors[:content_custom_fields].should == ["is too small (minimum element number is 1)"]
|
content_type.errors[:content_custom_fields].should == ["is too small (minimum element number is 1)"]
|
||||||
end
|
end
|
||||||
|
|
||||||
%w(created_at updated_at).each do |_alias|
|
%w(created_at updated_at).each do |_alias|
|
||||||
it "does not allow #{_alias} as alias" do
|
it "does not allow #{_alias} as alias" do
|
||||||
content_type = Factory.build(:content_type)
|
content_type = FactoryGirl.build(:content_type)
|
||||||
field = content_type.content_custom_fields.build :label => 'anything', :kind => 'String', :_alias => _alias
|
field = content_type.content_custom_fields.build :label => 'anything', :kind => 'String', :_alias => _alias
|
||||||
field.valid?.should be_false
|
field.valid?.should be_false
|
||||||
field.errors[:_alias].should == ['is reserved']
|
field.errors[:_alias].should == ['is reserved']
|
||||||
@ -58,7 +58,7 @@ describe ContentType do
|
|||||||
context '#ordered_contents' do
|
context '#ordered_contents' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@content_type = Factory.build(:content_type, :order_by => 'created_at')
|
@content_type = FactoryGirl.build(:content_type, :order_by => 'created_at')
|
||||||
@content_1 = stub('content_1', :name => 'Did', :_position_in_list => 2)
|
@content_1 = stub('content_1', :name => 'Did', :_position_in_list => 2)
|
||||||
@content_2 = stub('content_2', :name => 'Sacha', :_position_in_list => 1)
|
@content_2 = stub('content_2', :name => 'Sacha', :_position_in_list => 1)
|
||||||
@content_type.stubs(:contents).returns([@content_1, @content_2])
|
@content_type.stubs(:contents).returns([@content_1, @content_2])
|
||||||
@ -95,9 +95,9 @@ describe ContentType do
|
|||||||
describe 'custom fields' do
|
describe 'custom fields' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
site = Factory.build(:site)
|
site = FactoryGirl.build(:site)
|
||||||
Site.stubs(:find).returns(site)
|
Site.stubs(:find).returns(site)
|
||||||
@content_type = Factory.build(:content_type, :site => site, :highlighted_field_name => 'custom_field_1')
|
@content_type = FactoryGirl.build(:content_type, :site => site, :highlighted_field_name => 'custom_field_1')
|
||||||
@content_type.content_custom_fields.build :label => 'My Description', :_alias => 'description', :kind => 'text'
|
@content_type.content_custom_fields.build :label => 'My Description', :_alias => 'description', :kind => 'text'
|
||||||
@content_type.content_custom_fields.build :label => 'Active', :kind => 'boolean'
|
@content_type.content_custom_fields.build :label => 'Active', :kind => 'boolean'
|
||||||
# ContentType.logger = Logger.new($stdout)
|
# ContentType.logger = Logger.new($stdout)
|
||||||
|
@ -3,14 +3,14 @@ require 'spec_helper'
|
|||||||
describe EditableElement do
|
describe EditableElement do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@site = Factory(:site)
|
@site = FactoryGirl.create(:site)
|
||||||
@home = @site.pages.root.first
|
@home = @site.pages.root.first
|
||||||
@home.update_attributes :raw_template => "{% block body %}{% editable_short_text 'body' %}Lorem ipsum{% endeditable_short_text %}{% endblock %}"
|
@home.update_attributes :raw_template => "{% block body %}{% editable_short_text 'body' %}Lorem ipsum{% endeditable_short_text %}{% endblock %}"
|
||||||
|
|
||||||
@sub_page_1 = Factory(:page, :slug => 'sub_page_1', :parent => @home, :raw_template => "{% extends 'parent' %}")
|
@sub_page_1 = FactoryGirl.create(:page, :slug => 'sub_page_1', :parent => @home, :raw_template => "{% extends 'parent' %}")
|
||||||
@sub_page_2 = Factory(:page, :slug => 'sub_page_2', :parent => @home, :raw_template => "{% extends 'parent' %}")
|
@sub_page_2 = FactoryGirl.create(:page, :slug => 'sub_page_2', :parent => @home, :raw_template => "{% extends 'parent' %}")
|
||||||
|
|
||||||
@sub_page_1_1 = Factory(:page, :slug => 'sub_page_1_1', :parent => @sub_page_1, :raw_template => "{% extends 'parent' %}")
|
@sub_page_1_1 = FactoryGirl.create(:page, :slug => 'sub_page_1_1', :parent => @sub_page_1, :raw_template => "{% extends 'parent' %}")
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'in sub pages level #1' do
|
context 'in sub pages level #1' do
|
||||||
|
@ -3,19 +3,19 @@ require 'spec_helper'
|
|||||||
describe Membership do
|
describe Membership do
|
||||||
|
|
||||||
it 'should have a valid factory' do
|
it 'should have a valid factory' do
|
||||||
Factory.build(:membership, :account => Factory.build(:account)).should be_valid
|
FactoryGirl.build(:membership, :account => FactoryGirl.build(:account)).should be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should validate presence of account' do
|
it 'should validate presence of account' do
|
||||||
membership = Factory.build(:membership, :account => nil)
|
membership = FactoryGirl.build(:membership, :account => nil)
|
||||||
membership.should_not be_valid
|
membership.should_not be_valid
|
||||||
membership.errors[:account].should == ["can't be blank"]
|
membership.errors[:account].should == ["can't be blank"]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should assign account from email' do
|
it 'should assign account from email' do
|
||||||
Account.stubs(:where).returns([Factory.build(:account)])
|
Account.stubs(:where).returns([FactoryGirl.build(:account)])
|
||||||
Account.stubs(:find).returns(Factory.build(:account))
|
Account.stubs(:find).returns(FactoryGirl.build(:account))
|
||||||
membership = Factory.build(:membership, :account => nil)
|
membership = FactoryGirl.build(:membership, :account => nil)
|
||||||
membership.email = 'bart@simpson.net'
|
membership.email = 'bart@simpson.net'
|
||||||
membership.account.should_not be_nil
|
membership.account.should_not be_nil
|
||||||
membership.account.name.should == 'Bart Simpson'
|
membership.account.name.should == 'Bart Simpson'
|
||||||
@ -24,8 +24,8 @@ describe Membership do
|
|||||||
describe 'next action to take' do
|
describe 'next action to take' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@membership = Factory.build(:membership, :site => Factory.build(:site))
|
@membership = FactoryGirl.build(:membership, :site => FactoryGirl.build(:site))
|
||||||
@account = Factory.build(:account)
|
@account = FactoryGirl.build(:account)
|
||||||
@account.stubs(:save).returns(true)
|
@account.stubs(:save).returns(true)
|
||||||
Account.stubs(:where).returns([@account])
|
Account.stubs(:where).returns([@account])
|
||||||
Account.stubs(:find).returns(@account)
|
Account.stubs(:find).returns(@account)
|
||||||
@ -53,7 +53,7 @@ describe Membership do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def build_membership(account = nil)
|
def build_membership(account = nil)
|
||||||
Factory.build(:membership, :site => Factory.build(:site), :account => account || Factory.build(:account))
|
FactoryGirl.build(:membership, :site => FactoryGirl.build(:site), :account => account || FactoryGirl.build(:account))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -10,36 +10,36 @@ describe Page do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'should have a valid factory' do
|
it 'should have a valid factory' do
|
||||||
Factory.build(:page).should be_valid
|
FactoryGirl.build(:page).should be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
# Validations ##
|
# Validations ##
|
||||||
|
|
||||||
%w{site title}.each do |field|
|
%w{site title}.each do |field|
|
||||||
it "should validate presence of #{field}" do
|
it "should validate presence of #{field}" do
|
||||||
page = Factory.build(:page, field.to_sym => nil)
|
page = FactoryGirl.build(:page, field.to_sym => nil)
|
||||||
page.should_not be_valid
|
page.should_not be_valid
|
||||||
page.errors[field.to_sym].should == ["can't be blank"]
|
page.errors[field.to_sym].should == ["can't be blank"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should validate presence of slug' do
|
it 'should validate presence of slug' do
|
||||||
page = Factory.build(:page, :title => nil, :slug => nil)
|
page = FactoryGirl.build(:page, :title => nil, :slug => nil)
|
||||||
page.should_not be_valid
|
page.should_not be_valid
|
||||||
page.errors[:slug].should == ["can't be blank"]
|
page.errors[:slug].should == ["can't be blank"]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should validate uniqueness of slug' do
|
it 'should validate uniqueness of slug' do
|
||||||
page = Factory(:page)
|
page = FactoryGirl.create(:page)
|
||||||
(page = Factory.build(:page, :site => page.site)).should_not be_valid
|
(page = FactoryGirl.build(:page, :site => page.site)).should_not be_valid
|
||||||
page.errors[:slug].should == ["is already taken"]
|
page.errors[:slug].should == ["is already taken"]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should validate uniqueness of slug within a "folder"' do
|
it 'should validate uniqueness of slug within a "folder"' do
|
||||||
site = Factory(:site)
|
site = FactoryGirl.create(:site)
|
||||||
root = Factory(:page, :slug => 'index', :site => site)
|
root = FactoryGirl.create(:page, :slug => 'index', :site => site)
|
||||||
child_1 = Factory(:page, :slug => 'first_child', :parent => root, :site => site)
|
child_1 = FactoryGirl.create(:page, :slug => 'first_child', :parent => root, :site => site)
|
||||||
(page = Factory.build(:page, :slug => 'first_child', :parent => root, :site => site)).should_not be_valid
|
(page = FactoryGirl.build(:page, :slug => 'first_child', :parent => root, :site => site)).should_not be_valid
|
||||||
page.errors[:slug].should == ["is already taken"]
|
page.errors[:slug].should == ["is already taken"]
|
||||||
|
|
||||||
page.slug = 'index'
|
page.slug = 'index'
|
||||||
@ -48,7 +48,7 @@ describe Page do
|
|||||||
|
|
||||||
%w{admin stylesheets images javascripts}.each do |slug|
|
%w{admin stylesheets images javascripts}.each do |slug|
|
||||||
it "should consider '#{slug}' as invalid" do
|
it "should consider '#{slug}' as invalid" do
|
||||||
page = Factory.build(:page, :slug => slug)
|
page = FactoryGirl.build(:page, :slug => slug)
|
||||||
page.should_not be_valid
|
page.should_not be_valid
|
||||||
page.errors[:slug].should == ["is reserved"]
|
page.errors[:slug].should == ["is reserved"]
|
||||||
end
|
end
|
||||||
@ -63,22 +63,22 @@ describe Page do
|
|||||||
describe 'once created' do
|
describe 'once created' do
|
||||||
|
|
||||||
it 'should tell if the page is the index one' do
|
it 'should tell if the page is the index one' do
|
||||||
Factory.build(:page, :slug => 'index', :site => nil).index?.should be_true
|
FactoryGirl.build(:page, :slug => 'index', :site => nil).index?.should be_true
|
||||||
Factory.build(:page, :slug => 'index', :depth => 1, :site => nil).index?.should be_false
|
FactoryGirl.build(:page, :slug => 'index', :depth => 1, :site => nil).index?.should be_false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should have normalized slug' do
|
it 'should have normalized slug' do
|
||||||
page = Factory.build(:page, :slug => ' Valid ité.html ')
|
page = FactoryGirl.build(:page, :slug => ' Valid ité.html ')
|
||||||
page.valid?
|
page.valid?
|
||||||
page.slug.should == 'valid-ite-html'
|
page.slug.should == 'valid-ite-html'
|
||||||
|
|
||||||
page = Factory.build(:page, :title => ' Valid ité.html ', :slug => nil, :site => page.site)
|
page = FactoryGirl.build(:page, :title => ' Valid ité.html ', :slug => nil, :site => page.site)
|
||||||
page.should be_valid
|
page.should be_valid
|
||||||
page.slug.should == 'valid-ite-html'
|
page.slug.should == 'valid-ite-html'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has no cache strategy' do
|
it 'has no cache strategy' do
|
||||||
page = Factory.build(:page, :site => nil)
|
page = FactoryGirl.build(:page, :site => nil)
|
||||||
page.with_cache?.should == false
|
page.with_cache?.should == false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ describe Page do
|
|||||||
describe '#deleting' do
|
describe '#deleting' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@page = Factory.build(:page)
|
@page = FactoryGirl.build(:page)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not delete the index page' do
|
it 'does not delete the index page' do
|
||||||
@ -111,27 +111,27 @@ describe Page do
|
|||||||
describe 'acts as tree' do
|
describe 'acts as tree' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@home = Factory(:page)
|
@home = FactoryGirl.create(:page)
|
||||||
@child_1 = Factory(:page, :title => 'Subpage 1', :slug => 'foo', :parent_id => @home._id, :site => @home.site)
|
@child_1 = FactoryGirl.create(:page, :title => 'Subpage 1', :slug => 'foo', :parent_id => @home._id, :site => @home.site)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should add root elements' do
|
it 'should add root elements' do
|
||||||
page_404 = Factory(:page, :title => 'Page not found', :slug => '404', :site => @home.site)
|
page_404 = FactoryGirl.create(:page, :title => 'Page not found', :slug => '404', :site => @home.site)
|
||||||
Page.roots.count.should == 2
|
Page.roots.count.should == 2
|
||||||
Page.roots.should == [@home, page_404]
|
Page.roots.should == [@home, page_404]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should add sub pages' do
|
it 'should add sub pages' do
|
||||||
child_2 = Factory(:page, :title => 'Subpage 2', :slug => 'bar', :parent => @home, :site => @home.site)
|
child_2 = FactoryGirl.create(:page, :title => 'Subpage 2', :slug => 'bar', :parent => @home, :site => @home.site)
|
||||||
@home = Page.find(@home.id)
|
@home = Page.find(@home.id)
|
||||||
@home.children.count.should == 2
|
@home.children.count.should == 2
|
||||||
@home.children.should == [@child_1, child_2]
|
@home.children.should == [@child_1, child_2]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should move its children accordingly' do
|
it 'should move its children accordingly' do
|
||||||
sub_child_1 = Factory(:page, :title => 'Sub Subpage 1', :slug => 'bar', :parent => @child_1, :site => @home.site)
|
sub_child_1 = FactoryGirl.create(:page, :title => 'Sub Subpage 1', :slug => 'bar', :parent => @child_1, :site => @home.site)
|
||||||
archives = Factory(:page, :title => 'archives', :slug => 'archives', :parent => @home, :site => @home.site)
|
archives = FactoryGirl.create(:page, :title => 'archives', :slug => 'archives', :parent => @home, :site => @home.site)
|
||||||
posts = Factory(:page, :title => 'posts', :slug => 'posts', :parent => archives, :site => @home.site)
|
posts = FactoryGirl.create(:page, :title => 'posts', :slug => 'posts', :parent => archives, :site => @home.site)
|
||||||
|
|
||||||
@child_1.parent_id = archives._id
|
@child_1.parent_id = archives._id
|
||||||
@child_1.save
|
@child_1.save
|
||||||
@ -146,7 +146,7 @@ describe Page do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'should destroy descendants as well' do
|
it 'should destroy descendants as well' do
|
||||||
Factory(:page, :title => 'Sub Subpage 1', :slug => 'bar', :parent_id => @child_1._id, :site => @home.site)
|
FactoryGirl.create(:page, :title => 'Sub Subpage 1', :slug => 'bar', :parent_id => @child_1._id, :site => @home.site)
|
||||||
@child_1.destroy
|
@child_1.destroy
|
||||||
Page.where(:slug => 'bar').first.should be_nil
|
Page.where(:slug => 'bar').first.should be_nil
|
||||||
end
|
end
|
||||||
@ -156,10 +156,10 @@ describe Page do
|
|||||||
describe 'acts as list' do
|
describe 'acts as list' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@home = Factory(:page)
|
@home = FactoryGirl.create(:page)
|
||||||
@child_1 = Factory(:page, :title => 'Subpage 1', :slug => 'foo', :parent => @home, :site => @home.site)
|
@child_1 = FactoryGirl.create(:page, :title => 'Subpage 1', :slug => 'foo', :parent => @home, :site => @home.site)
|
||||||
@child_2 = Factory(:page, :title => 'Subpage 2', :slug => 'bar', :parent => @home, :site => @home.site)
|
@child_2 = FactoryGirl.create(:page, :title => 'Subpage 2', :slug => 'bar', :parent => @home, :site => @home.site)
|
||||||
@child_3 = Factory(:page, :title => 'Subpage 3', :slug => 'acme', :parent => @home, :site => @home.site)
|
@child_3 = FactoryGirl.create(:page, :title => 'Subpage 3', :slug => 'acme', :parent => @home, :site => @home.site)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be at the bottom of the folder once created' do
|
it 'should be at the bottom of the folder once created' do
|
||||||
@ -176,8 +176,8 @@ describe Page do
|
|||||||
describe 'templatized extension' do
|
describe 'templatized extension' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@page = Factory.build(:page, :site => nil, :templatized => true, :content_type_id => 42)
|
@page = FactoryGirl.build(:page, :site => nil, :templatized => true, :content_type_id => 42)
|
||||||
ContentType.stubs(:find).returns(Factory.build(:content_type, :site => nil))
|
ContentType.stubs(:find).returns(FactoryGirl.build(:content_type, :site => nil))
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is considered as a templatized page' do
|
it 'is considered as a templatized page' do
|
||||||
@ -198,12 +198,12 @@ describe Page do
|
|||||||
describe 'listed extension' do
|
describe 'listed extension' do
|
||||||
|
|
||||||
it 'is considered as a visible page' do
|
it 'is considered as a visible page' do
|
||||||
@page = Factory.build(:page, :site => nil, :content_type_id => 42)
|
@page = FactoryGirl.build(:page, :site => nil, :content_type_id => 42)
|
||||||
@page.listed?.should be_true
|
@page.listed?.should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is not considered as a visible page' do
|
it 'is not considered as a visible page' do
|
||||||
@page = Factory.build(:page, :site => nil, :listed => false, :content_type_id => 42)
|
@page = FactoryGirl.build(:page, :site => nil, :listed => false, :content_type_id => 42)
|
||||||
@page.listed?.should be_false
|
@page.listed?.should be_false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ describe Page do
|
|||||||
describe 'redirect extension' do
|
describe 'redirect extension' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@page = Factory.build(:page, :site => nil, :redirect=> true, :redirect_url => 'http://www.google.com/')
|
@page = FactoryGirl.build(:page, :site => nil, :redirect=> true, :redirect_url => 'http://www.google.com/')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is considered as a redirect page' do
|
it 'is considered as a redirect page' do
|
||||||
|
@ -3,61 +3,61 @@ require 'spec_helper'
|
|||||||
describe Site do
|
describe Site do
|
||||||
|
|
||||||
it 'should have a valid factory' do
|
it 'should have a valid factory' do
|
||||||
Factory.build(:site).should be_valid
|
FactoryGirl.build(:site).should be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
## Validations ##
|
## Validations ##
|
||||||
|
|
||||||
it 'should validate presence of name' do
|
it 'should validate presence of name' do
|
||||||
site = Factory.build(:site, :name => nil)
|
site = FactoryGirl.build(:site, :name => nil)
|
||||||
site.should_not be_valid
|
site.should_not be_valid
|
||||||
site.errors[:name].should == ["can't be blank"]
|
site.errors[:name].should == ["can't be blank"]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should validate presence of subdomain' do
|
it 'should validate presence of subdomain' do
|
||||||
site = Factory.build(:site, :subdomain => nil)
|
site = FactoryGirl.build(:site, :subdomain => nil)
|
||||||
site.should_not be_valid
|
site.should_not be_valid
|
||||||
site.errors[:subdomain].should == ["can't be blank"]
|
site.errors[:subdomain].should == ["can't be blank"]
|
||||||
end
|
end
|
||||||
|
|
||||||
%w{test test42 foo_bar}.each do |subdomain|
|
%w{test test42 foo_bar}.each do |subdomain|
|
||||||
it "should accept subdomain like '#{subdomain}'" do
|
it "should accept subdomain like '#{subdomain}'" do
|
||||||
Factory.build(:site, :subdomain => subdomain).should be_valid
|
FactoryGirl.build(:site, :subdomain => subdomain).should be_valid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
['-', '_test', 'test_', 't est', '42', '42test'].each do |subdomain|
|
['-', '_test', 'test_', 't est', '42', '42test'].each do |subdomain|
|
||||||
it "should not accept subdomain like '#{subdomain}'" do
|
it "should not accept subdomain like '#{subdomain}'" do
|
||||||
(site = Factory.build(:site, :subdomain => subdomain)).should_not be_valid
|
(site = FactoryGirl.build(:site, :subdomain => subdomain)).should_not be_valid
|
||||||
site.errors[:subdomain].should == ['is invalid']
|
site.errors[:subdomain].should == ['is invalid']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not use reserved keywords as subdomain" do
|
it "should not use reserved keywords as subdomain" do
|
||||||
%w{www admin email blog webmail mail support help site sites}.each do |subdomain|
|
%w{www admin email blog webmail mail support help site sites}.each do |subdomain|
|
||||||
(site = Factory.build(:site, :subdomain => subdomain)).should_not be_valid
|
(site = FactoryGirl.build(:site, :subdomain => subdomain)).should_not be_valid
|
||||||
site.errors[:subdomain].should == ['is reserved']
|
site.errors[:subdomain].should == ['is reserved']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should validate uniqueness of subdomain' do
|
it 'should validate uniqueness of subdomain' do
|
||||||
Factory(:site)
|
FactoryGirl.create(:site)
|
||||||
(site = Factory.build(:site)).should_not be_valid
|
(site = FactoryGirl.build(:site)).should_not be_valid
|
||||||
site.errors[:subdomain].should == ["is already taken"]
|
site.errors[:subdomain].should == ["is already taken"]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should validate uniqueness of domains' do
|
it 'should validate uniqueness of domains' do
|
||||||
Factory(:site, :domains => %w{www.acme.net www.acme.com})
|
FactoryGirl.create(:site, :domains => %w{www.acme.net www.acme.com})
|
||||||
|
|
||||||
(site = Factory.build(:site, :domains => %w{www.acme.com})).should_not be_valid
|
(site = FactoryGirl.build(:site, :domains => %w{www.acme.com})).should_not be_valid
|
||||||
site.errors[:domains].should == ["www.acme.com is already taken"]
|
site.errors[:domains].should == ["www.acme.com is already taken"]
|
||||||
|
|
||||||
(site = Factory.build(:site, :subdomain => 'foo', :domains => %w{acme.example.com})).should_not be_valid
|
(site = FactoryGirl.build(:site, :subdomain => 'foo', :domains => %w{acme.example.com})).should_not be_valid
|
||||||
site.errors[:domains].should == ["acme.example.com is already taken"]
|
site.errors[:domains].should == ["acme.example.com is already taken"]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should validate format of domains' do
|
it 'should validate format of domains' do
|
||||||
site = Factory.build(:site, :domains => ['barformat.superlongextension', '-foo.net'])
|
site = FactoryGirl.build(:site, :domains => ['barformat.superlongextension', '-foo.net'])
|
||||||
site.should_not be_valid
|
site.should_not be_valid
|
||||||
site.errors[:domains].should == ['barformat.superlongextension is invalid', '-foo.net is invalid']
|
site.errors[:domains].should == ['barformat.superlongextension is invalid', '-foo.net is invalid']
|
||||||
end
|
end
|
||||||
@ -65,8 +65,8 @@ describe Site do
|
|||||||
## Named scopes ##
|
## Named scopes ##
|
||||||
|
|
||||||
it 'should retrieve sites by domain' do
|
it 'should retrieve sites by domain' do
|
||||||
site_1 = Factory(:site, :domains => %w{www.acme.net})
|
site_1 = FactoryGirl.create(:site, :domains => %w{www.acme.net})
|
||||||
site_2 = Factory(:site, :subdomain => 'test', :domains => %w{www.example.com})
|
site_2 = FactoryGirl.create(:site, :subdomain => 'test', :domains => %w{www.example.com})
|
||||||
|
|
||||||
sites = Site.match_domain('www.acme.net')
|
sites = Site.match_domain('www.acme.net')
|
||||||
sites.size.should == 1
|
sites.size.should == 1
|
||||||
@ -87,8 +87,8 @@ describe Site do
|
|||||||
## Associations ##
|
## Associations ##
|
||||||
|
|
||||||
it 'should have many accounts' do
|
it 'should have many accounts' do
|
||||||
site = Factory.build(:site)
|
site = FactoryGirl.build(:site)
|
||||||
account_1, account_2 = Factory(:account), Factory(:account, :name => 'homer', :email => 'homer@simpson.net')
|
account_1, account_2 = FactoryGirl.create(:account), FactoryGirl.create(:account, :name => 'homer', :email => 'homer@simpson.net')
|
||||||
site.memberships.build(:account => account_1, :admin => true)
|
site.memberships.build(:account => account_1, :admin => true)
|
||||||
site.memberships.build(:account => account_2)
|
site.memberships.build(:account => account_2)
|
||||||
site.memberships.size.should == 2
|
site.memberships.size.should == 2
|
||||||
@ -98,7 +98,7 @@ describe Site do
|
|||||||
## Methods ##
|
## Methods ##
|
||||||
|
|
||||||
it 'should return domains without subdomain' do
|
it 'should return domains without subdomain' do
|
||||||
site = Factory(:site, :domains => %w{www.acme.net www.acme.com})
|
site = FactoryGirl.create(:site, :domains => %w{www.acme.net www.acme.com})
|
||||||
site.domains.should == %w{www.acme.net www.acme.com acme.example.com}
|
site.domains.should == %w{www.acme.net www.acme.com acme.example.com}
|
||||||
site.domains_without_subdomain.should == %w{www.acme.net www.acme.com}
|
site.domains_without_subdomain.should == %w{www.acme.net www.acme.com}
|
||||||
end
|
end
|
||||||
@ -106,7 +106,7 @@ describe Site do
|
|||||||
describe 'once created' do
|
describe 'once created' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@site = Factory(:site)
|
@site = FactoryGirl.create(:site)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should create index and 404 pages' do
|
it 'should create index and 404 pages' do
|
||||||
@ -119,7 +119,7 @@ describe Site do
|
|||||||
describe 'deleting in cascade' do
|
describe 'deleting in cascade' do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@site = Factory(:site)
|
@site = FactoryGirl.create(:site)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should also destroy pages' do
|
it 'should also destroy pages' do
|
||||||
|
@ -3,14 +3,14 @@ require 'spec_helper'
|
|||||||
describe Snippet do
|
describe Snippet do
|
||||||
|
|
||||||
it 'should have a valid factory' do
|
it 'should have a valid factory' do
|
||||||
Factory.build(:snippet).should be_valid
|
FactoryGirl.build(:snippet).should be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
# Validations ##
|
# Validations ##
|
||||||
|
|
||||||
%w{site name template}.each do |field|
|
%w{site name template}.each do |field|
|
||||||
it "should validate presence of #{field}" do
|
it "should validate presence of #{field}" do
|
||||||
template = Factory.build(:snippet, field.to_sym => nil)
|
template = FactoryGirl.build(:snippet, field.to_sym => nil)
|
||||||
template.should_not be_valid
|
template.should_not be_valid
|
||||||
template.errors[field.to_sym].should == ["can't be blank"]
|
template.errors[field.to_sym].should == ["can't be blank"]
|
||||||
end
|
end
|
||||||
@ -19,14 +19,14 @@ describe Snippet do
|
|||||||
describe '#update_templates' do
|
describe '#update_templates' do
|
||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@site = Factory(:site, :subdomain => 'omg')
|
@site = FactoryGirl.create(:site, :subdomain => 'omg')
|
||||||
@snippet = Factory(:snippet, :site => @site, :slug => 'my_test_snippet', :template => 'a testing template')
|
@snippet = FactoryGirl.create(:snippet, :site => @site, :slug => 'my_test_snippet', :template => 'a testing template')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a normal top level snippet' do
|
context 'with a normal top level snippet' do
|
||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@page = Factory(:page, :site => @site, :slug => 'my_page_here', :raw_template => "{% include 'my_test_snippet' %}")
|
@page = FactoryGirl.create(:page, :site => @site, :slug => 'my_page_here', :raw_template => "{% include 'my_test_snippet' %}")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates templates with the new snippet template' do
|
it 'updates templates with the new snippet template' do
|
||||||
@ -39,7 +39,7 @@ describe Snippet do
|
|||||||
context 'for snippets inside of a block' do
|
context 'for snippets inside of a block' do
|
||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@page = Factory(:page, :site => @site, :slug => 'my_page_here', :raw_template => "{% block main %}{% include 'my_test_snippet' %}{% endblock %}")
|
@page = FactoryGirl.create(:page, :site => @site, :slug => 'my_page_here', :raw_template => "{% block main %}{% include 'my_test_snippet' %}{% endblock %}")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates templates with the new snippet template' do
|
it 'updates templates with the new snippet template' do
|
||||||
|
@ -8,7 +8,7 @@ describe ThemeAsset do
|
|||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
ThemeAsset.any_instance.stubs(:site_id).returns('test')
|
ThemeAsset.any_instance.stubs(:site_id).returns('test')
|
||||||
@asset = Factory.build(:theme_asset)
|
@asset = FactoryGirl.build(:theme_asset)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'file is a picture' do
|
describe 'file is a picture' do
|
||||||
@ -63,7 +63,7 @@ describe ThemeAsset do
|
|||||||
@asset.source = FixturedAsset.open('5k.png')
|
@asset.source = FixturedAsset.open('5k.png')
|
||||||
@asset.save!
|
@asset.save!
|
||||||
|
|
||||||
another_asset = Factory.build(:theme_asset, :site => @asset.site)
|
another_asset = FactoryGirl.build(:theme_asset, :site => @asset.site)
|
||||||
another_asset.source = FixturedAsset.open('5k.png')
|
another_asset.source = FixturedAsset.open('5k.png')
|
||||||
another_asset.valid?.should be_false
|
another_asset.valid?.should be_false
|
||||||
another_asset.errors[:local_path].should_not be_blank
|
another_asset.errors[:local_path].should_not be_blank
|
||||||
@ -94,8 +94,8 @@ describe ThemeAsset do
|
|||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
ThemeAsset.any_instance.stubs(:site_id).returns('test')
|
ThemeAsset.any_instance.stubs(:site_id).returns('test')
|
||||||
@asset = Factory.build(:theme_asset, {
|
@asset = FactoryGirl.build(:theme_asset, {
|
||||||
:site => Factory.build(:site),
|
:site => FactoryGirl.build(:site),
|
||||||
:plain_text_name => 'test',
|
:plain_text_name => 'test',
|
||||||
:plain_text => 'Lorem ipsum',
|
:plain_text => 'Lorem ipsum',
|
||||||
:performing_plain_text => true
|
:performing_plain_text => true
|
||||||
|
Loading…
Reference in New Issue
Block a user