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 'heroku', '1.19.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_mongoid', '1.0.2'
|
||||
gem 'rubyzip'
|
||||
@ -68,7 +68,7 @@ group :test do
|
||||
gem 'ZenTest'
|
||||
gem 'growl-glue'
|
||||
gem 'rspec-rails', '2.6.1'
|
||||
gem 'factory_girl_rails'
|
||||
gem 'factory_girl_rails', '~> 1.1'
|
||||
gem 'pickle'
|
||||
gem 'xpath', '~> 0.1.4'
|
||||
gem 'capybara'
|
||||
@ -76,7 +76,7 @@ group :test do
|
||||
|
||||
gem 'spork', '~> 0.9.0.rc'
|
||||
gem 'launchy'
|
||||
gem 'mocha', :git => 'git://github.com/floehopper/mocha.git'
|
||||
gem 'mocha', '0.9.12' # :git => 'git://github.com/floehopper/mocha.git'
|
||||
end
|
||||
|
||||
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
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
@ -12,7 +5,7 @@ GEM
|
||||
Platform (>= 0.4.0)
|
||||
open4
|
||||
Platform (0.4.0)
|
||||
RedCloth (4.2.7)
|
||||
RedCloth (4.2.8)
|
||||
SystemTimer (1.2.3)
|
||||
ZenTest (4.6.1)
|
||||
abstract (1.0.0)
|
||||
@ -170,10 +163,10 @@ GEM
|
||||
i18n (>= 0.4.0)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
metaclass (0.0.1)
|
||||
mime-types (1.16)
|
||||
mimemagic (0.1.8)
|
||||
mimetype-fu (0.1.2)
|
||||
mocha (0.9.12)
|
||||
mongo (1.3.1)
|
||||
bson (>= 1.3.1)
|
||||
mongoid (2.0.2)
|
||||
@ -286,7 +279,7 @@ PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
RedCloth (= 4.2.7)
|
||||
RedCloth (= 4.2.8)
|
||||
SystemTimer
|
||||
ZenTest
|
||||
actionmailer-with-request
|
||||
@ -306,7 +299,7 @@ DEPENDENCIES
|
||||
devise (= 1.3.4)
|
||||
devise_bushido_authenticatable (= 1.0.0.alpha10)
|
||||
dragonfly (~> 0.9.1)
|
||||
factory_girl_rails
|
||||
factory_girl_rails (~> 1.1)
|
||||
fog (= 0.8.2)
|
||||
formtastic (~> 1.2.3)
|
||||
growl-glue
|
||||
@ -321,7 +314,7 @@ DEPENDENCIES
|
||||
locomotive_liquid (= 2.2.2)
|
||||
locomotive_mongoid_acts_as_tree (= 0.1.5.7)
|
||||
mimetype-fu
|
||||
mocha!
|
||||
mocha (= 0.9.12)
|
||||
mongoid (~> 2.0.2)
|
||||
pickle
|
||||
rack-cache
|
||||
|
@ -1,7 +1,7 @@
|
||||
<%
|
||||
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}"
|
||||
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
|
||||
wip: --tags @wip:3 --wip features
|
||||
|
@ -5,7 +5,7 @@ Given /^I am not authenticated$/ do
|
||||
end
|
||||
|
||||
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}
|
||||
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|
|
||||
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|
|
||||
if (target_name = field.delete('target')).present?
|
||||
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
|
||||
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.should be_valid
|
||||
page
|
||||
|
@ -5,7 +5,7 @@
|
||||
# - 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|
|
||||
@site = Factory(site_factory, parse_fields(fields))
|
||||
@site = FactoryGirl.create(site_factory, parse_fields(fields))
|
||||
@site.should_not be_nil
|
||||
|
||||
@admin = @site.memberships.first.account
|
||||
@ -13,8 +13,8 @@ Given /^I have the site: "([^"]*)" set up(?: with #{capture_fields})?$/ do |site
|
||||
end
|
||||
|
||||
Given /^I have a designer and an author$/ do
|
||||
Factory(:designer, :site => Site.first)
|
||||
Factory(:author, :site => Site.first)
|
||||
FactoryGirl.create(:designer, :site => Site.first)
|
||||
FactoryGirl.create(:author, :site => Site.first)
|
||||
end
|
||||
|
||||
Then /^I should be a administrator of the "([^"]*)" site$/ do |name|
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
# helps create a theme asset
|
||||
def create_plain_text_asset(name, type)
|
||||
asset = Factory.build(:theme_asset, {
|
||||
asset = FactoryGirl.build(:theme_asset, {
|
||||
:site => @site,
|
||||
:plain_text_name => name,
|
||||
:plain_text => 'Lorem ipsum',
|
||||
|
@ -50,7 +50,7 @@ Gem::Specification.new do |s|
|
||||
s.add_dependency 'mimetype-fu'
|
||||
s.add_dependency 'actionmailer-with-request'
|
||||
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_mongoid', '1.0.2'
|
||||
s.add_dependency 'rubyzip'
|
||||
|
@ -4,7 +4,7 @@ describe Admin::GlobalActionsCell do
|
||||
|
||||
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
|
||||
|
||||
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
||||
describe Admin::ApiContentsController do
|
||||
|
||||
before(:each) do
|
||||
@site = Factory('existing site')
|
||||
@site = FactoryGirl.create('existing site')
|
||||
@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 => 'Description', :kind => 'text'
|
||||
|
@ -1,136 +1,141 @@
|
||||
## Site ##
|
||||
Factory.define :site do |s|
|
||||
s.name 'Acme Website'
|
||||
s.subdomain 'acme'
|
||||
s.created_at Time.now
|
||||
end
|
||||
FactoryGirl.define do
|
||||
|
||||
## Site ##
|
||||
factory :site do
|
||||
name 'Acme Website'
|
||||
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'
|
||||
end
|
||||
|
||||
factory "another site" do
|
||||
name "Locomotive test website #2"
|
||||
subdomain "test2"
|
||||
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
|
||||
|
||||
Factory.define "test site", :parent => :site do |s|
|
||||
s.name 'Locomotive test website'
|
||||
s.subdomain 'test'
|
||||
s.after_build do |site_test|
|
||||
site_test.memberships.build :account => Account.where(:name => "Admin").first || Factory("admin user"), :role => 'admin'
|
||||
end
|
||||
end
|
||||
|
||||
Factory.define "another site", :parent => "test site" do |s|
|
||||
s.name "Locomotive test website #2"
|
||||
s.subdomain "test2"
|
||||
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
|
||||
|
||||
Factory.define "existing site", :parent => "site" do |s|
|
||||
s.name "Locomotive site with existing models"
|
||||
s.subdomain "models"
|
||||
s.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.define "valid site", :parent => "site" do |s|
|
||||
# s.after_build { |valid_site| valid_site.stubs(:valid?).returns(true) }
|
||||
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
|
||||
|
||||
|
||||
# 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
|
||||
## Assets ##
|
||||
factory :asset do
|
||||
site { Site.where(:subdomain => "acme").first || Factory(:site) }
|
||||
end
|
||||
|
||||
|
||||
## Memberships ##
|
||||
Factory.define :membership do |m|
|
||||
m.role 'admin'
|
||||
m.account { Account.where(:name => "Bart Simpson").first || Factory('admin user') }
|
||||
end
|
||||
## Theme assets ##
|
||||
factory :theme_asset do
|
||||
site { Site.where(:subdomain => "acme").first || Factory(:site) }
|
||||
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
|
||||
## Content types ##
|
||||
factory :content_type do
|
||||
name 'My project'
|
||||
site { Site.where(:subdomain => "acme").first || Factory(:site) }
|
||||
end
|
||||
|
||||
end
|
@ -66,7 +66,7 @@ describe 'Bushido support' do
|
||||
|
||||
before(:each) do
|
||||
configure_locomotive_with_bushido
|
||||
@site = Factory.build('test site')
|
||||
@site = FactoryGirl.build('test site')
|
||||
@account = @site.memberships.first.account
|
||||
Account.stubs(:first).returns(@account)
|
||||
end
|
||||
@ -83,7 +83,7 @@ describe 'Bushido support' do
|
||||
|
||||
before(:each) do
|
||||
configure_locomotive_with_bushido
|
||||
@site = Factory.build('valid site')
|
||||
@site = FactoryGirl.build('valid site')
|
||||
end
|
||||
|
||||
it 'calls add_bushido_domains after saving a site' do
|
||||
|
@ -5,7 +5,7 @@ describe Locomotive::Export do
|
||||
context '#content_type' do
|
||||
|
||||
before(:each) do
|
||||
site = Factory.build('another site')
|
||||
site = FactoryGirl.build('another site')
|
||||
Site.stubs(:find).returns(site)
|
||||
project_type = build_project_type(site)
|
||||
project_type.contents.build(:title => 'Project #1', :description => 'Lorem ipsum', :active => true)
|
||||
@ -39,7 +39,7 @@ describe Locomotive::Export do
|
||||
end
|
||||
|
||||
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 => 'My Description', :_alias => 'description', :kind => 'text'
|
||||
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)
|
||||
Object.send(:remove_const, 'TestProject') rescue nil
|
||||
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 => 'Projects', :kind => 'has_many', :_alias => 'projects', :target => 'TestProject'
|
||||
content_type.content_custom_fields.build :label => 'Bio', :_alias => 'bio', :kind => 'text'
|
||||
@ -62,7 +62,7 @@ describe Locomotive::Export do
|
||||
context '#zipfile' do
|
||||
|
||||
before(:all) do
|
||||
@site = Factory('another site')
|
||||
@site = FactoryGirl.create('another site')
|
||||
|
||||
# first import a brand new site
|
||||
self.import_it
|
||||
|
@ -95,9 +95,7 @@ describe 'Heroku support' do
|
||||
|
||||
before(:each) do
|
||||
configure_locomotive_with_heroku
|
||||
# (@site = Factory.stub(:site)).stubs(:valid?).returns(true)
|
||||
@site = Factory.build('valid site')
|
||||
# (@site = Site.new(:name => 'foobar', :subdomain => 'acme')).stubs(:valid?).returns(true)
|
||||
@site = FactoryGirl.build('valid site')
|
||||
end
|
||||
|
||||
it 'calls add_heroku_domains after saving a site' do
|
||||
|
@ -2,15 +2,10 @@ require 'spec_helper'
|
||||
|
||||
describe Locomotive::Import::Job do
|
||||
|
||||
# before(:all) do
|
||||
# # Site.destroy_all
|
||||
# # Locomotive.configure_for_test(true)
|
||||
# end
|
||||
|
||||
context 'when successful' 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.perform
|
||||
@ -115,7 +110,7 @@ describe Locomotive::Import::Job do
|
||||
|
||||
context 'with an existing site' 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.perform
|
||||
|
@ -3,8 +3,8 @@ require 'spec_helper'
|
||||
describe Locomotive::Liquid::Drops::Content do
|
||||
|
||||
before(:each) do
|
||||
@site = Factory.build(:site)
|
||||
content_type = Factory.build(:content_type)
|
||||
@site = FactoryGirl.build(:site)
|
||||
content_type = FactoryGirl.build(:content_type)
|
||||
content_type.content_custom_fields.build :label => 'anything', :kind => 'string'
|
||||
content_type.content_custom_fields.build :label => 'published_at', :kind => 'date'
|
||||
@content = content_type.contents.build({
|
||||
|
@ -6,8 +6,8 @@ describe Locomotive::Liquid::Drops::Contents do
|
||||
# Reload the file (needed for spork)
|
||||
load File.join(Rails.root, 'lib', 'locomotive', 'liquid', 'drops', 'contents.rb')
|
||||
|
||||
@site = Factory.build(:site)
|
||||
@content_type = Factory.build(:content_type, :site => @site, :slug => 'projects')
|
||||
@site = FactoryGirl.build(:site)
|
||||
@content_type = FactoryGirl.build(:content_type, :site => @site, :slug => 'projects')
|
||||
end
|
||||
|
||||
it 'retrieves a content type from a slug' do
|
||||
|
@ -3,8 +3,8 @@ require 'spec_helper'
|
||||
describe Locomotive::Liquid::Drops::Page do
|
||||
|
||||
before(:each) do
|
||||
site = Factory.build(:site)
|
||||
@home = Factory.build(:page, :site => site, :meta_keywords => 'Libidinous, Angsty', :meta_description => "Quite the combination.")
|
||||
site = FactoryGirl.build(:site)
|
||||
@home = FactoryGirl.build(:page, :site => site, :meta_keywords => 'Libidinous, Angsty', :meta_description => "Quite the combination.")
|
||||
end
|
||||
|
||||
context '#rendering tree' do
|
||||
@ -40,24 +40,24 @@ describe Locomotive::Liquid::Drops::Page do
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
context '#parent' 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
|
||||
|
||||
|
||||
it 'renders title of parent page' do
|
||||
content = render_template '{{ sub_page.parent.title }}', {'sub_page' => @sub_page}
|
||||
content.should == "Home page"
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
context '#breadcrumbs' 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
|
||||
|
||||
|
||||
it 'renders breadcrumbs of current page' do
|
||||
content = render_template '{% for crumb in sub_page.breadcrumbs %}{{ crumb.title}},{% endfor %}', {'sub_page' => @sub_page}
|
||||
content.should == 'Home page,Subpage,'
|
||||
@ -71,7 +71,7 @@ describe Locomotive::Liquid::Drops::Page do
|
||||
end
|
||||
|
||||
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 !'))
|
||||
|
||||
|
@ -3,9 +3,9 @@ require 'spec_helper'
|
||||
describe Locomotive::Liquid::Drops::Site do
|
||||
|
||||
before(:each) do
|
||||
@site = Factory.build(:site)
|
||||
page_1 = Factory.build(:page, :site => @site)
|
||||
page_2 = Factory.build(:page, :site => @site, :title => 'About us', :slug => 'about_us')
|
||||
@site = FactoryGirl.build(:site)
|
||||
page_1 = FactoryGirl.build(:page, :site => @site)
|
||||
page_2 = FactoryGirl.build(:page, :site => @site, :title => 'About us', :slug => 'about_us')
|
||||
@site.stubs(:pages).returns([page_1, page_2])
|
||||
end
|
||||
|
||||
|
@ -99,7 +99,7 @@ describe Locomotive::Liquid::Filters::Html do
|
||||
end
|
||||
|
||||
it 'should return a url for a javascript file' do
|
||||
result = "/sites/000000000000000000000042/theme/javascripts/main.js"
|
||||
result = "/sites/000000000000000000000042/theme/javascripts/main.js"
|
||||
javascript_url('main.js').should == result
|
||||
javascript_url('main').should == result
|
||||
javascript_url(nil).should == ''
|
||||
@ -233,7 +233,7 @@ describe Locomotive::Liquid::Filters::Html do
|
||||
klass = Class.new
|
||||
klass.class_eval do
|
||||
def registers
|
||||
{ :site => Factory.build(:site, :id => fake_bson_id(42)) }
|
||||
{ :site => FactoryGirl.build(:site, :id => fake_bson_id(42)) }
|
||||
end
|
||||
|
||||
def fake_bson_id(id)
|
||||
|
@ -3,10 +3,10 @@ require 'spec_helper'
|
||||
describe Locomotive::Liquid::Filters::Resize do
|
||||
|
||||
before :each do
|
||||
@site = Factory.create(:site)
|
||||
@theme_asset = Factory.create(:theme_asset, :source => FixturedAsset.open('5k.png'), :site => @site)
|
||||
@site = FactoryGirl.create(: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"
|
||||
@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_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 })
|
||||
|
@ -15,24 +15,24 @@ describe Locomotive::Liquid::Tags::Editable::Content do
|
||||
end.should_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
context 'output' do
|
||||
|
||||
|
||||
before :each do
|
||||
EditableElement.any_instance.stubs(:content).returns("test string")
|
||||
end
|
||||
|
||||
|
||||
context 'inheriting from a parent' do
|
||||
|
||||
|
||||
before :each do
|
||||
@parent = Factory.build(:page)
|
||||
@child = Factory.build(:page)
|
||||
|
||||
@parent = FactoryGirl.build(:page)
|
||||
@child = FactoryGirl.build(:page)
|
||||
|
||||
@child.stubs(:parent).returns(@parent)
|
||||
end
|
||||
|
||||
|
||||
it 'should return the parents field if inherit is set' do
|
||||
@element = @parent.editable_elements.create(:slug => 'test')
|
||||
@child.stubs(:raw_template).returns("{% content test, inherit: true %}")
|
||||
@ -40,27 +40,27 @@ describe Locomotive::Liquid::Tags::Editable::Content do
|
||||
text = template.render!(liquid_context(:page => @child))
|
||||
text.should match /test string/
|
||||
end
|
||||
|
||||
|
||||
it 'should raise an exception if it cant find the field' do
|
||||
@child.stubs(:raw_template).returns("{% content test, inherit: true %}")
|
||||
template = Liquid::Template.parse(@child.raw_template)
|
||||
lambda do
|
||||
lambda do
|
||||
template.render!(liquid_context(:page => @child))
|
||||
end.should raise_error
|
||||
end
|
||||
|
||||
|
||||
after :each do
|
||||
@parent.editable_elements.destroy_all
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
context 'reading from the same page' do
|
||||
|
||||
|
||||
before :each do
|
||||
@page = Factory.build(:page)
|
||||
@page = FactoryGirl.build(:page)
|
||||
end
|
||||
|
||||
|
||||
it 'should return the previously defined field' do
|
||||
@element = @page.editable_elements.create(:slug => 'test')
|
||||
@page.stubs(:raw_template).returns("{% content test %}")
|
||||
@ -68,7 +68,7 @@ describe Locomotive::Liquid::Tags::Editable::Content do
|
||||
text = template.render!(liquid_context(:page => @page))
|
||||
text.should match /test string/
|
||||
end
|
||||
|
||||
|
||||
it 'should raise an exception if it wasnt defined' do
|
||||
@page.stubs(:raw_template).returns("{% content test %}")
|
||||
template = Liquid::Template.parse(@page.raw_template)
|
||||
@ -76,19 +76,19 @@ describe Locomotive::Liquid::Tags::Editable::Content do
|
||||
template.render!(liquid_context(:page => @page))
|
||||
end.should raise_error
|
||||
end
|
||||
|
||||
|
||||
after :each do
|
||||
@page.editable_elements.destroy_all
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
# ___ helpers methods ___ #
|
||||
|
||||
def liquid_context(options = {})
|
||||
::Liquid::Context.new({}, {},
|
||||
::Liquid::Context.new({}, {},
|
||||
{
|
||||
:page => options[:page]
|
||||
}, true)
|
||||
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
||||
describe Locomotive::Liquid::Tags::Nav do
|
||||
|
||||
before(:each) do
|
||||
@home = Factory.build(:page)
|
||||
@home = FactoryGirl.build(:page)
|
||||
home_children = [
|
||||
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)
|
||||
@ -24,7 +24,7 @@ describe Locomotive::Liquid::Tags::Nav do
|
||||
pages = [@home]
|
||||
pages.stubs(:root).returns(pages)
|
||||
pages.stubs(:minimal_attributes).returns(pages) # iso
|
||||
@site = Factory.build(:site)
|
||||
@site = FactoryGirl.build(:site)
|
||||
@site.stubs(:pages).returns(pages)
|
||||
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']),
|
||||
'current_page' => options[:page] || 1
|
||||
}, {
|
||||
:page => Factory.build(:page)
|
||||
:page => FactoryGirl.build(:page)
|
||||
}, true)
|
||||
end
|
||||
|
||||
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
||||
describe Locomotive::Liquid::Tags::SEO 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
|
||||
|
||||
describe 'rendering' do
|
||||
@ -80,7 +80,7 @@ describe Locomotive::Liquid::Tags::SEO do
|
||||
context "when content instance" 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'
|
||||
end
|
||||
end
|
||||
|
@ -6,10 +6,10 @@ describe 'Locomotive rendering system' do
|
||||
before(:each) do
|
||||
@controller = Locomotive::TestController.new
|
||||
Site.any_instance.stubs(:create_default_pages!).returns(true)
|
||||
@site = Factory.build(:site)
|
||||
@site = FactoryGirl.build(:site)
|
||||
Site.stubs(:find).returns(@site)
|
||||
@controller.current_site = @site
|
||||
@page = Factory.build(:page, :site => nil, :published => true)
|
||||
@page = FactoryGirl.build(:page, :site => nil, :published => true)
|
||||
end
|
||||
|
||||
context '#liquid_context' do
|
||||
@ -125,7 +125,7 @@ describe 'Locomotive rendering system' do
|
||||
context 'templatized page' 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)
|
||||
@page.templatized = true
|
||||
@page.content_type = @content_type
|
||||
|
@ -26,7 +26,7 @@ describe Locomotive::Routing::SiteDispatcher do
|
||||
|
||||
before :each do
|
||||
@request = Object.new
|
||||
@site = Factory.build(:site)
|
||||
@site = FactoryGirl.build(:site)
|
||||
|
||||
@controller.stubs(:request).returns(@request)
|
||||
@request.stubs(:host).returns('host')
|
||||
@ -48,7 +48,7 @@ describe Locomotive::Routing::SiteDispatcher do
|
||||
describe '#current_site' do
|
||||
|
||||
before :each do
|
||||
@site = Factory.build(:site)
|
||||
@site = FactoryGirl.build(:site)
|
||||
end
|
||||
|
||||
it 'returns the current site instance if available' do
|
||||
@ -157,8 +157,8 @@ describe Locomotive::Routing::SiteDispatcher do
|
||||
describe '#validate_site_membership' do
|
||||
|
||||
before :each do
|
||||
@account = Factory.build(:account)
|
||||
@site = Factory.build(:site)
|
||||
@account = FactoryGirl.build(:account)
|
||||
@site = FactoryGirl.build(:site)
|
||||
@request = ActionDispatch::Request.new({})
|
||||
|
||||
@controller.instance_variable_set('@_response', ActionDispatch::Response.new)
|
||||
|
@ -3,12 +3,12 @@ require 'spec_helper'
|
||||
describe Ability do
|
||||
|
||||
before :each do
|
||||
@site = Factory(:site)
|
||||
@account = Factory(:account)
|
||||
@site = FactoryGirl.create(:site)
|
||||
@account = FactoryGirl.create(:account)
|
||||
|
||||
@admin = Factory(:membership, :account => Factory.stub(:account), :site => Factory.stub(:site))
|
||||
@designer = Factory(:membership, :account => Factory.stub(:account), :site => @site, :role => %(designer))
|
||||
@author = Factory(:membership, :account => Factory.stub(:account), :site => @site, :role => %(author))
|
||||
@admin = FactoryGirl.create(:membership, :account => FactoryGirl.build(:account), :site => FactoryGirl.build(:site))
|
||||
@designer = FactoryGirl.create(:membership, :account => FactoryGirl.build(:account), :site => @site, :role => %(designer))
|
||||
@author = FactoryGirl.create(:membership, :account => FactoryGirl.build(:account), :site => @site, :role => %(author))
|
||||
end
|
||||
|
||||
context 'pages' do
|
||||
|
@ -3,14 +3,14 @@ require 'spec_helper'
|
||||
describe Account do
|
||||
|
||||
it 'should have a valid factory' do
|
||||
Factory.build(:account).should be_valid
|
||||
FactoryGirl.build(:account).should be_valid
|
||||
end
|
||||
|
||||
## Validations ##
|
||||
|
||||
%w{name email password}.each do |attr|
|
||||
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.errors[attr.to_sym].should include("can't be blank")
|
||||
end
|
||||
@ -22,26 +22,26 @@ describe Account do
|
||||
end
|
||||
|
||||
it "should validate uniqueness of email" do
|
||||
Factory(:account)
|
||||
(account = Factory.build(:account)).should_not be_valid
|
||||
FactoryGirl.create(:account)
|
||||
(account = FactoryGirl.build(:account)).should_not be_valid
|
||||
account.errors[:email].should == ["is already taken"]
|
||||
end
|
||||
|
||||
## Associations ##
|
||||
|
||||
it 'should own many sites' do
|
||||
account = Factory(:account)
|
||||
site_1 = Factory(:site, :memberships => [Membership.new(:account => account)])
|
||||
site_2 = Factory(:site, :subdomain => 'foo', :memberships => [Membership.new(:account => account)])
|
||||
account = FactoryGirl.create(:account)
|
||||
site_1 = FactoryGirl.create(:site, :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]
|
||||
end
|
||||
|
||||
describe 'deleting' do
|
||||
|
||||
before(:each) do
|
||||
@account = Factory.build(:account)
|
||||
@site_1 = Factory.build(:site, :subdomain => 'foo', :memberships => [Factory.build(:membership, :account => @account)])
|
||||
@site_2 = Factory.build(:site, :subdomain => 'bar', :memberships => [Factory.build(:membership, :account => @account)])
|
||||
@account = FactoryGirl.build(:account)
|
||||
@site_1 = FactoryGirl.build(:site, :subdomain => 'foo', :memberships => [FactoryGirl.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])
|
||||
Site.any_instance.stubs(:save).returns(true)
|
||||
end
|
||||
@ -65,7 +65,7 @@ describe Account do
|
||||
describe 'cross domain authentication' do
|
||||
|
||||
before(:each) do
|
||||
@account = Factory.build(:account)
|
||||
@account = FactoryGirl.build(:account)
|
||||
@account.stubs(:save).returns(true)
|
||||
end
|
||||
|
||||
|
@ -8,7 +8,7 @@ describe Asset do
|
||||
|
||||
before(:each) do
|
||||
Asset.any_instance.stubs(:site_id).returns('test')
|
||||
@asset = Factory.build(:asset)
|
||||
@asset = FactoryGirl.build(:asset)
|
||||
end
|
||||
|
||||
it 'should process picture' do
|
||||
@ -28,7 +28,7 @@ describe Asset do
|
||||
describe 'vignette' do
|
||||
|
||||
before(:each) do
|
||||
@asset = Factory.build(:asset, :source => FixturedAsset.open('5k.png'))
|
||||
@asset = FactoryGirl.build(:asset, :source => FixturedAsset.open('5k.png'))
|
||||
end
|
||||
|
||||
it 'does not resize image smaller than 50x50' do
|
||||
|
@ -6,7 +6,7 @@ describe ContentInstance do
|
||||
|
||||
before(:each) do
|
||||
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 => 'Description', :kind => 'Text'
|
||||
@content_type.content_custom_fields.build :label => 'Visible ?', :kind => 'Text', :_alias => 'visible'
|
||||
@ -111,8 +111,8 @@ describe ContentInstance do
|
||||
describe '#api' do
|
||||
|
||||
before(:each) do
|
||||
@account_1 = Factory.build('admin user', :id => fake_bson_id('1'))
|
||||
@account_2 = Factory.build('frenchy user', :id => fake_bson_id('2'))
|
||||
@account_1 = FactoryGirl.build('admin user', :id => fake_bson_id('1'))
|
||||
@account_2 = FactoryGirl.build('frenchy user', :id => fake_bson_id('2'))
|
||||
|
||||
@content_type.api_enabled = true
|
||||
@content_type.api_accounts = ['', @account_1.id, @account_2.id]
|
||||
|
@ -9,7 +9,7 @@ describe ContentType do
|
||||
context 'when validating' 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.should be_valid
|
||||
end
|
||||
@ -18,35 +18,35 @@ describe ContentType do
|
||||
|
||||
%w{site name}.each do |field|
|
||||
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.errors[field.to_sym].should == ["can't be blank"]
|
||||
end
|
||||
end
|
||||
|
||||
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.errors[:slug].should == ["can't be blank"]
|
||||
end
|
||||
|
||||
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.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"]
|
||||
end
|
||||
|
||||
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.errors[:content_custom_fields].should == ["is too small (minimum element number is 1)"]
|
||||
end
|
||||
|
||||
%w(created_at updated_at).each do |_alias|
|
||||
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.valid?.should be_false
|
||||
field.errors[:_alias].should == ['is reserved']
|
||||
@ -58,7 +58,7 @@ describe ContentType do
|
||||
context '#ordered_contents' 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_2 = stub('content_2', :name => 'Sacha', :_position_in_list => 1)
|
||||
@content_type.stubs(:contents).returns([@content_1, @content_2])
|
||||
@ -95,9 +95,9 @@ describe ContentType do
|
||||
describe 'custom fields' do
|
||||
|
||||
before(:each) do
|
||||
site = Factory.build(:site)
|
||||
site = FactoryGirl.build(: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 => 'Active', :kind => 'boolean'
|
||||
# ContentType.logger = Logger.new($stdout)
|
||||
|
@ -3,14 +3,14 @@ require 'spec_helper'
|
||||
describe EditableElement do
|
||||
|
||||
before(:each) do
|
||||
@site = Factory(:site)
|
||||
@site = FactoryGirl.create(:site)
|
||||
@home = @site.pages.root.first
|
||||
@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_2 = Factory(:page, :slug => 'sub_page_2', :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 = 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
|
||||
|
||||
context 'in sub pages level #1' do
|
||||
|
@ -3,19 +3,19 @@ require 'spec_helper'
|
||||
describe Membership 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
|
||||
|
||||
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.errors[:account].should == ["can't be blank"]
|
||||
end
|
||||
|
||||
it 'should assign account from email' do
|
||||
Account.stubs(:where).returns([Factory.build(:account)])
|
||||
Account.stubs(:find).returns(Factory.build(:account))
|
||||
membership = Factory.build(:membership, :account => nil)
|
||||
Account.stubs(:where).returns([FactoryGirl.build(:account)])
|
||||
Account.stubs(:find).returns(FactoryGirl.build(:account))
|
||||
membership = FactoryGirl.build(:membership, :account => nil)
|
||||
membership.email = 'bart@simpson.net'
|
||||
membership.account.should_not be_nil
|
||||
membership.account.name.should == 'Bart Simpson'
|
||||
@ -24,8 +24,8 @@ describe Membership do
|
||||
describe 'next action to take' do
|
||||
|
||||
before(:each) do
|
||||
@membership = Factory.build(:membership, :site => Factory.build(:site))
|
||||
@account = Factory.build(:account)
|
||||
@membership = FactoryGirl.build(:membership, :site => FactoryGirl.build(:site))
|
||||
@account = FactoryGirl.build(:account)
|
||||
@account.stubs(:save).returns(true)
|
||||
Account.stubs(:where).returns([@account])
|
||||
Account.stubs(:find).returns(@account)
|
||||
@ -53,7 +53,7 @@ describe Membership do
|
||||
end
|
||||
|
||||
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
|
||||
|
@ -10,36 +10,36 @@ describe Page do
|
||||
end
|
||||
|
||||
it 'should have a valid factory' do
|
||||
Factory.build(:page).should be_valid
|
||||
FactoryGirl.build(:page).should be_valid
|
||||
end
|
||||
|
||||
# Validations ##
|
||||
|
||||
%w{site title}.each do |field|
|
||||
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.errors[field.to_sym].should == ["can't be blank"]
|
||||
end
|
||||
end
|
||||
|
||||
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.errors[:slug].should == ["can't be blank"]
|
||||
end
|
||||
|
||||
it 'should validate uniqueness of slug' do
|
||||
page = Factory(:page)
|
||||
(page = Factory.build(:page, :site => page.site)).should_not be_valid
|
||||
page = FactoryGirl.create(:page)
|
||||
(page = FactoryGirl.build(:page, :site => page.site)).should_not be_valid
|
||||
page.errors[:slug].should == ["is already taken"]
|
||||
end
|
||||
|
||||
it 'should validate uniqueness of slug within a "folder"' do
|
||||
site = Factory(:site)
|
||||
root = Factory(:page, :slug => 'index', :site => site)
|
||||
child_1 = Factory(:page, :slug => 'first_child', :parent => root, :site => site)
|
||||
(page = Factory.build(:page, :slug => 'first_child', :parent => root, :site => site)).should_not be_valid
|
||||
site = FactoryGirl.create(:site)
|
||||
root = FactoryGirl.create(:page, :slug => 'index', :site => site)
|
||||
child_1 = FactoryGirl.create(:page, :slug => 'first_child', :parent => root, :site => site)
|
||||
(page = FactoryGirl.build(:page, :slug => 'first_child', :parent => root, :site => site)).should_not be_valid
|
||||
page.errors[:slug].should == ["is already taken"]
|
||||
|
||||
page.slug = 'index'
|
||||
@ -48,7 +48,7 @@ describe Page do
|
||||
|
||||
%w{admin stylesheets images javascripts}.each do |slug|
|
||||
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.errors[:slug].should == ["is reserved"]
|
||||
end
|
||||
@ -63,22 +63,22 @@ describe Page do
|
||||
describe 'once created' do
|
||||
|
||||
it 'should tell if the page is the index one' do
|
||||
Factory.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', :site => nil).index?.should be_true
|
||||
FactoryGirl.build(:page, :slug => 'index', :depth => 1, :site => nil).index?.should be_false
|
||||
end
|
||||
|
||||
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.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.slug.should == 'valid-ite-html'
|
||||
end
|
||||
|
||||
it 'has no cache strategy' do
|
||||
page = Factory.build(:page, :site => nil)
|
||||
page = FactoryGirl.build(:page, :site => nil)
|
||||
page.with_cache?.should == false
|
||||
end
|
||||
|
||||
@ -87,7 +87,7 @@ describe Page do
|
||||
describe '#deleting' do
|
||||
|
||||
before(:each) do
|
||||
@page = Factory.build(:page)
|
||||
@page = FactoryGirl.build(:page)
|
||||
end
|
||||
|
||||
it 'does not delete the index page' do
|
||||
@ -111,27 +111,27 @@ describe Page do
|
||||
describe 'acts as tree' do
|
||||
|
||||
before(:each) do
|
||||
@home = Factory(:page)
|
||||
@child_1 = Factory(:page, :title => 'Subpage 1', :slug => 'foo', :parent_id => @home._id, :site => @home.site)
|
||||
@home = FactoryGirl.create(:page)
|
||||
@child_1 = FactoryGirl.create(:page, :title => 'Subpage 1', :slug => 'foo', :parent_id => @home._id, :site => @home.site)
|
||||
end
|
||||
|
||||
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.should == [@home, page_404]
|
||||
end
|
||||
|
||||
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.children.count.should == 2
|
||||
@home.children.should == [@child_1, child_2]
|
||||
end
|
||||
|
||||
it 'should move its children accordingly' do
|
||||
sub_child_1 = Factory(: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)
|
||||
posts = Factory(:page, :title => 'posts', :slug => 'posts', :parent => archives, :site => @home.site)
|
||||
sub_child_1 = FactoryGirl.create(:page, :title => 'Sub Subpage 1', :slug => 'bar', :parent => @child_1, :site => @home.site)
|
||||
archives = FactoryGirl.create(:page, :title => 'archives', :slug => 'archives', :parent => @home, :site => @home.site)
|
||||
posts = FactoryGirl.create(:page, :title => 'posts', :slug => 'posts', :parent => archives, :site => @home.site)
|
||||
|
||||
@child_1.parent_id = archives._id
|
||||
@child_1.save
|
||||
@ -146,7 +146,7 @@ describe Page do
|
||||
end
|
||||
|
||||
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
|
||||
Page.where(:slug => 'bar').first.should be_nil
|
||||
end
|
||||
@ -156,10 +156,10 @@ describe Page do
|
||||
describe 'acts as list' do
|
||||
|
||||
before(:each) do
|
||||
@home = Factory(:page)
|
||||
@child_1 = Factory(: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_3 = Factory(:page, :title => 'Subpage 3', :slug => 'acme', :parent => @home, :site => @home.site)
|
||||
@home = FactoryGirl.create(:page)
|
||||
@child_1 = FactoryGirl.create(:page, :title => 'Subpage 1', :slug => 'foo', :parent => @home, :site => @home.site)
|
||||
@child_2 = FactoryGirl.create(:page, :title => 'Subpage 2', :slug => 'bar', :parent => @home, :site => @home.site)
|
||||
@child_3 = FactoryGirl.create(:page, :title => 'Subpage 3', :slug => 'acme', :parent => @home, :site => @home.site)
|
||||
end
|
||||
|
||||
it 'should be at the bottom of the folder once created' do
|
||||
@ -176,8 +176,8 @@ describe Page do
|
||||
describe 'templatized extension' do
|
||||
|
||||
before(:each) do
|
||||
@page = Factory.build(:page, :site => nil, :templatized => true, :content_type_id => 42)
|
||||
ContentType.stubs(:find).returns(Factory.build(:content_type, :site => nil))
|
||||
@page = FactoryGirl.build(:page, :site => nil, :templatized => true, :content_type_id => 42)
|
||||
ContentType.stubs(:find).returns(FactoryGirl.build(:content_type, :site => nil))
|
||||
end
|
||||
|
||||
it 'is considered as a templatized page' do
|
||||
@ -198,12 +198,12 @@ describe Page do
|
||||
describe 'listed extension' 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
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
@ -212,7 +212,7 @@ describe Page do
|
||||
describe 'redirect extension' 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
|
||||
|
||||
it 'is considered as a redirect page' do
|
||||
|
@ -3,61 +3,61 @@ require 'spec_helper'
|
||||
describe Site do
|
||||
|
||||
it 'should have a valid factory' do
|
||||
Factory.build(:site).should be_valid
|
||||
FactoryGirl.build(:site).should be_valid
|
||||
end
|
||||
|
||||
## Validations ##
|
||||
|
||||
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.errors[:name].should == ["can't be blank"]
|
||||
end
|
||||
|
||||
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.errors[:subdomain].should == ["can't be blank"]
|
||||
end
|
||||
|
||||
%w{test test42 foo_bar}.each do |subdomain|
|
||||
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
|
||||
|
||||
['-', '_test', 'test_', 't est', '42', '42test'].each do |subdomain|
|
||||
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']
|
||||
end
|
||||
end
|
||||
|
||||
it "should not use reserved keywords as subdomain" do
|
||||
%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']
|
||||
end
|
||||
end
|
||||
|
||||
it 'should validate uniqueness of subdomain' do
|
||||
Factory(:site)
|
||||
(site = Factory.build(:site)).should_not be_valid
|
||||
FactoryGirl.create(:site)
|
||||
(site = FactoryGirl.build(:site)).should_not be_valid
|
||||
site.errors[:subdomain].should == ["is already taken"]
|
||||
end
|
||||
|
||||
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 = 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"]
|
||||
end
|
||||
|
||||
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.errors[:domains].should == ['barformat.superlongextension is invalid', '-foo.net is invalid']
|
||||
end
|
||||
@ -65,8 +65,8 @@ describe Site do
|
||||
## Named scopes ##
|
||||
|
||||
it 'should retrieve sites by domain' do
|
||||
site_1 = Factory(:site, :domains => %w{www.acme.net})
|
||||
site_2 = Factory(:site, :subdomain => 'test', :domains => %w{www.example.com})
|
||||
site_1 = FactoryGirl.create(:site, :domains => %w{www.acme.net})
|
||||
site_2 = FactoryGirl.create(:site, :subdomain => 'test', :domains => %w{www.example.com})
|
||||
|
||||
sites = Site.match_domain('www.acme.net')
|
||||
sites.size.should == 1
|
||||
@ -87,8 +87,8 @@ describe Site do
|
||||
## Associations ##
|
||||
|
||||
it 'should have many accounts' do
|
||||
site = Factory.build(:site)
|
||||
account_1, account_2 = Factory(:account), Factory(:account, :name => 'homer', :email => 'homer@simpson.net')
|
||||
site = FactoryGirl.build(:site)
|
||||
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_2)
|
||||
site.memberships.size.should == 2
|
||||
@ -98,7 +98,7 @@ describe Site do
|
||||
## Methods ##
|
||||
|
||||
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_without_subdomain.should == %w{www.acme.net www.acme.com}
|
||||
end
|
||||
@ -106,7 +106,7 @@ describe Site do
|
||||
describe 'once created' do
|
||||
|
||||
before(:each) do
|
||||
@site = Factory(:site)
|
||||
@site = FactoryGirl.create(:site)
|
||||
end
|
||||
|
||||
it 'should create index and 404 pages' do
|
||||
@ -119,7 +119,7 @@ describe Site do
|
||||
describe 'deleting in cascade' do
|
||||
|
||||
before(:each) do
|
||||
@site = Factory(:site)
|
||||
@site = FactoryGirl.create(:site)
|
||||
end
|
||||
|
||||
it 'should also destroy pages' do
|
||||
|
@ -3,30 +3,30 @@ require 'spec_helper'
|
||||
describe Snippet do
|
||||
|
||||
it 'should have a valid factory' do
|
||||
Factory.build(:snippet).should be_valid
|
||||
FactoryGirl.build(:snippet).should be_valid
|
||||
end
|
||||
|
||||
|
||||
# Validations ##
|
||||
|
||||
%w{site name template}.each do |field|
|
||||
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.errors[field.to_sym].should == ["can't be blank"]
|
||||
end
|
||||
end
|
||||
|
||||
describe '#update_templates' do
|
||||
|
||||
|
||||
before :each do
|
||||
@site = Factory(:site, :subdomain => 'omg')
|
||||
@snippet = Factory(:snippet, :site => @site, :slug => 'my_test_snippet', :template => 'a testing template')
|
||||
@site = FactoryGirl.create(:site, :subdomain => 'omg')
|
||||
@snippet = FactoryGirl.create(:snippet, :site => @site, :slug => 'my_test_snippet', :template => 'a testing template')
|
||||
end
|
||||
|
||||
context 'with a normal top level snippet' 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
|
||||
|
||||
it 'updates templates with the new snippet template' do
|
||||
@ -39,7 +39,7 @@ describe Snippet do
|
||||
context 'for snippets inside of a block' 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
|
||||
|
||||
it 'updates templates with the new snippet template' do
|
||||
|
@ -8,7 +8,7 @@ describe ThemeAsset do
|
||||
|
||||
before(:each) do
|
||||
ThemeAsset.any_instance.stubs(:site_id).returns('test')
|
||||
@asset = Factory.build(:theme_asset)
|
||||
@asset = FactoryGirl.build(:theme_asset)
|
||||
end
|
||||
|
||||
describe 'file is a picture' do
|
||||
@ -63,7 +63,7 @@ describe ThemeAsset do
|
||||
@asset.source = FixturedAsset.open('5k.png')
|
||||
@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.valid?.should be_false
|
||||
another_asset.errors[:local_path].should_not be_blank
|
||||
@ -94,8 +94,8 @@ describe ThemeAsset do
|
||||
|
||||
before(:each) do
|
||||
ThemeAsset.any_instance.stubs(:site_id).returns('test')
|
||||
@asset = Factory.build(:theme_asset, {
|
||||
:site => Factory.build(:site),
|
||||
@asset = FactoryGirl.build(:theme_asset, {
|
||||
:site => FactoryGirl.build(:site),
|
||||
:plain_text_name => 'test',
|
||||
:plain_text => 'Lorem ipsum',
|
||||
:performing_plain_text => true
|
||||
|
Loading…
Reference in New Issue
Block a user