Merge branch 'rails_3_1' of github.com:locomotivecms/engine into rails_3_1

This commit is contained in:
did 2011-11-27 08:23:12 -08:00
commit cad1f5e68f
39 changed files with 192 additions and 542 deletions

1
.gitignore vendored
View File

@ -36,6 +36,7 @@ doc/bushido
*.swp
.sass-cache/
spec/dummy/tmp/
spec/dummy/spec/tmp
spec/dummy/log/*.log
app/assets/javascripts/old/
app/assets/stylesheets/old/

View File

@ -2,6 +2,7 @@ script: "bundle exec rake travis"
before_script: ./bin/ci/before_build.sh
rvm:
- 1.9.2
- 1.9.3
notifications:
email:
- didier@nocoffee.fr

10
Gemfile
View File

@ -4,7 +4,7 @@ source 'http://rubygems.org'
gem 'rake', '0.9.2'
gem 'rails', '~> 3.1.1'
gem 'rails', '~> 3.1.3'
gem 'devise', :git => 'git://github.com/plataformatec/devise.git'# FIXME: waiting for the new devise gem coming soon
gem 'cancan', '~> 1.6.7'
@ -46,12 +46,10 @@ gem 'rubyzip'
gem 'actionmailer-with-request', '~> 0.3.0', :require => 'actionmailer_with_request'
gem 'httparty', '~> 0.8.1'
gem 'delayed_job', '~> 2.1.1'
gem 'delayed_job_mongoid', '~> 1.0.4'
gem 'delayed_job', '~> 3.0.0.pre4'
gem 'delayed_job_mongoid', '~> 1.0.6'
gem 'SystemTimer', :platforms => :ruby_18
# The rest of the dependencies are for use when in the locomotive dev environment
group :development do
@ -63,7 +61,7 @@ end
group :test, :development do
# gem 'linecache', '0.43', :platforms => :mri_18
# gem 'ruby-debug', :platforms => :mri_18
# gem 'ruby-debug19', :platforms => :mri_19, :require => 'ruby-debug'
# gem 'ruby-debug19', :platforms => :mri_19
gem 'cucumber-rails'
end

View File

@ -1,8 +1,8 @@
GIT
remote: git://github.com/chriseppstein/compass.git
revision: ebd758a7999a74611a3d682ba72c661a83f97498
revision: 79d94647f9a00b06c4a83db02e86f5d404569baf
specs:
compass (0.12.alpha.0.ebd758a)
compass (0.12.alpha.1.79d9464)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
@ -26,9 +26,9 @@ GIT
GIT
remote: git://github.com/plataformatec/devise.git
revision: a5aa03b98328d8e1fdb4081a74b3c04ff9593607
revision: ede004169c6af7416f8c4e3fc29a653bee133f60
specs:
devise (1.5.0.dev)
devise (1.5.1)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
warden (~> 1.1)
@ -51,35 +51,35 @@ GEM
RedCloth (4.2.8)
SystemTimer (1.2.3)
ZenTest (4.6.2)
actionmailer (3.1.1)
actionpack (= 3.1.1)
actionmailer (3.1.3)
actionpack (= 3.1.3)
mail (~> 2.3.0)
actionmailer-with-request (0.3.0)
rails (>= 3)
actionpack (3.1.1)
activemodel (= 3.1.1)
activesupport (= 3.1.1)
actionpack (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
rack (~> 1.3.2)
rack (~> 1.3.5)
rack-cache (~> 1.1)
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
sprockets (~> 2.0.2)
activemodel (3.1.1)
activesupport (= 3.1.1)
sprockets (~> 2.0.3)
activemodel (3.1.3)
activesupport (= 3.1.3)
builder (~> 3.0.0)
i18n (~> 0.6)
activerecord (3.1.1)
activemodel (= 3.1.1)
activesupport (= 3.1.1)
activerecord (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
arel (~> 2.2.1)
tzinfo (~> 0.3.29)
activeresource (3.1.1)
activemodel (= 3.1.1)
activesupport (= 3.1.1)
activesupport (3.1.1)
activeresource (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
activesupport (3.1.3)
multi_json (~> 1.0)
addressable (2.2.6)
arel (2.2.1)
@ -95,7 +95,7 @@ GEM
orm_adapter (~> 0.0.3)
rest-client (>= 1.6.1)
cancan (1.6.7)
capybara (1.1.1)
capybara (1.1.2)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
@ -118,38 +118,38 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.1.3)
cucumber (1.1.1)
cucumber (1.1.3)
builder (>= 2.1.2)
diff-lcs (>= 1.1.2)
gherkin (~> 2.6.0)
gherkin (~> 2.6.7)
json (>= 1.4.6)
term-ansicolor (>= 1.0.6)
cucumber-rails (1.2.0)
capybara (>= 1.1.1)
cucumber (>= 1.1.1)
nokogiri (>= 1.5.0)
daemons (1.1.4)
database_cleaner (0.6.7)
delayed_job (2.1.4)
daemons (1.0.10)
database_cleaner (0.7.0)
delayed_job (3.0.0.pre4)
activesupport (~> 3.0)
daemons
delayed_job_mongoid (1.0.4)
delayed_job (~> 2.1.1)
daemons (= 1.0.10)
delayed_job_mongoid (1.0.6)
delayed_job (= 3.0.0.pre4)
mongoid (>= 2.0)
diff-lcs (1.1.3)
dragonfly (0.9.8)
rack
ejs (1.0.0)
erubis (2.7.0)
excon (0.7.6)
excon (0.7.8)
execjs (1.2.9)
multi_json (~> 1.0)
factory_girl (2.2.0)
factory_girl (2.3.1)
activesupport
factory_girl_rails (1.3.0)
factory_girl (~> 2.2.0)
factory_girl_rails (1.4.0)
factory_girl (~> 2.3.0)
railties (>= 3.0.0)
ffi (1.0.9)
ffi (1.0.11)
flash_cookie_session (1.1.1)
rails (~> 3.0)
fog (1.0.0)
@ -166,17 +166,17 @@ GEM
formtastic (2.0.2)
rails (~> 3.0)
fssm (0.2.7)
gherkin (2.6.2)
gherkin (2.6.8)
json (>= 1.4.6)
growl-glue (1.0.7)
haml (3.1.3)
highline (1.6.5)
highline (1.6.8)
hike (1.2.1)
httparty (0.8.1)
multi_json
multi_xml
i18n (0.6.0)
jquery-rails (1.0.16)
jquery-rails (1.0.18)
railties (~> 3.0)
thor (~> 0.14)
json (1.6.1)
@ -196,7 +196,7 @@ GEM
mocha (0.9.12)
mongo (1.4.0)
bson (= 1.4.0)
mongoid (2.3.3)
mongoid (2.3.4)
activemodel (~> 3.1)
mongo (~> 1.3)
tzinfo (~> 0.3.22)
@ -220,21 +220,21 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.1.1)
actionmailer (= 3.1.1)
actionpack (= 3.1.1)
activerecord (= 3.1.1)
activeresource (= 3.1.1)
activesupport (= 3.1.1)
rails (3.1.3)
actionmailer (= 3.1.3)
actionpack (= 3.1.3)
activerecord (= 3.1.3)
activeresource (= 3.1.3)
activesupport (= 3.1.3)
bundler (~> 1.0)
railties (= 3.1.1)
railties (= 3.1.3)
rails-backbone (0.5.4)
coffee-script (~> 2.2.0)
ejs (~> 1.0.0)
rails (~> 3.1.0)
railties (3.1.1)
actionpack (= 3.1.1)
activesupport (= 3.1.1)
railties (3.1.3)
actionpack (= 3.1.3)
activesupport (= 3.1.3)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
@ -268,15 +268,14 @@ GEM
sanitize (2.0.3)
nokogiri (>= 1.4.4, < 1.6)
sass (3.1.10)
sass-rails (3.1.4)
sass-rails (3.1.5)
actionpack (~> 3.1.0)
railties (~> 3.1.0)
sass (>= 3.1.4)
sprockets (~> 2.0.0)
sass (~> 3.1.10)
tilt (~> 1.3.2)
selenium-webdriver (2.10.0)
selenium-webdriver (2.13.0)
childprocess (>= 0.2.1)
ffi (= 1.0.9)
ffi (~> 1.0.9)
json_pure
rubyzip
sprockets (2.0.3)
@ -325,8 +324,8 @@ DEPENDENCIES
cucumber-rails
custom_fields!
database_cleaner
delayed_job (~> 2.1.1)
delayed_job_mongoid (~> 1.0.4)
delayed_job (~> 3.0.0.pre4)
delayed_job_mongoid (~> 1.0.6)
devise!
dragonfly (~> 0.9.8)
factory_girl_rails (~> 1.1)
@ -348,7 +347,7 @@ DEPENDENCIES
mongoid (~> 2.3.3)
pickle
rack-cache (~> 1.1)
rails (~> 3.1.1)
rails (~> 3.1.3)
rails-backbone (= 0.5.4)
rake (= 0.9.2)
responders (~> 0.6.0)

View File

@ -1,5 +1,8 @@
h1. Locomotive CMS
"!https://secure.travis-ci.org/locomotivecms/engine.png!":http://travis-ci.org/locomotivecms/engine
Locomotive is a simple but powerful CMS based on liquid templates and mongodb database. At my company ("NoCoffee":http://www.nocoffee.fr), we use it for our clients when they request a simple website.
If we have to give only 5 main features to describe our application, there will be:
@ -32,6 +35,12 @@ h2. Installation
See the "official website":http://www.locomotivecms.com
h2. Community
* Get help or discuss locomotive CMS at the "LocomotiveCMS Discussion Forums":http://locomotive.vanillaforums.com/
* Join us on IRC "#locomotivecms at irc.freenode.net!":http://webchat.freenode.net/
* "Follow us on twitter":http://twitter.com/locomotiveapp
h2. Team
* Developers: "Didier Lafforgue":http://www.nocoffee.fr, "Jacques Crocker":http://www.railsjedi.com, "Mario Visic":http://www.mariovisic.com

View File

@ -7,7 +7,7 @@ module Locomotive
included do
referenced_in :content_type
referenced_in :content_type, :class_name => 'Locomotive::ContentType'
field :templatized, :type => Boolean, :default => false
@ -27,4 +27,4 @@ module Locomotive
end
end
end
end
end

View File

@ -29,7 +29,7 @@ module Locomotive
def email=(email)
@email = email
self.account = Account.where(:email => email).first
self.account = Locomotive::Account.where(:email => email).first
end
def process!
@ -72,4 +72,4 @@ module Locomotive
end
end
end
end

View File

@ -7,18 +7,18 @@ end
Given /^I am an authenticated "([^"]*)"$/ do |role|
@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}"}
And %{I fill in "Password" with "easyone"}
And %{I press "Log in"}
step %{I go to login}
step %{I fill in "Email" with "#{@member.account.email}"}
step %{I fill in "Password" with "easyone"}
step %{I press "Log in"}
end
Given /^I am an authenticated user$/ do
Given %{I am an authenticated "admin"}
step %{I am an authenticated "admin"}
end
Then /^I should see the access denied message$/ do
Then %{I should see "You are not authorized to access this page"}
step %{I should see "You are not authorized to access this page"}
end
Then /^I am redirected to "([^\"]*)"$/ do |url|

View File

@ -7,7 +7,7 @@ Then /^I should see the role dropdown on the "([^"]*)" without the "([^"]*)" opt
end
Then /^I should see the role dropdown on myself$/ do
Then %{I should see the role dropdown on the "#{@member.role}"}
step %{I should see the role dropdown on the "#{@member.role}"}
end
Then /^I should not see the role dropdown on the "([^"]*)"$/ do |user|
@ -15,7 +15,7 @@ Then /^I should not see the role dropdown on the "([^"]*)"$/ do |user|
end
Then /^I should not see the role dropdown on myself$/ do
Then %{I should not see the role dropdown on the "#{@member.role}"}
step %{I should not see the role dropdown on the "#{@member.role}"}
end
Then /^I should not see any role dropdowns$/ do
@ -31,7 +31,7 @@ Then /^I should not see delete on the "([^"]*)"$/ do |role|
end
Then /^I should not see delete on myself$/ do
Then %{I should not see delete on the "#{@member.role}"}
step %{I should not see delete on the "#{@member.role}"}
end
Then /^I should not see any delete buttons$/ do
@ -39,5 +39,5 @@ Then /^I should not see any delete buttons$/ do
end
When /^I select the "([^"]*)" role for the "author" user/ do |role|
Given %{I select "#{role}" from "site[memberships_attributes][2][role]"}
step %{I select "#{role}" from "site[memberships_attributes][2][role]"}
end

View File

@ -19,7 +19,7 @@ end
Then /^I should be able to view a paginaed list of a has many association$/ do
# Create models
Given %{I have an "Articles" model which has many "Comments"}
step %{I have an "Articles" model which has many "Comments"}
# Create contents
article = @parent_model.contents.create!(:slug => 'parent', :body => 'Parent')

View File

@ -14,7 +14,7 @@ Given /^I have the site: "([^"]*)" set up(?: with #{capture_fields})?$/ do |site
end
Given /^I have a site set up$/ do
Given %{I have the site: "test site" set up}
step %{I have the site: "test site" set up}
end
Given /^I have a designer and an author$/ do

View File

@ -19,12 +19,12 @@ World(WithinHelpers)
# Single-line step scoper
When /^(.*) within (.*[^:])$/ do |step, parent|
with_scope(parent) { When step }
with_scope(parent) { step step }
end
# Multi-line step scoper
When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
with_scope(parent) { When "#{step}:", table_or_string }
with_scope(parent) { step "#{step}:", table_or_string }
end
Given /^(?:|I )am on (.+)$/ do |page_name|
@ -64,7 +64,7 @@ end
#
When /^(?:|I )fill in the following:$/ do |fields|
fields.rows_hash.each do |name, value|
When %{I fill in "#{name}" with "#{value}"}
step %{I fill in "#{name}" with "#{value}"}
end
end
@ -194,4 +194,4 @@ end
Then /^show me the page$/ do
save_and_open_page
end
end

View File

@ -12,7 +12,6 @@ require 'cucumber/rails'
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
require 'cucumber/rails/rspec'
require 'cucumber/rails/world'
require 'cucumber/web/tableish'
require 'capybara'
require 'capybara/rails'
@ -68,4 +67,4 @@ ActionController::Base.allow_rescue = false
require File.expand_path(File.dirname(__FILE__) + '/../../spec/support/carrierwave')
require File.expand_path(File.dirname(__FILE__) + '/../../spec/support/locomotive')
Locomotive.configure_for_test(true)
Locomotive.configure_for_test(true)

View File

@ -20,8 +20,8 @@ module Locomotive
def run!
self.initialize_site_hash
self.log('copying assets')
self.copy_assets
self.log('copying content assets')
self.copy_content_assets
self.log('copying theme assets')
self.copy_theme_assets
@ -163,10 +163,10 @@ module Locomotive
end
end
def copy_assets
@site.assets.each do |asset|
target_path = File.join(self.samples_folder, asset.source_filename)
self.copy_file_from_an_uploader(asset.source, target_path)
def copy_content_assets
@site.content_assets.each do |content_asset|
target_path = File.join(self.samples_folder, content_asset.source_filename)
self.copy_file_from_an_uploader(content_asset.source, target_path)
end
end
@ -340,4 +340,4 @@ module Locomotive
end
end
end

View File

@ -42,7 +42,7 @@ module Locomotive
self.reset! if @options[:reset]
%w(site content_types assets snippets pages).each do |step|
%w(site content_types content_assets snippets pages).each do |step|
if @options[:enabled][step] != false
"Locomotive::Import::#{step.camelize}".constantize.process(context, @options)
@worker.update_attributes :step => step if @worker
@ -162,7 +162,7 @@ module Locomotive
def reset!
@site.pages.destroy_all
@site.assets.destroy_all
@site.content_assets.destroy_all
@site.theme_assets.destroy_all
@site.content_types.destroy_all
end
@ -176,4 +176,4 @@ module Locomotive
end
end
end
end

View File

@ -163,7 +163,7 @@ module Locomotive
end
def absolute_url(url)
url.starts_with('/') ? url : "/#{url}"
url.starts_with?('/') ? url : "/#{url}"
end
end

View File

@ -13,4 +13,4 @@ module Locomotive
end
end
end
end

View File

@ -7,7 +7,7 @@ module Locomotive
super
if !self.contains_super?(@nodelist) # then disable all editable_elements coming from the parent block too and not used
@context[:page].disable_parent_editable_elements(@name)
@context[:page].disable_parent_editable_elements(@name) unless @context[:page].nil?
end
end

View File

@ -9,7 +9,7 @@ module Locomotive
def call(env)
path = env['PATH_INFO']
if !path.starts_with('/admin/') && (match = path.match(%r{(.+)/$}))
if !path.starts_with?('/admin/') && (match = path.match(%r{(.+)/$}))
response = Rack::Response.new
response.redirect(match[1], 301) # moved permanently
response.finish

View File

@ -33,13 +33,13 @@ module Locomotive
def require_site
return true if current_site
redirect_to installation_url and return false if Account.count == 0 || Site.count == 0
redirect_to installation_url and return false if Locomotive::Account.count == 0 || Locomotive::Site.count == 0
render_no_site_error and return false
end
def render_no_site_error
render :template => '/admin/errors/no_site', :layout => false, :status => :not_found
render :template => '/Locomotive/errors/no_site', :layout => false, :status => :not_found
end
def validate_site_membership

View File

@ -55,8 +55,8 @@ Gem::Specification.new do |s|
s.add_dependency 'actionmailer-with-request'
s.add_dependency 'httparty', '0.7.8'
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 'delayed_job', '3.0.0.pre4'
s.add_dependency 'delayed_job_mongoid', '1.0.6'
s.add_dependency 'rubyzip'
s.add_dependency 'locomotive_jammit-s3'

View File

@ -1,10 +1,11 @@
require 'spec_helper'
describe Admin::GlobalActionsCell do
describe Locomotive::GlobalActionsCell do
# FIXME: This does not seem to work correctly, rspec-cells should allow this to be called
# as if it were a controller.
# render_views
render_views
let(:menu) { render_cell('admin/global_actions', :show, :current_locomotive_account => FactoryGirl.build('admin user'), :current_site_url => 'http://www.yahoo.fr') }
let(:menu) { render_cell('locomotive/global_actions', :show, :current_locomotive_account => FactoryGirl.build('admin user'), :current_site_url => 'http://www.yahoo.fr') }
describe 'show menu' do
@ -17,7 +18,7 @@ describe Admin::GlobalActionsCell do
end
it 'has a link to edit my account' do
menu.should have_link('Admin')
menu.should have_link('Locomotive')
end
it 'has a link to see my website' do
@ -34,7 +35,7 @@ describe Admin::GlobalActionsCell do
before(:each) do
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::GlobalActionsCell.update_for(:testing_add) { |m| m.add(:my_link, :label => 'My link', :url => 'http://www.locomotivecms.com') }
Locomotive::GlobalActionsCell.update_for(:testing_add) { |m| m.add(:my_link, :label => 'My link', :url => 'http://www.locomotivecms.com') }
end
it 'has 4 items' do
@ -51,7 +52,7 @@ describe Admin::GlobalActionsCell do
before(:each) do
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::GlobalActionsCell.update_for(:testing_remove) { |m| m.remove(:see) }
Locomotive::GlobalActionsCell.update_for(:testing_remove) { |m| m.remove(:see) }
end
it 'has 2 items' do
@ -68,7 +69,7 @@ describe Admin::GlobalActionsCell do
before(:each) do
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::GlobalActionsCell.update_for(:testing_update) { |m| m.modify(:see, { :label => 'Modified !' }) }
Locomotive::GlobalActionsCell.update_for(:testing_update) { |m| m.modify(:see, { :label => 'Modified !' }) }
end
it 'still has 3 items' do
@ -86,4 +87,4 @@ describe Admin::GlobalActionsCell do
CellsResetter.clean!
end
end
end

View File

@ -1,10 +1,11 @@
require 'spec_helper'
describe Admin::MainMenuCell do
describe Locomotive::MainMenuCell do
# FIXME: This does not seem to work correctly, rspec-cells should allow this to be called
# as if it were a controller.
# render_views
render_views
let(:menu) { render_cell('admin/main_menu', :show) }
let(:menu) { render_cell('locomotive/main_menu', :show) }
describe 'show menu' do
@ -30,7 +31,7 @@ describe Admin::MainMenuCell do
before(:each) do
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::MainMenuCell.update_for(:testing_add) { |m| m.add(:my_link, :label => 'Shop', :url => 'http://www.locomotivecms.com') }
Locomotive::MainMenuCell.update_for(:testing_add) { |m| m.add(:my_link, :label => 'Shop', :url => 'http://www.locomotivecms.com') }
end
it 'has 3 items' do
@ -47,7 +48,7 @@ describe Admin::MainMenuCell do
before(:each) do
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::MainMenuCell.update_for(:testing_remove) { |m| m.remove(:settings) }
Locomotive::MainMenuCell.update_for(:testing_remove) { |m| m.remove(:settings) }
end
it 'has only 1 item' do
@ -64,7 +65,7 @@ describe Admin::MainMenuCell do
before(:each) do
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::MainMenuCell.update_for(:testing_update) { |m| m.modify(:settings, { :label => 'Modified !' }) }
Locomotive::MainMenuCell.update_for(:testing_update) { |m| m.modify(:settings, { :label => 'Modified !' }) }
end
it 'still has 2 items' do
@ -82,4 +83,4 @@ describe Admin::MainMenuCell do
CellsResetter.clean!
end
end
end

View File

@ -1,10 +1,11 @@
require 'spec_helper'
describe Admin::SettingsMenuCell do
describe Locomotive::SettingsMenuCell do
# FIXME: This does not seem to work correctly, rspec-cells should allow this to be called
# as if it were a controller.
# render_views
render_views
let(:menu) { render_cell('admin/settings_menu', :show) }
let(:menu) { render_cell('locomotive/settings_menu', :show) }
describe 'show menu' do
@ -34,7 +35,7 @@ describe Admin::SettingsMenuCell do
before(:each) do
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::SettingsMenuCell.update_for(:testing_add) { |m| m.add(:my_link, :label => 'My link', :url => 'http://www.locomotivecms.com') }
Locomotive::SettingsMenuCell.update_for(:testing_add) { |m| m.add(:my_link, :label => 'My link', :url => 'http://www.locomotivecms.com') }
end
it 'has 4 items' do
@ -51,7 +52,7 @@ describe Admin::SettingsMenuCell do
before(:each) do
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::SettingsMenuCell.update_for(:testing_remove) { |m| m.remove(:theme_assets) }
Locomotive::SettingsMenuCell.update_for(:testing_remove) { |m| m.remove(:theme_assets) }
end
it 'has 2 items' do
@ -68,7 +69,7 @@ describe Admin::SettingsMenuCell do
before(:each) do
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::SettingsMenuCell.update_for(:testing_update) { |m| m.modify(:theme_assets, { :label => 'Modified !' }) }
Locomotive::SettingsMenuCell.update_for(:testing_update) { |m| m.modify(:theme_assets, { :label => 'Modified !' }) }
end
it 'still has 3 items' do
@ -86,4 +87,4 @@ describe Admin::SettingsMenuCell do
CellsResetter.clean!
end
end
end

View File

@ -1,6 +1,6 @@
require 'spec_helper'
describe Admin::ApiContentsController do
describe Locomotive::ApiContentsController do
before(:each) do
@site = FactoryGirl.create('existing site')
@ -88,4 +88,4 @@ describe Admin::ApiContentsController do
}.merge(options)
end
end
end

View File

@ -1,10 +1,20 @@
require 'rubygems'
gemfile = File.expand_path('../../../../Gemfile', __FILE__)
# Need to explicitly use syck for yaml. This fixes a problem with the current
# delayed job parsing of YAML
#
# FIXME: I don't expect end users to have to modify their config/boot.rb for an
# app using the locomotiveCMS gem. Perhaps we can remove this when a newer
# delayed job version is released?
#
require 'yaml'
YAML::ENGINE.yamler = 'syck'
if File.exist?(gemfile)
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
end
$:.unshift File.expand_path('../../../../lib', __FILE__)
$:.unshift File.expand_path('../../../../lib', __FILE__)

View File

@ -1,184 +0,0 @@
require 'spec_helper'
describe 'Bushido support' do
before(:each) do
::Bushido::App.stubs(:subdomain_available?).returns(true)
end
context '#loaded' do
it 'has method to enable bushido' do
Locomotive.respond_to?(:enable_bushido).should be_true
end
it 'tells bushido is disabled' do
Locomotive.bushido?.should be_false
end
it 'does not add instance methods to Site' do
Site.should_not include_instance_method :add_bushido_domains
Site.should_not include_instance_method :remove_bushido_domains
Site.should_not include_class_method :create_first_one_with_bushido
end
end
context '#disabled' do
before(:each) do
Locomotive.configure do |config|
config.hosting = :none
end
end
it 'tells bushido is disabled' do
Locomotive.bushido?.should be_false
end
it 'does not add methods to Site' do
Site.should_not include_instance_method :add_bushido_domains
Site.should_not include_instance_method :remove_bushido_domains
end
end
context '#enabled' do
it 'tells bushido is enabled from ENV' do
ENV['APP_TLD'] = 'bushi.do'
Locomotive.config.hosting = :auto
Locomotive.bushido?.should be_true
end
it 'adds a method to automatically create a site with Bushido settings' do
configure_locomotive_with_bushido
Site.should include_class_method :create_first_one_with_bushido
end
it 'tells bushido is enabled when forcing it' do
configure_locomotive_with_bushido
Locomotive.bushido?.should be_true
end
describe 'events' do
before(:each) do
configure_locomotive_with_bushido
@site = FactoryGirl.build('test site')
@account = @site.memberships.first.account
Account.stubs(:first).returns(@account)
end
it 'responds to the app.claimed event' do
::Bushido::Data.call('app.claimed')
@account.name.should == 'san_francisco'
@account.email.should == 'san_francisco@bushi.do'
end
end
context 'enhancing site' do
before(:each) do
configure_locomotive_with_bushido
@site = FactoryGirl.build('valid site')
end
it 'calls add_bushido_domains after saving a site' do
@site.expects(:add_bushido_domains)
@site.save
end
it 'calls remove_bushido_domains after saving a site' do
@site.expects(:remove_bushido_domains)
@site.destroy
end
context 'adding domain' do
it 'does not add new domain if no delta' do
::Bushido::App.expects(:add_domain).never
@site.save
end
it 'adds a new domain if new one' do
@site.domains = ['www.acme.fr']
::Bushido::App.expects(:add_domain).with('www.acme.fr')
@site.save
Locomotive.bushido_domains.should include('www.acme.fr')
end
end
context 'changing subdomain' do
it 'does not change it if not modified' do
::Bushido::App.expects(:set_subdomain).never
@site.save
end
it 'does not change it if Locomotive is launched with multi sites' do
@site.save
@site.subdomain = 'rope'
::Bushido::App.expects(:set_subdomain).never
@site.save
end
it 'changes the bushido name' do
configure_locomotive_with_bushido do |config|
config.multi_sites = false
end
@site.save
@site.subdomain = 'rope'
::Bushido::App.expects(:set_subdomain).with('rope')
@site.save
end
end
context 'removing domain' do
it 'does not remove domain if no delta' do
::Bushido::App.expects(:remove_domain).never
@site.destroy
end
it 'removes domains if we destroy a site' do
@site.stubs(:domains_without_subdomain).returns(['www.acme.com'])
::Bushido::App.expects(:remove_domain).with('www.acme.com')
@site.destroy
Locomotive.bushido_domains.should_not include('www.acme.com')
end
it 'removes domain if removed' do
::Bushido::App.stubs(:add_domain)
@site.domains = ['www.acme.fr']; @site.save
@site.domains = ['www.acme.com']
::Bushido::App.expects(:remove_domain).with('www.acme.fr')
@site.save
Locomotive.bushido_domains.should_not include('www.acme.fr')
end
end
end
end
def configure_locomotive_with_bushido(&block)
::Bushido::App.stubs(:subdomain).returns('locomotive')
::Bushido::App.stubs(:domains).returns(['www.acme.com', 'example.com', 'www.example.com'])
Locomotive.configure do |config|
config.hosting = :bushido
block.call(config) if block_given?
Locomotive.define_subdomain_and_domains_options
Object.send(:remove_const, 'Site') if Object.const_defined?('Site')
load 'site.rb'
end
end
end

View File

@ -6,7 +6,7 @@ describe Locomotive::Export do
before(:each) do
site = FactoryGirl.build('another site')
Site.stubs(:find).returns(site)
Locomotive::Site.stubs(:find).returns(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 #2', :description => 'More Lorem ipsum', :active => false)
@ -120,9 +120,9 @@ describe Locomotive::Export do
after(:all) do
FileUtils.rm_rf(self.zip_folder) if File.exists?(self.zip_folder)
Site.destroy_all
Locomotive::Site.destroy_all
end
end
end
end

View File

@ -1,175 +0,0 @@
require 'spec_helper'
describe 'Heroku support' do
before(:each) do
::Heroku::Client.any_instance.stubs(:post).returns(true)
::Heroku::Client.any_instance.stubs(:delete).returns(true)
end
context '#loaded' do
it 'has method to enable heroku' do
Locomotive.respond_to?(:enable_heroku).should be_true
end
it 'tells heroku is disabled' do
Locomotive.heroku?.should be_false
end
it 'does not add instance methods to Site' do
Site.should_not include_instance_method :add_heroku_domains
Site.should_not include_instance_method :remove_heroku_domains
Site.should_not include_class_method :create_first_one_with_heroku
end
end
context '#disabled' do
before(:each) do
Locomotive.configure do |config|
config.hosting = :none
end
end
it 'has a nil connection' do
Locomotive.respond_to?(:heroku_connection).should be_false
end
it 'tells heroku is disabled' do
Locomotive.heroku?.should be_false
end
it 'does not add methods to Site' do
Site.should_not include_instance_method :add_heroku_domains
Site.should_not include_instance_method :remove_heroku_domains
end
end
context '#enabled' do
it 'tells heroku is enabled from ENV' do
ENV['HEROKU_SLUG'] = 'test'
Locomotive.config.hosting = :auto
Locomotive.heroku?.should be_true
end
it 'adds a method to automatically create a site with Heroku settings' do
configure_locomotive_with_heroku
Site.should include_class_method :create_first_one_with_heroku
end
it 'tells heroku is enabled when forcing it' do
configure_locomotive_with_heroku
Locomotive.heroku?.should be_true
end
it 'raises an exception if no app name is given' do
lambda {
configure_locomotive_with_heroku(:name => nil)
}.should raise_error
end
context 'dealing with heroku connection' do
it 'opens a heroku connection with provided credentials' do
configure_locomotive_with_heroku
Locomotive.heroku_connection.user.should == 'john@doe.net'
Locomotive.heroku_connection.password.should == 'easyone'
end
it 'opens a heroku connection with env credentials' do
::Heroku::Client.any_instance.stubs(:list_domains).returns([])
ENV['HEROKU_LOGIN'] = 'john@doe.net'; ENV['HEROKU_PASSWORD'] = 'easyone'; ENV['APP_NAME'] = 'test'
Locomotive.configure { |config| config.hosting = :heroku; config.heroku = {} }
Locomotive.heroku_connection.user.should == 'john@doe.net'
Locomotive.heroku_connection.password.should == 'easyone'
end
end
context 'enhancing site' do
before(:each) do
configure_locomotive_with_heroku
@site = FactoryGirl.build('valid site')
end
it 'calls add_heroku_domains after saving a site' do
@site.expects(:add_heroku_domains)
@site.save
end
it 'calls remove_heroku_domains after saving a site' do
@site.expects(:remove_heroku_domains)
@site.destroy
end
context 'adding domain' do
it 'does not add new domain if no delta' do
Locomotive.heroku_connection.expects(:add_domain).never
@site.save
end
it 'adds a new domain if new one' do
@site.domains = ['www.acme.fr']
Locomotive.heroku_connection.expects(:add_domain).with('locomotive', 'www.acme.fr')
@site.save
Locomotive.heroku_domains.should include('www.acme.fr')
end
end
context 'removing domain' do
it 'does not remove domain if no delta' do
Locomotive.heroku_connection.expects(:remove_domain).never
@site.destroy
end
it 'removes domains if we destroy a site' do
@site.stubs(:domains_without_subdomain).returns(['www.acme.com'])
Locomotive.heroku_connection.expects(:remove_domain).with('locomotive', 'www.acme.com')
@site.destroy
Locomotive.heroku_domains.should_not include('www.acme.com')
end
it 'removes domain if removed' do
@site.domains = ['www.acme.fr']; @site.save
@site.domains = ['www.acme.com']
Locomotive.heroku_connection.expects(:remove_domain).with('locomotive', 'www.acme.fr')
@site.save
Locomotive.heroku_domains.should_not include('www.acme.fr')
end
end
end
end
def configure_locomotive_with_heroku(options = {}, domains = nil)
if options.has_key?(:name)
ENV['APP_NAME'] = options.delete(:name)
else
ENV['APP_NAME'] = 'locomotive'
end
::Heroku::Client.any_instance.stubs(:list_domains).with(ENV['APP_NAME']).returns(domains || [
{ :domain => "www.acme.com" }, { :domain => "example.com" }, { :domain => "www.example.com" }
])
Locomotive.configure do |config|
config.hosting = :heroku
config.heroku = { :login => 'john@doe.net', :password => 'easyone' }.merge(options)
Locomotive.define_subdomain_and_domains_options
Object.send(:remove_const, 'Site') if Object.const_defined?('Site')
load 'site.rb'
end
end
end

View File

@ -11,13 +11,13 @@ describe Locomotive::Liquid::Drops::Page do
before(:each) do
@home.stubs(:children).returns([
Page.new(:title => 'Child #1'),
Page.new(:title => 'Child #2'),
Page.new(:title => 'Child #3')
Locomotive::Page.new(:title => 'Child #1'),
Locomotive::Page.new(:title => 'Child #2'),
Locomotive::Page.new(:title => 'Child #3')
])
@home.children.last.stubs(:children).returns([
Page.new(:title => 'Child #3.1'),
Page.new(:title => 'Child #3.2')
Locomotive::Page.new(:title => 'Child #3.1'),
Locomotive::Page.new(:title => 'Child #3.2')
])
end

View File

@ -1,7 +1,6 @@
require 'spec_helper'
describe Locomotive::Liquid::Filters::Resize do
before :each do
@site = FactoryGirl.create(:site)
@theme_asset = FactoryGirl.create(:theme_asset, :source => FixturedAsset.open('5k.png'), :site => @site)
@ -10,13 +9,10 @@ describe Locomotive::Liquid::Filters::Resize do
@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 })
@app = Locomotive::Dragonfly.app
end
describe '#resize' do
context 'when an asset url string is given' do
before :each do
@template = Liquid::Template.parse('{{ asset_url | resize: "40x30" }}')
end
@ -26,13 +22,11 @@ describe Locomotive::Liquid::Filters::Resize do
end
it 'should use the path in the public folder to generate a location' do
@template.render(@context).should == @app.fetch_file("public#{@asset_path}").thumb('40x30').url
@template.render(@context).should == Locomotive::Dragonfly.resize_url(@asset_path, '40x30')
end
end
context 'when a theme asset is given' do
before :each do
@template = Liquid::Template.parse("{{ theme_asset | resize: '300x400' }}")
end
@ -42,13 +36,11 @@ describe Locomotive::Liquid::Filters::Resize do
end
it 'should use the path of the theme asset to generate a location' do
@template.render(@context).should == @app.fetch_file("public#{@theme_asset_path}").thumb('300x400').url
@template.render(@context).should == Locomotive::Dragonfly.resize_url(@theme_asset_path, '300x400')
end
end
context 'when no resize string is given' do
before :each do
@template = Liquid::Template.parse('{{ asset | resize: }}')
end
@ -56,9 +48,6 @@ describe Locomotive::Liquid::Filters::Resize do
it 'should return a liquid error' do
@template.render(@context).should include 'Liquid error: wrong number of arguments'
end
end
end
end
end

View File

@ -21,7 +21,7 @@ describe Locomotive::Liquid::Tags::Editable::Content do
context 'output' do
before :each do
EditableElement.any_instance.stubs(:content).returns("test string")
Locomotive::EditableElement.any_instance.stubs(:content).returns("test string")
end
context 'inheriting from a parent' do

View File

@ -5,18 +5,18 @@ describe Locomotive::Liquid::Tags::Nav do
before(:each) do
@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)
Locomotive::Page.new(:title => 'Child #1', :fullpath => 'child_1', :slug => 'child_1', :published => true),
Locomotive::Page.new(:title => 'Child #2', :fullpath => 'child_2', :slug => 'child_2', :published => true)
]
@home.stubs(:children_with_minimal_attributes).returns(home_children)
@home.stubs(:children).returns(home_children)
other_children = [
Page.new(:title => 'Child #2.1', :fullpath => 'child_2/sub_child_1', :slug => 'sub_child_1', :published => true),
Page.new(:title => 'Child #2.2', :fullpath => 'child_2/sub_child_2', :slug => 'sub_child_2', :published => true),
Page.new(:title => 'Unpublished #2.2', :fullpath => 'child_2/sub_child_unpublishd_2', :slug => 'sub_child_unpublished_2', :published => false),
Page.new(:title => 'Templatized #2.3', :fullpath => 'child_2/sub_child_template_3', :slug => 'sub_child_template_3', :published => true, :templatized => true),
Page.new(:title => 'Unlisted #2.4', :fullpath => 'child_2/sub_child_unlisted_4', :slug => 'sub_child_unlisted_4', :published => true, :listed => false)
Locomotive::Page.new(:title => 'Child #2.1', :fullpath => 'child_2/sub_child_1', :slug => 'sub_child_1', :published => true),
Locomotive::Page.new(:title => 'Child #2.2', :fullpath => 'child_2/sub_child_2', :slug => 'sub_child_2', :published => true),
Locomotive::Page.new(:title => 'Unpublished #2.2', :fullpath => 'child_2/sub_child_unpublishd_2', :slug => 'sub_child_unpublished_2', :published => false),
Locomotive::Page.new(:title => 'Templatized #2.3', :fullpath => 'child_2/sub_child_template_3', :slug => 'sub_child_template_3', :published => true, :templatized => true),
Locomotive::Page.new(:title => 'Unlisted #2.4', :fullpath => 'child_2/sub_child_unlisted_4', :slug => 'sub_child_unlisted_4', :published => true, :listed => false)
]
@home.children.last.stubs(:children_with_minimal_attributes).returns(other_children)
@home.children.last.stubs(:children).returns(other_children)

View File

@ -5,9 +5,9 @@ describe 'Locomotive rendering system' do
before(:each) do
@controller = Locomotive::TestController.new
Site.any_instance.stubs(:create_default_pages!).returns(true)
Locomotive::Site.any_instance.stubs(:create_default_pages!).returns(true)
@site = FactoryGirl.build(:site)
Site.stubs(:find).returns(@site)
Locomotive::Site.stubs(:find).returns(@site)
@controller.current_site = @site
@page = FactoryGirl.build(:page, :site => nil, :published => true)
end
@ -101,7 +101,7 @@ describe 'Locomotive rendering system' do
it 'should return the 404 page if the page does not exist' do
@controller.request.fullpath = '/contact'
(klass = Page).expects(:published).returns([true])
(klass = Locomotive::Page).expects(:published).returns([true])
@controller.current_site.pages.expects(:not_found).returns(klass)
@controller.send(:locomotive_page).should be_true
end
@ -141,7 +141,7 @@ describe 'Locomotive rendering system' do
it 'returns the 404 page if the instance does not exist' do
@content_type.contents.stubs(:where).returns([])
(klass = Page).expects(:published).returns([true])
(klass = Locomotive::Page).expects(:published).returns([true])
@controller.current_site.pages.expects(:not_found).returns(klass)
@controller.send(:locomotive_page).should be_true
@controller.instance_variable_get(:@content_instance).should be_nil
@ -150,7 +150,7 @@ describe 'Locomotive rendering system' do
it 'returns the 404 page if the instance is not visible' do
@content._visible = false
@content_type.contents.stubs(:where).returns([@content])
(klass = Page).expects(:published).returns([true])
(klass = Locomotive::Page).expects(:published).returns([true])
@controller.current_site.pages.expects(:not_found).returns(klass)
@controller.send(:locomotive_page).should be_true
end
@ -167,7 +167,7 @@ describe 'Locomotive rendering system' do
it 'should return the 404 page if the page has not been published yet' do
@controller.request.fullpath = '/contact'
@controller.current_site.pages.expects(:any_in).with({ :fullpath => %w{contact content_type_template} }).returns([@page])
(klass = Page).expects(:published).returns([true])
(klass = Locomotive::Page).expects(:published).returns([true])
@controller.current_site.pages.expects(:not_found).returns(klass)
@controller.send(:locomotive_page).should be_true
end

View File

@ -39,7 +39,7 @@ describe Locomotive::Routing::SiteDispatcher do
end
it 'returns the site with matching domain if there is no current site instance' do
Site.expects(:match_domain).with('host').returns([@site])
Locomotive::Site.expects(:match_domain).with('host').returns([@site])
@controller.send(:fetch_site).should == @site
end
@ -80,7 +80,7 @@ describe Locomotive::Routing::SiteDispatcher do
context 'when there are no accounts' do
before :each do
Account.expects(:count).returns(0)
Locomotive::Account.expects(:count).returns(0)
@controller.instance_variable_set('@_response', ActionDispatch::Response.new)
@controller.expects(:current_site).returns(false)
@ -102,8 +102,8 @@ describe Locomotive::Routing::SiteDispatcher do
context 'when there are no sites' do
before :each do
Account.expects(:count).returns(1)
Site.expects(:count).returns(0)
Locomotive::Account.expects(:count).returns(1)
Locomotive::Site.expects(:count).returns(0)
@controller.instance_variable_set('@_response', ActionDispatch::Response.new)
@controller.expects(:current_site).returns(false)
@ -125,8 +125,8 @@ describe Locomotive::Routing::SiteDispatcher do
context 'when there is no current site' do
before :each do
Account.expects(:count).returns(1)
Site.expects(:count).returns(1)
Locomotive::Account.expects(:count).returns(1)
Locomotive::Site.expects(:count).returns(1)
@controller.instance_variable_set('@_response', ActionDispatch::Response.new)
@controller.expects(:current_site).returns(false)

View File

@ -31,7 +31,7 @@ describe Locomotive::Snippet do
it 'updates templates with the new snippet template' do
@snippet.update_attributes(:template => 'a new template')
Page.find(@page.id).render({}).should == 'a new template'
Locomotive::Page.find(@page.id).render({}).should == 'a new template'
end
end
@ -44,7 +44,7 @@ describe Locomotive::Snippet do
it 'updates templates with the new snippet template' do
@snippet.update_attributes(:template => 'a new template')
Page.find(@page.id).render({}).should == 'a new template'
Locomotive::Page.find(@page.id).render({}).should == 'a new template'
end
end

View File

@ -3,7 +3,7 @@ require 'spec_helper'
describe 'Locomotive::Middlewares::SeoTrailingSlash' do
before(:all) do
Locomotive::Application.instance.instance_variable_set(:@app, nil) # re-initialize the stack
Dummy::Application.instance.instance_variable_set(:@app, nil) # re-initialize the stack
end
it 'does not process the "/" url' do
@ -26,4 +26,4 @@ describe 'Locomotive::Middlewares::SeoTrailingSlash' do
response.status.should be(301)
end
end
end

View File

@ -10,18 +10,18 @@ module CellsResetter
klass_name = name.camelize
::Admin.send(:remove_const, klass_name)
load "#{name}.rb"
::Locomotive.send(:remove_const, klass_name)
load "locomotive/#{name}.rb"
"::Admin::#{klass_name}".constantize.any_instance.stubs(:sections).returns(args.first)
"::Locomotive::#{klass_name}".constantize.any_instance.stubs(:sections).returns(args.first)
end
end
def self.clean!
[:menu_cell, :main_menu_cell, :global_actions_cell, :settings_menu_cell].each do |name|
::Admin.send(:remove_const, "#{name.to_s.camelize}")
load "#{name}.rb"
::Locomotive.send(:remove_const, "#{name.to_s.camelize}")
load "locomotive/#{name}.rb"
end
end
end
end

View File

@ -76,7 +76,7 @@ FactoryGirl.define do
## Memberships ##
factory :membership, :class => Locomotive::Membership do
role 'admin'
account { Account.where(:name => "Bart Simpson").first || Factory('admin user') }
account { Locomotive::Account.where(:name => "Bart Simpson").first || Factory('admin user') }
factory :admin do
role 'admin'