From d5534a4a2b32540e24f24359bdafd794261b8976 Mon Sep 17 00:00:00 2001 From: Andrea Frigido Date: Tue, 27 Sep 2011 09:01:55 +0200 Subject: [PATCH 01/15] Bugfix in snippets with block and editable_elements. --- lib/locomotive/liquid/tags/inherited_block.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/locomotive/liquid/tags/inherited_block.rb b/lib/locomotive/liquid/tags/inherited_block.rb index 6d380e23..858d2cc8 100644 --- a/lib/locomotive/liquid/tags/inherited_block.rb +++ b/lib/locomotive/liquid/tags/inherited_block.rb @@ -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 From 1d1137fa362db0c38558018e61829d024d960dcb Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Sat, 26 Nov 2011 15:57:22 +1100 Subject: [PATCH 02/15] Bumped the rails 3.1.3 --- Gemfile | 2 +- Gemfile.lock | 97 ++++++++++++++++++++++++++-------------------------- 2 files changed, 49 insertions(+), 50 deletions(-) diff --git a/Gemfile b/Gemfile index e2cee4ba..f95e9b33 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index c03be8e1..12ffabc2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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,10 +118,10 @@ 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) @@ -129,7 +129,7 @@ GEM cucumber (>= 1.1.1) nokogiri (>= 1.5.0) daemons (1.1.4) - database_cleaner (0.6.7) + database_cleaner (0.7.0) delayed_job (2.1.4) activesupport (~> 3.0) daemons @@ -141,15 +141,15 @@ GEM 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) @@ -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) From cfd0be5755dee3330641c7ad30db88738b394328 Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Sat, 26 Nov 2011 16:10:47 +1100 Subject: [PATCH 03/15] Controller specs now run. --- .../{admin => locomotive}/api_contents_controller_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename spec/controllers/{admin => locomotive}/api_contents_controller_spec.rb (98%) diff --git a/spec/controllers/admin/api_contents_controller_spec.rb b/spec/controllers/locomotive/api_contents_controller_spec.rb similarity index 98% rename from spec/controllers/admin/api_contents_controller_spec.rb rename to spec/controllers/locomotive/api_contents_controller_spec.rb index f26883f1..4e09f64f 100644 --- a/spec/controllers/admin/api_contents_controller_spec.rb +++ b/spec/controllers/locomotive/api_contents_controller_spec.rb @@ -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 \ No newline at end of file +end From 9a603eb57fa19823b92fa0620a256fdd5eed129d Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Sat, 26 Nov 2011 16:17:24 +1100 Subject: [PATCH 04/15] Removed bushido and heroku lib specs (implemenation already gone). --- spec/lib/locomotive/bushido_spec.rb | 184 ---------------------------- spec/lib/locomotive/heroku_spec.rb | 175 -------------------------- 2 files changed, 359 deletions(-) delete mode 100644 spec/lib/locomotive/bushido_spec.rb delete mode 100644 spec/lib/locomotive/heroku_spec.rb diff --git a/spec/lib/locomotive/bushido_spec.rb b/spec/lib/locomotive/bushido_spec.rb deleted file mode 100644 index 3c5abba8..00000000 --- a/spec/lib/locomotive/bushido_spec.rb +++ /dev/null @@ -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 diff --git a/spec/lib/locomotive/heroku_spec.rb b/spec/lib/locomotive/heroku_spec.rb deleted file mode 100644 index 9c89035d..00000000 --- a/spec/lib/locomotive/heroku_spec.rb +++ /dev/null @@ -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 From fa138b28d0bb12c727025d98eaaf91b4aef931c8 Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Sat, 26 Nov 2011 16:22:48 +1100 Subject: [PATCH 05/15] Fixed some failing export specs. --- lib/locomotive/export.rb | 14 +++++++------- lib/locomotive/import/job.rb | 6 +++--- spec/lib/locomotive/export_spec.rb | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/locomotive/export.rb b/lib/locomotive/export.rb index 602e2440..398d8284 100644 --- a/lib/locomotive/export.rb +++ b/lib/locomotive/export.rb @@ -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 \ No newline at end of file +end diff --git a/lib/locomotive/import/job.rb b/lib/locomotive/import/job.rb index 62f1ab61..63e2cb43 100644 --- a/lib/locomotive/import/job.rb +++ b/lib/locomotive/import/job.rb @@ -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 \ No newline at end of file +end diff --git a/spec/lib/locomotive/export_spec.rb b/spec/lib/locomotive/export_spec.rb index 6faa2b63..cfabb54d 100644 --- a/spec/lib/locomotive/export_spec.rb +++ b/spec/lib/locomotive/export_spec.rb @@ -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 \ No newline at end of file +end From 9f1ce08136cceac5a30edbea01acad5d824c37b0 Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Sat, 26 Nov 2011 16:33:57 +1100 Subject: [PATCH 06/15] Specs are now all running, 190 failures. --- .gitignore | 1 + Gemfile | 2 -- spec/cells/{admin => locomotive}/global_actions_spec.rb | 9 +++++---- spec/cells/{admin => locomotive}/main_menu_cell_spec.rb | 9 +++++---- .../{admin => locomotive}/settings_menu_cell_spec.rb | 9 +++++---- 5 files changed, 16 insertions(+), 14 deletions(-) rename spec/cells/{admin => locomotive}/global_actions_spec.rb (92%) rename spec/cells/{admin => locomotive}/main_menu_cell_spec.rb (91%) rename spec/cells/{admin => locomotive}/settings_menu_cell_spec.rb (91%) diff --git a/.gitignore b/.gitignore index 5cf1f029..393e194d 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ diff --git a/Gemfile b/Gemfile index f95e9b33..331b1828 100644 --- a/Gemfile +++ b/Gemfile @@ -50,8 +50,6 @@ gem 'delayed_job', '~> 2.1.1' gem 'delayed_job_mongoid', '~> 1.0.4' gem 'SystemTimer', :platforms => :ruby_18 - - # The rest of the dependencies are for use when in the locomotive dev environment group :development do diff --git a/spec/cells/admin/global_actions_spec.rb b/spec/cells/locomotive/global_actions_spec.rb similarity index 92% rename from spec/cells/admin/global_actions_spec.rb rename to spec/cells/locomotive/global_actions_spec.rb index 4b4c8297..d9821fb1 100644 --- a/spec/cells/admin/global_actions_spec.rb +++ b/spec/cells/locomotive/global_actions_spec.rb @@ -1,8 +1,9 @@ require 'spec_helper' -describe Admin::GlobalActionsCell do - - render_views +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 let(:menu) { render_cell('admin/global_actions', :show, :current_locomotive_account => FactoryGirl.build('admin user'), :current_site_url => 'http://www.yahoo.fr') } @@ -86,4 +87,4 @@ describe Admin::GlobalActionsCell do CellsResetter.clean! end -end \ No newline at end of file +end diff --git a/spec/cells/admin/main_menu_cell_spec.rb b/spec/cells/locomotive/main_menu_cell_spec.rb similarity index 91% rename from spec/cells/admin/main_menu_cell_spec.rb rename to spec/cells/locomotive/main_menu_cell_spec.rb index ea2e1224..4dc24ed5 100644 --- a/spec/cells/admin/main_menu_cell_spec.rb +++ b/spec/cells/locomotive/main_menu_cell_spec.rb @@ -1,8 +1,9 @@ require 'spec_helper' -describe Admin::MainMenuCell do - - render_views +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 let(:menu) { render_cell('admin/main_menu', :show) } @@ -82,4 +83,4 @@ describe Admin::MainMenuCell do CellsResetter.clean! end -end \ No newline at end of file +end diff --git a/spec/cells/admin/settings_menu_cell_spec.rb b/spec/cells/locomotive/settings_menu_cell_spec.rb similarity index 91% rename from spec/cells/admin/settings_menu_cell_spec.rb rename to spec/cells/locomotive/settings_menu_cell_spec.rb index 95db40b8..2ac44e18 100644 --- a/spec/cells/admin/settings_menu_cell_spec.rb +++ b/spec/cells/locomotive/settings_menu_cell_spec.rb @@ -1,8 +1,9 @@ require 'spec_helper' -describe Admin::SettingsMenuCell do - - render_views +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 let(:menu) { render_cell('admin/settings_menu', :show) } @@ -86,4 +87,4 @@ describe Admin::SettingsMenuCell do CellsResetter.clean! end -end \ No newline at end of file +end From ad6273e2fdb0600c3bbd19cc11061d0c8410ba56 Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Sat, 26 Nov 2011 17:24:34 +1100 Subject: [PATCH 07/15] Lots of spec fixes (mostly namespacing), down to 107 failing specs. --- .../locomotive/extensions/page/templatized.rb | 4 ++-- app/models/locomotive/membership.rb | 4 ++-- lib/locomotive/routing/site_dispatcher.rb | 4 ++-- spec/cells/locomotive/global_actions_spec.rb | 10 +++++----- spec/cells/locomotive/main_menu_cell_spec.rb | 8 ++++---- spec/cells/locomotive/settings_menu_cell_spec.rb | 8 ++++---- spec/lib/locomotive/liquid/drops/page_spec.rb | 10 +++++----- .../liquid/tags/editable/content_spec.rb | 2 +- spec/lib/locomotive/liquid/tags/nav_spec.rb | 14 +++++++------- spec/lib/locomotive/render_spec.rb | 12 ++++++------ .../lib/locomotive/routing/site_dispatcher_spec.rb | 12 ++++++------ spec/models/locomotive/snippet_spec.rb | 4 ++-- spec/requests/seo_trailing_slash_spec.rb | 4 ++-- spec/support/cells.rb | 12 ++++++------ spec/support/factories.rb | 2 +- 15 files changed, 55 insertions(+), 55 deletions(-) diff --git a/app/models/locomotive/extensions/page/templatized.rb b/app/models/locomotive/extensions/page/templatized.rb index 10d7c5fb..5f5d36b8 100644 --- a/app/models/locomotive/extensions/page/templatized.rb +++ b/app/models/locomotive/extensions/page/templatized.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/locomotive/membership.rb b/app/models/locomotive/membership.rb index 0806c74a..9053a6c5 100644 --- a/app/models/locomotive/membership.rb +++ b/app/models/locomotive/membership.rb @@ -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 \ No newline at end of file +end diff --git a/lib/locomotive/routing/site_dispatcher.rb b/lib/locomotive/routing/site_dispatcher.rb index d8494cbb..8bbffa07 100644 --- a/lib/locomotive/routing/site_dispatcher.rb +++ b/lib/locomotive/routing/site_dispatcher.rb @@ -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 diff --git a/spec/cells/locomotive/global_actions_spec.rb b/spec/cells/locomotive/global_actions_spec.rb index d9821fb1..e2db9733 100644 --- a/spec/cells/locomotive/global_actions_spec.rb +++ b/spec/cells/locomotive/global_actions_spec.rb @@ -5,7 +5,7 @@ describe Locomotive::GlobalActionsCell do # as if it were a controller. # 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 @@ -18,7 +18,7 @@ describe Locomotive::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 @@ -35,7 +35,7 @@ describe Locomotive::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 @@ -52,7 +52,7 @@ describe Locomotive::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 @@ -69,7 +69,7 @@ describe Locomotive::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 diff --git a/spec/cells/locomotive/main_menu_cell_spec.rb b/spec/cells/locomotive/main_menu_cell_spec.rb index 4dc24ed5..4521a61a 100644 --- a/spec/cells/locomotive/main_menu_cell_spec.rb +++ b/spec/cells/locomotive/main_menu_cell_spec.rb @@ -5,7 +5,7 @@ describe Locomotive::MainMenuCell do # as if it were a controller. # render_views - let(:menu) { render_cell('admin/main_menu', :show) } + let(:menu) { render_cell('locomotive/main_menu', :show) } describe 'show menu' do @@ -31,7 +31,7 @@ describe Locomotive::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 @@ -48,7 +48,7 @@ describe Locomotive::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 @@ -65,7 +65,7 @@ describe Locomotive::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 diff --git a/spec/cells/locomotive/settings_menu_cell_spec.rb b/spec/cells/locomotive/settings_menu_cell_spec.rb index 2ac44e18..00a8b0f7 100644 --- a/spec/cells/locomotive/settings_menu_cell_spec.rb +++ b/spec/cells/locomotive/settings_menu_cell_spec.rb @@ -5,7 +5,7 @@ describe Locomotive::SettingsMenuCell do # as if it were a controller. # render_views - let(:menu) { render_cell('admin/settings_menu', :show) } + let(:menu) { render_cell('locomotive/settings_menu', :show) } describe 'show menu' do @@ -35,7 +35,7 @@ describe Locomotive::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 @@ -52,7 +52,7 @@ describe Locomotive::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 @@ -69,7 +69,7 @@ describe Locomotive::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 diff --git a/spec/lib/locomotive/liquid/drops/page_spec.rb b/spec/lib/locomotive/liquid/drops/page_spec.rb index 7b9c1e83..7ebc9ed8 100644 --- a/spec/lib/locomotive/liquid/drops/page_spec.rb +++ b/spec/lib/locomotive/liquid/drops/page_spec.rb @@ -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 diff --git a/spec/lib/locomotive/liquid/tags/editable/content_spec.rb b/spec/lib/locomotive/liquid/tags/editable/content_spec.rb index f3eb9ae4..5a78da65 100644 --- a/spec/lib/locomotive/liquid/tags/editable/content_spec.rb +++ b/spec/lib/locomotive/liquid/tags/editable/content_spec.rb @@ -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 diff --git a/spec/lib/locomotive/liquid/tags/nav_spec.rb b/spec/lib/locomotive/liquid/tags/nav_spec.rb index 37a01293..ad4d38aa 100644 --- a/spec/lib/locomotive/liquid/tags/nav_spec.rb +++ b/spec/lib/locomotive/liquid/tags/nav_spec.rb @@ -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) diff --git a/spec/lib/locomotive/render_spec.rb b/spec/lib/locomotive/render_spec.rb index e0de8b58..32a9e8cc 100644 --- a/spec/lib/locomotive/render_spec.rb +++ b/spec/lib/locomotive/render_spec.rb @@ -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 diff --git a/spec/lib/locomotive/routing/site_dispatcher_spec.rb b/spec/lib/locomotive/routing/site_dispatcher_spec.rb index 90d62260..aad6d295 100644 --- a/spec/lib/locomotive/routing/site_dispatcher_spec.rb +++ b/spec/lib/locomotive/routing/site_dispatcher_spec.rb @@ -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) diff --git a/spec/models/locomotive/snippet_spec.rb b/spec/models/locomotive/snippet_spec.rb index a09d62da..e8fcd670 100644 --- a/spec/models/locomotive/snippet_spec.rb +++ b/spec/models/locomotive/snippet_spec.rb @@ -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 diff --git a/spec/requests/seo_trailing_slash_spec.rb b/spec/requests/seo_trailing_slash_spec.rb index 44181075..0f4277d6 100644 --- a/spec/requests/seo_trailing_slash_spec.rb +++ b/spec/requests/seo_trailing_slash_spec.rb @@ -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 \ No newline at end of file +end diff --git a/spec/support/cells.rb b/spec/support/cells.rb index 75fe18e3..21b90f30 100644 --- a/spec/support/cells.rb +++ b/spec/support/cells.rb @@ -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 \ No newline at end of file +end diff --git a/spec/support/factories.rb b/spec/support/factories.rb index e0772c82..ab00d809 100644 --- a/spec/support/factories.rb +++ b/spec/support/factories.rb @@ -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' From 7f7ed896cf82797ec2b48218251d57de17c80be1 Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Sun, 27 Nov 2011 18:22:00 +1100 Subject: [PATCH 08/15] use starts_with? instead of start_with, fixes #253 and #251 --- lib/locomotive/liquid/filters/html.rb | 2 +- lib/locomotive/middlewares/seo_trailing_slash.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/locomotive/liquid/filters/html.rb b/lib/locomotive/liquid/filters/html.rb index e67127d4..6b20aebf 100644 --- a/lib/locomotive/liquid/filters/html.rb +++ b/lib/locomotive/liquid/filters/html.rb @@ -163,7 +163,7 @@ module Locomotive end def absolute_url(url) - url.starts_with('/') ? url : "/#{url}" + url.starts_with?('/') ? url : "/#{url}" end end diff --git a/lib/locomotive/middlewares/seo_trailing_slash.rb b/lib/locomotive/middlewares/seo_trailing_slash.rb index 6f5a1918..ec01afa6 100644 --- a/lib/locomotive/middlewares/seo_trailing_slash.rb +++ b/lib/locomotive/middlewares/seo_trailing_slash.rb @@ -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 From 5c6794d69c8f83c8226d3d2c12863198d4c84f44 Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Sun, 27 Nov 2011 19:02:20 +1100 Subject: [PATCH 09/15] Fixed some failing dragonfly specs. --- lib/locomotive/liquid/filters/resize.rb | 2 +- .../locomotive/liquid/filters/resize_spec.rb | 17 +++-------------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/lib/locomotive/liquid/filters/resize.rb b/lib/locomotive/liquid/filters/resize.rb index 0672ed52..3d499a12 100644 --- a/lib/locomotive/liquid/filters/resize.rb +++ b/lib/locomotive/liquid/filters/resize.rb @@ -13,4 +13,4 @@ module Locomotive end end -end \ No newline at end of file +end diff --git a/spec/lib/locomotive/liquid/filters/resize_spec.rb b/spec/lib/locomotive/liquid/filters/resize_spec.rb index 880ed397..8ef3097b 100644 --- a/spec/lib/locomotive/liquid/filters/resize_spec.rb +++ b/spec/lib/locomotive/liquid/filters/resize_spec.rb @@ -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 \ No newline at end of file +end From 0f09c577d09c5ba39d3ba7ce347980b548dbcdf2 Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Sun, 27 Nov 2011 19:29:09 +1100 Subject: [PATCH 10/15] New capybara and selenium version, works in FF8 now. --- Gemfile.lock | 22 +++++++++---------- features/step_definitions/admin_steps.rb | 12 +++++----- .../step_definitions/current_site_steps.rb | 8 +++---- features/step_definitions/has_many_steps.rb | 2 +- features/step_definitions/site_steps.rb | 2 +- features/step_definitions/web_steps.rb | 8 +++---- features/support/env.rb | 3 +-- 7 files changed, 28 insertions(+), 29 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ceb24d1b..2ca27abb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,7 +53,7 @@ GEM bushido_stub (0.0.3) activesupport (>= 3.0.7) cancan (1.6.5) - capybara (1.1.1) + capybara (1.1.2) mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) @@ -70,15 +70,15 @@ GEM columnize (0.3.4) configuration (1.3.1) crack (0.1.8) - cucumber (1.1.0) + cucumber (1.1.3) builder (>= 2.1.2) diff-lcs (>= 1.1.2) - gherkin (~> 2.5.0) + gherkin (~> 2.6.7) json (>= 1.4.6) term-ansicolor (>= 1.0.6) - cucumber-rails (1.1.1) + cucumber-rails (1.2.0) capybara (>= 1.1.1) - cucumber (>= 1.1.0) + cucumber (>= 1.1.1) nokogiri (>= 1.5.0) custom_fields (1.0.0.beta.25) activesupport (~> 3.0.9) @@ -110,7 +110,7 @@ GEM factory_girl_rails (1.2.0) factory_girl (~> 2.1.0) railties (>= 3.0.0) - ffi (1.0.9) + ffi (1.0.11) fog (0.8.2) builder excon (~> 0.6.1) @@ -125,7 +125,7 @@ GEM actionpack (>= 2.3.7) activesupport (>= 2.3.7) i18n (~> 0.4) - gherkin (2.5.2) + gherkin (2.6.8) json (>= 1.4.6) growl-glue (1.0.7) haml (3.1.2) @@ -166,7 +166,7 @@ GEM i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - mime-types (1.16) + mime-types (1.17.2) mimemagic (0.1.8) mimetype-fu (0.1.2) mocha (0.9.12) @@ -248,15 +248,15 @@ GEM archive-tar-minitar (>= 0.5.2) rubycas-client (2.2.1) activesupport - rubyzip (0.9.4) + rubyzip (0.9.5) s3 (0.3.8) proxies (~> 0.2.0) sanitize (2.0.3) nokogiri (>= 1.4.4, < 1.6) sass (3.1.2) - selenium-webdriver (2.8.0) + selenium-webdriver (2.13.0) childprocess (>= 0.2.1) - ffi (>= 1.0.7) + ffi (~> 1.0.9) json_pure rubyzip spork (0.9.0.rc9) diff --git a/features/step_definitions/admin_steps.rb b/features/step_definitions/admin_steps.rb index 42ad9c29..2a85d18b 100644 --- a/features/step_definitions/admin_steps.rb +++ b/features/step_definitions/admin_steps.rb @@ -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| diff --git a/features/step_definitions/current_site_steps.rb b/features/step_definitions/current_site_steps.rb index e2dc0545..abef1b24 100644 --- a/features/step_definitions/current_site_steps.rb +++ b/features/step_definitions/current_site_steps.rb @@ -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 diff --git a/features/step_definitions/has_many_steps.rb b/features/step_definitions/has_many_steps.rb index 4d4e5ce0..45455f41 100644 --- a/features/step_definitions/has_many_steps.rb +++ b/features/step_definitions/has_many_steps.rb @@ -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') diff --git a/features/step_definitions/site_steps.rb b/features/step_definitions/site_steps.rb index ee03442a..6746fb14 100644 --- a/features/step_definitions/site_steps.rb +++ b/features/step_definitions/site_steps.rb @@ -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 diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb index b82f78eb..b7663109 100644 --- a/features/step_definitions/web_steps.rb +++ b/features/step_definitions/web_steps.rb @@ -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 \ No newline at end of file +end diff --git a/features/support/env.rb b/features/support/env.rb index efcb084c..a1c12dda 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -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) \ No newline at end of file +Locomotive.configure_for_test(true) From 83da41a2b1836727551e70165a80d8e629d84021 Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Sun, 27 Nov 2011 19:35:08 +1100 Subject: [PATCH 11/15] Add the travis-ci button to the readme. --- README.textile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.textile b/README.textile index 263ed9cb..da1e6451 100644 --- a/README.textile +++ b/README.textile @@ -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: From 9b049aa0551b41595058e361c85ecb8e0a44b092 Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Sun, 27 Nov 2011 19:44:06 +1100 Subject: [PATCH 12/15] Bumped delayed job versions, fixes #249. --- Gemfile | 4 ++-- Gemfile.lock | 16 ++++++++-------- locomotive_cms.gemspec | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index 8c72a1f1..7cfe99b4 100644 --- a/Gemfile +++ b/Gemfile @@ -36,8 +36,8 @@ gem 'actionmailer-with-request', :require => 'actionmailer_with_request' gem 'heroku', '1.19.1' gem 'httparty', '0.7.8' gem 'RedCloth', '4.2.8' -gem 'delayed_job', '2.1.4' -gem 'delayed_job_mongoid', '1.0.2' +gem 'delayed_job', '3.0.0.pre4' +gem 'delayed_job_mongoid', '1.0.6' gem 'rubyzip' gem 'locomotive_jammit-s3', :require => 'jammit-s3' gem 'SystemTimer', :platforms => :ruby_18 diff --git a/Gemfile.lock b/Gemfile.lock index 2ca27abb..4677670d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -83,14 +83,14 @@ GEM custom_fields (1.0.0.beta.25) activesupport (~> 3.0.9) mongoid (= 2.0.2) - daemons (1.1.4) + daemons (1.0.10) database_cleaner (0.6.7) - delayed_job (2.1.4) + delayed_job (3.0.0.pre4) activesupport (~> 3.0) - daemons - delayed_job_mongoid (1.0.2) - delayed_job (~> 2.1.1) - mongoid (~> 2.0.0.rc) + daemons (= 1.0.10) + delayed_job_mongoid (1.0.6) + delayed_job (= 3.0.0.pre4) + mongoid (>= 2.0) devise (1.3.4) bcrypt-ruby (~> 2.1.2) orm_adapter (~> 0.0.3) @@ -297,8 +297,8 @@ DEPENDENCIES cucumber-rails custom_fields (= 1.0.0.beta.25) database_cleaner - delayed_job (= 2.1.4) - delayed_job_mongoid (= 1.0.2) + delayed_job (= 3.0.0.pre4) + delayed_job_mongoid (= 1.0.6) devise (= 1.3.4) devise_bushido_authenticatable (= 1.0.0.alpha10) dragonfly (~> 0.9.1) diff --git a/locomotive_cms.gemspec b/locomotive_cms.gemspec index 41c58d10..d90e4f4f 100644 --- a/locomotive_cms.gemspec +++ b/locomotive_cms.gemspec @@ -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' From 05d9990e69bb7bda321012dc14a8090c690d42b9 Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Sun, 27 Nov 2011 20:05:39 +1100 Subject: [PATCH 13/15] Use syck for yaml, fixes an issuew with new delayed job. --- config/boot.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/boot.rb b/config/boot.rb index 712b0981..c3c5221e 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,9 @@ require 'rubygems' + +# Need to explicitly use syck for yaml +require 'yaml' +YAML::ENGINE.yamler = 'syck' + # Set up gems listed in the Gemfile. if File.exist?(File.expand_path('../../Gemfile', __FILE__)) require 'bundler' From 1a350e7d0cab46ddeca09f018a87ce09324494ec Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Sun, 27 Nov 2011 20:17:08 +1100 Subject: [PATCH 14/15] Updated readme to include community information. --- README.textile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.textile b/README.textile index da1e6451..a3b1b0b4 100644 --- a/README.textile +++ b/README.textile @@ -35,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 From 867878a4f45e2928e69fc8a3932b1304f55e6f9d Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Sun, 27 Nov 2011 21:21:27 +1100 Subject: [PATCH 15/15] Test on ruby 1.9.3, removed the require for ruby-debug19 as it breaks on 1.9.3 --- .travis.yml | 1 + Gemfile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9f17598d..f81ffde1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Gemfile b/Gemfile index 7cfe99b4..116f5e44 100644 --- a/Gemfile +++ b/Gemfile @@ -58,7 +58,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 'bushido_stub', '0.0.3'