fixing specs (wip) + cell specs are fine
This commit is contained in:
parent
87c8f3bfd7
commit
64a050dff9
14
Gemfile
14
Gemfile
@ -11,7 +11,7 @@ group :development do
|
|||||||
gem 'custom_fields', :path => '../gems/custom_fields' # Locale
|
gem 'custom_fields', :path => '../gems/custom_fields' # Locale
|
||||||
# # gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git', :branch => '2.0.0.rc' # Branch on Github
|
# # gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git', :branch => '2.0.0.rc' # Branch on Github
|
||||||
|
|
||||||
gem 'rspec-rails', '2.6.1' # In order to have rspec tasks and generators
|
gem 'rspec-rails', '~> 2.8.0' # In order to have rspec tasks and generators
|
||||||
gem 'rspec-cells'
|
gem 'rspec-cells'
|
||||||
|
|
||||||
gem 'unicorn' # Using unicorn_rails instead of webrick (default server)
|
gem 'unicorn' # Using unicorn_rails instead of webrick (default server)
|
||||||
@ -28,16 +28,16 @@ end
|
|||||||
group :test do
|
group :test do
|
||||||
gem 'launchy'
|
gem 'launchy'
|
||||||
|
|
||||||
gem 'autotest', :platforms => :mri
|
# gem 'autotest', :platforms => :mri
|
||||||
gem 'ZenTest', :platforms => :mri
|
# gem 'ZenTest', :platforms => :mri
|
||||||
|
|
||||||
gem 'growl-glue'
|
# gem 'growl-glue'
|
||||||
|
|
||||||
gem 'cucumber-rails'
|
# gem 'cucumber-rails'
|
||||||
gem 'rspec-rails', '2.6.1'
|
gem 'rspec-rails', '~> 2.8.0'
|
||||||
gem 'shoulda-matchers'
|
gem 'shoulda-matchers'
|
||||||
|
|
||||||
gem 'factory_girl_rails', '~> 1.3.0'
|
gem 'factory_girl_rails', '~> 1.6.0'
|
||||||
gem 'pickle'
|
gem 'pickle'
|
||||||
gem 'mocha', '0.9.12' # :git => 'git://github.com/floehopper/mocha.git'
|
gem 'mocha', '0.9.12' # :git => 'git://github.com/floehopper/mocha.git'
|
||||||
|
|
||||||
|
48
Gemfile.lock
48
Gemfile.lock
@ -65,7 +65,6 @@ GEM
|
|||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
RedCloth (4.2.9)
|
RedCloth (4.2.9)
|
||||||
ZenTest (4.6.2)
|
|
||||||
actionmailer (3.2.1)
|
actionmailer (3.2.1)
|
||||||
actionpack (= 3.2.1)
|
actionpack (= 3.2.1)
|
||||||
mail (~> 2.4.0)
|
mail (~> 2.4.0)
|
||||||
@ -97,8 +96,6 @@ GEM
|
|||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
addressable (2.2.6)
|
addressable (2.2.6)
|
||||||
arel (3.0.0)
|
arel (3.0.0)
|
||||||
autotest (4.4.6)
|
|
||||||
ZenTest (>= 4.4.1)
|
|
||||||
bcrypt-ruby (3.0.1)
|
bcrypt-ruby (3.0.1)
|
||||||
bson (1.5.2)
|
bson (1.5.2)
|
||||||
bson_ext (1.5.2)
|
bson_ext (1.5.2)
|
||||||
@ -138,10 +135,6 @@ GEM
|
|||||||
gherkin (~> 2.7.1)
|
gherkin (~> 2.7.1)
|
||||||
json (>= 1.4.6)
|
json (>= 1.4.6)
|
||||||
term-ansicolor (>= 1.0.6)
|
term-ansicolor (>= 1.0.6)
|
||||||
cucumber-rails (1.2.1)
|
|
||||||
capybara (>= 1.1.2)
|
|
||||||
cucumber (>= 1.1.3)
|
|
||||||
nokogiri (>= 1.5.0)
|
|
||||||
database_cleaner (0.7.1)
|
database_cleaner (0.7.1)
|
||||||
devise (1.5.3)
|
devise (1.5.3)
|
||||||
bcrypt-ruby (~> 3.0)
|
bcrypt-ruby (~> 3.0)
|
||||||
@ -155,10 +148,10 @@ GEM
|
|||||||
excon (0.7.12)
|
excon (0.7.12)
|
||||||
execjs (1.3.0)
|
execjs (1.3.0)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
factory_girl (2.2.0)
|
factory_girl (2.5.2)
|
||||||
activesupport
|
activesupport (>= 2.3.9)
|
||||||
factory_girl_rails (1.3.0)
|
factory_girl_rails (1.6.0)
|
||||||
factory_girl (~> 2.2.0)
|
factory_girl (~> 2.5.0)
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
ffi (1.0.11)
|
ffi (1.0.11)
|
||||||
flash_cookie_session (1.1.1)
|
flash_cookie_session (1.1.1)
|
||||||
@ -179,7 +172,6 @@ GEM
|
|||||||
fssm (0.2.8.1)
|
fssm (0.2.8.1)
|
||||||
gherkin (2.7.6)
|
gherkin (2.7.6)
|
||||||
json (>= 1.4.6)
|
json (>= 1.4.6)
|
||||||
growl-glue (1.0.7)
|
|
||||||
haml (3.1.4)
|
haml (3.1.4)
|
||||||
highline (1.6.11)
|
highline (1.6.11)
|
||||||
hike (1.2.1)
|
hike (1.2.1)
|
||||||
@ -262,23 +254,23 @@ GEM
|
|||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
responders (0.6.5)
|
responders (0.6.5)
|
||||||
rmagick (2.12.2)
|
rmagick (2.12.2)
|
||||||
rspec (2.6.0)
|
rspec (2.8.0)
|
||||||
rspec-core (~> 2.6.0)
|
rspec-core (~> 2.8.0)
|
||||||
rspec-expectations (~> 2.6.0)
|
rspec-expectations (~> 2.8.0)
|
||||||
rspec-mocks (~> 2.6.0)
|
rspec-mocks (~> 2.8.0)
|
||||||
rspec-cells (0.1.2)
|
rspec-cells (0.1.2)
|
||||||
cells (~> 3.4)
|
cells (~> 3.4)
|
||||||
rails (~> 3.0)
|
rails (~> 3.0)
|
||||||
rspec-rails (~> 2.2)
|
rspec-rails (~> 2.2)
|
||||||
rspec-core (2.6.4)
|
rspec-core (2.8.0)
|
||||||
rspec-expectations (2.6.0)
|
rspec-expectations (2.8.0)
|
||||||
diff-lcs (~> 1.1.2)
|
diff-lcs (~> 1.1.2)
|
||||||
rspec-mocks (2.6.0)
|
rspec-mocks (2.8.0)
|
||||||
rspec-rails (2.6.1)
|
rspec-rails (2.8.1)
|
||||||
actionpack (~> 3.0)
|
actionpack (>= 3.0)
|
||||||
activesupport (~> 3.0)
|
activesupport (>= 3.0)
|
||||||
railties (~> 3.0)
|
railties (>= 3.0)
|
||||||
rspec (~> 2.6.0)
|
rspec (~> 2.8.0)
|
||||||
ruby-hmac (0.4.0)
|
ruby-hmac (0.4.0)
|
||||||
rubyzip (0.9.5)
|
rubyzip (0.9.5)
|
||||||
sanitize (2.0.3)
|
sanitize (2.0.3)
|
||||||
@ -321,23 +313,19 @@ PLATFORMS
|
|||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
ZenTest
|
|
||||||
autotest
|
|
||||||
capybara
|
capybara
|
||||||
coffee-rails (~> 3.2.2)
|
coffee-rails (~> 3.2.2)
|
||||||
compass!
|
compass!
|
||||||
compass-rails!
|
compass-rails!
|
||||||
cucumber-rails
|
|
||||||
custom_fields!
|
custom_fields!
|
||||||
database_cleaner
|
database_cleaner
|
||||||
factory_girl_rails (~> 1.3.0)
|
factory_girl_rails (~> 1.6.0)
|
||||||
growl-glue
|
|
||||||
launchy
|
launchy
|
||||||
locomotive_cms!
|
locomotive_cms!
|
||||||
mocha (= 0.9.12)
|
mocha (= 0.9.12)
|
||||||
pickle
|
pickle
|
||||||
rspec-cells
|
rspec-cells
|
||||||
rspec-rails (= 2.6.1)
|
rspec-rails (~> 2.8.0)
|
||||||
sass-rails (~> 3.2.4)
|
sass-rails (~> 3.2.4)
|
||||||
shoulda-matchers
|
shoulda-matchers
|
||||||
uglifier (~> 1.2.3)
|
uglifier (~> 1.2.3)
|
||||||
|
172
Rakefile
172
Rakefile
@ -1,77 +1,107 @@
|
|||||||
require File.expand_path('../config/application', __FILE__)
|
#!/usr/bin/env rake
|
||||||
|
begin
|
||||||
require 'rubygems'
|
require 'bundler/setup'
|
||||||
|
rescue LoadError
|
||||||
require 'rake/dsl_definition'
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
||||||
require 'rake'
|
|
||||||
require 'rdoc/task'
|
|
||||||
require 'rubygems/package_task'
|
|
||||||
|
|
||||||
Locomotive::Application.load_tasks
|
|
||||||
|
|
||||||
gemspec = eval(File.read('locomotive_cms.gemspec'))
|
|
||||||
Gem::PackageTask.new(gemspec) do |pkg|
|
|
||||||
pkg.gem_spec = gemspec
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'build the gem and release it to rubygems.org'
|
# begin
|
||||||
task :release => :gem do
|
# require 'rdoc/task'
|
||||||
sh "gem push pkg/custom_fields-#{gemspec.version}.gem"
|
# rescue LoadError
|
||||||
end
|
# require 'rdoc/rdoc'
|
||||||
|
# require 'rake/rdoctask'
|
||||||
|
# RDoc::Task = Rake::RDocTask
|
||||||
|
# end
|
||||||
|
|
||||||
task :default => [:spec, :cucumber]
|
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
||||||
|
|
||||||
# only for running the tests suite in the order observed in *nix systems
|
load 'lib/tasks/locomotive.rake'
|
||||||
task :spec_nix do
|
|
||||||
files = %w(
|
|
||||||
lib/core_ext_spec.rb
|
|
||||||
lib/locomotive/routing/site_dispatcher_spec.rb
|
|
||||||
lib/locomotive/bushido_spec.rb
|
|
||||||
lib/locomotive/render_spec.rb
|
|
||||||
lib/locomotive/httparty/patches_spec.rb
|
|
||||||
lib/locomotive/httparty/webservice_spec.rb
|
|
||||||
lib/locomotive/configuration_spec.rb
|
|
||||||
lib/locomotive/liquid/tags/consume_spec.rb
|
|
||||||
lib/locomotive/liquid/tags/with_scope_spec.rb
|
|
||||||
lib/locomotive/liquid/tags/nav_spec.rb
|
|
||||||
lib/locomotive/liquid/tags/editable/content_spec.rb
|
|
||||||
lib/locomotive/liquid/tags/editable/short_text_spec.rb
|
|
||||||
lib/locomotive/liquid/tags/seo_spec.rb
|
|
||||||
lib/locomotive/liquid/tags/paginate_spec.rb
|
|
||||||
lib/locomotive/liquid/drops/content_spec.rb
|
|
||||||
lib/locomotive/liquid/drops/contents_spec.rb
|
|
||||||
lib/locomotive/liquid/drops/page_spec.rb
|
|
||||||
lib/locomotive/liquid/drops/site_spec.rb
|
|
||||||
lib/locomotive/liquid/filters/resize_spec.rb
|
|
||||||
lib/locomotive/liquid/filters/html_spec.rb
|
|
||||||
lib/locomotive/liquid/filters/date_spec.rb
|
|
||||||
lib/locomotive/liquid/filters/text_spec.rb
|
|
||||||
lib/locomotive/liquid/filters/misc_spec.rb
|
|
||||||
lib/locomotive/heroku_spec.rb
|
|
||||||
models/content_entry_spec.rb
|
|
||||||
models/editable_element_spec.rb
|
|
||||||
models/account_spec.rb
|
|
||||||
models/content_type_spec.rb
|
|
||||||
models/snippet_spec.rb
|
|
||||||
models/ability_spec.rb
|
|
||||||
models/membership_spec.rb
|
|
||||||
models/page_spec.rb
|
|
||||||
models/asset_spec.rb
|
|
||||||
models/theme_asset_spec.rb
|
|
||||||
models/site_spec.rb
|
|
||||||
cells/admin/main_menu_cell_spec.rb
|
|
||||||
cells/admin/global_actions_spec.rb
|
|
||||||
cells/admin/settings_menu_cell_spec.rb
|
|
||||||
requests/seo_trailing_slash_spec.rb
|
|
||||||
).collect { |f| File.join('spec', f) }.join(' ')
|
|
||||||
|
|
||||||
sh "bundle exec rspec #{files}"
|
# FIXME: it is disabled because it loaded twice the Locomotive engine
|
||||||
end
|
# load 'rails/tasks/engine.rake'
|
||||||
|
|
||||||
task :travis do
|
require 'rspec/core/rake_task'
|
||||||
["rspec spec", "cucumber -b"].each do |cmd|
|
RSpec::Core::RakeTask.new(:spec)
|
||||||
puts "Starting to run #{cmd}..."
|
|
||||||
system("export DISPLAY=:99.0 && bundle exec #{cmd}")
|
task :default => :spec
|
||||||
raise "#{cmd} failed!" unless $?.exitstatus == 0
|
|
||||||
end
|
Bundler::GemHelper.install_tasks
|
||||||
end
|
|
||||||
|
|
||||||
|
# # require File.expand_path('../config/application', __FILE__)
|
||||||
|
#
|
||||||
|
# require 'rubygems'
|
||||||
|
#
|
||||||
|
# require 'rake/dsl_definition'
|
||||||
|
# require 'rake'
|
||||||
|
# require 'rdoc/task'
|
||||||
|
# require 'rubygems/package_task'
|
||||||
|
#
|
||||||
|
# # Locomotive::Application.load_tasks
|
||||||
|
#
|
||||||
|
# gemspec = eval(File.read('locomotive_cms.gemspec'))
|
||||||
|
# Gem::PackageTask.new(gemspec) do |pkg|
|
||||||
|
# pkg.gem_spec = gemspec
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# desc 'build the gem and release it to rubygems.org'
|
||||||
|
# task :release => :gem do
|
||||||
|
# sh "gem push pkg/custom_fields-#{gemspec.version}.gem"
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# task :default => [:spec, :cucumber]
|
||||||
|
#
|
||||||
|
# # only for running the tests suite in the order observed in *nix systems
|
||||||
|
# task :spec_nix do
|
||||||
|
# files = %w(
|
||||||
|
# lib/core_ext_spec.rb
|
||||||
|
# lib/locomotive/routing/site_dispatcher_spec.rb
|
||||||
|
# lib/locomotive/bushido_spec.rb
|
||||||
|
# lib/locomotive/render_spec.rb
|
||||||
|
# lib/locomotive/httparty/patches_spec.rb
|
||||||
|
# lib/locomotive/httparty/webservice_spec.rb
|
||||||
|
# lib/locomotive/configuration_spec.rb
|
||||||
|
# lib/locomotive/liquid/tags/consume_spec.rb
|
||||||
|
# lib/locomotive/liquid/tags/with_scope_spec.rb
|
||||||
|
# lib/locomotive/liquid/tags/nav_spec.rb
|
||||||
|
# lib/locomotive/liquid/tags/editable/content_spec.rb
|
||||||
|
# lib/locomotive/liquid/tags/editable/short_text_spec.rb
|
||||||
|
# lib/locomotive/liquid/tags/seo_spec.rb
|
||||||
|
# lib/locomotive/liquid/tags/paginate_spec.rb
|
||||||
|
# lib/locomotive/liquid/drops/content_spec.rb
|
||||||
|
# lib/locomotive/liquid/drops/contents_spec.rb
|
||||||
|
# lib/locomotive/liquid/drops/page_spec.rb
|
||||||
|
# lib/locomotive/liquid/drops/site_spec.rb
|
||||||
|
# lib/locomotive/liquid/filters/resize_spec.rb
|
||||||
|
# lib/locomotive/liquid/filters/html_spec.rb
|
||||||
|
# lib/locomotive/liquid/filters/date_spec.rb
|
||||||
|
# lib/locomotive/liquid/filters/text_spec.rb
|
||||||
|
# lib/locomotive/liquid/filters/misc_spec.rb
|
||||||
|
# lib/locomotive/heroku_spec.rb
|
||||||
|
# models/content_entry_spec.rb
|
||||||
|
# models/editable_element_spec.rb
|
||||||
|
# models/account_spec.rb
|
||||||
|
# models/content_type_spec.rb
|
||||||
|
# models/snippet_spec.rb
|
||||||
|
# models/ability_spec.rb
|
||||||
|
# models/membership_spec.rb
|
||||||
|
# models/page_spec.rb
|
||||||
|
# models/asset_spec.rb
|
||||||
|
# models/theme_asset_spec.rb
|
||||||
|
# models/site_spec.rb
|
||||||
|
# cells/admin/main_menu_cell_spec.rb
|
||||||
|
# cells/admin/global_actions_spec.rb
|
||||||
|
# cells/admin/settings_menu_cell_spec.rb
|
||||||
|
# requests/seo_trailing_slash_spec.rb
|
||||||
|
# ).collect { |f| File.join('spec', f) }.join(' ')
|
||||||
|
#
|
||||||
|
# sh "bundle exec rspec #{files}"
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# task :travis do
|
||||||
|
# ["rspec spec", "cucumber -b"].each do |cmd|
|
||||||
|
# puts "Starting to run #{cmd}..."
|
||||||
|
# system("export DISPLAY=:99.0 && bundle exec #{cmd}")
|
||||||
|
# raise "#{cmd} failed!" unless $?.exitstatus == 0
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
require 'locomotive'
|
# require 'locomotive'
|
||||||
require 'highline/import'
|
# require 'highline/import'
|
||||||
|
|
||||||
namespace :locomotive do
|
namespace :locomotive do
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Locomotive::GlobalActionsCell do
|
describe Locomotive::GlobalActionsCell do
|
||||||
|
|
||||||
let(:menu) { render_cell('locomotive/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
|
describe 'show menu' do
|
||||||
|
|
||||||
before(:each) do
|
before(:all) do
|
||||||
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
|
reset_cell(:main => 'settings', :sub => 'site')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has 3 links' do
|
it 'has 3 links' do
|
||||||
@ -14,6 +15,7 @@ describe Locomotive::GlobalActionsCell do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'has a link to edit my account' do
|
it 'has a link to edit my account' do
|
||||||
|
puts "last test"
|
||||||
menu.should have_link('Admin')
|
menu.should have_link('Admin')
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,8 +31,8 @@ describe Locomotive::GlobalActionsCell do
|
|||||||
|
|
||||||
describe 'add a new menu item' do
|
describe 'add a new menu item' do
|
||||||
|
|
||||||
before(:each) do
|
before(:all) do
|
||||||
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
|
reset_cell(:main => 'settings', :sub => 'site')
|
||||||
Locomotive::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
|
end
|
||||||
|
|
||||||
@ -46,8 +48,8 @@ describe Locomotive::GlobalActionsCell do
|
|||||||
|
|
||||||
describe 'remove a new menu item' do
|
describe 'remove a new menu item' do
|
||||||
|
|
||||||
before(:each) do
|
before(:all) do
|
||||||
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
|
reset_cell(:main => 'settings', :sub => 'site')
|
||||||
Locomotive::GlobalActionsCell.update_for(:testing_remove) { |m| m.remove(:see) }
|
Locomotive::GlobalActionsCell.update_for(:testing_remove) { |m| m.remove(:see) }
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -63,8 +65,8 @@ describe Locomotive::GlobalActionsCell do
|
|||||||
|
|
||||||
describe 'modify an existing menu item' do
|
describe 'modify an existing menu item' do
|
||||||
|
|
||||||
before(:each) do
|
before(:all) do
|
||||||
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
|
reset_cell(:main => 'settings', :sub => 'site')
|
||||||
Locomotive::GlobalActionsCell.update_for(:testing_update) { |m| m.modify(:see, { :label => 'Modified !' }) }
|
Locomotive::GlobalActionsCell.update_for(:testing_update) { |m| m.modify(:see, { :label => 'Modified !' }) }
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -80,7 +82,18 @@ describe Locomotive::GlobalActionsCell do
|
|||||||
end
|
end
|
||||||
|
|
||||||
after(:all) do
|
after(:all) do
|
||||||
CellsResetter.clean!
|
reset_cell
|
||||||
|
end
|
||||||
|
|
||||||
|
def reset_cell(attributes = {})
|
||||||
|
::Locomotive.send(:remove_const, 'GlobalActionsCell')
|
||||||
|
|
||||||
|
cell_path = File.join(File.dirname(__FILE__), '../../../app/cells/locomotive/global_actions_cell.rb')
|
||||||
|
load cell_path
|
||||||
|
|
||||||
|
unless attributes.empty?
|
||||||
|
Locomotive::GlobalActionsCell.any_instance.stubs(:sections).returns(attributes)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,20 +1,15 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Locomotive::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
|
|
||||||
|
|
||||||
let(:menu) { render_cell('locomotive/main_menu', :show) }
|
let(:menu) { render_cell('locomotive/main_menu', :show) }
|
||||||
|
|
||||||
describe 'show menu' do
|
describe 'show menu' do
|
||||||
|
|
||||||
before(:each) do
|
before(:all) { reset_cell }
|
||||||
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has 2 items' do
|
it 'has 3 items' do
|
||||||
menu.should have_selector('li.entry', :count => 2)
|
menu.should have_selector('li.entry', :count => 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has a link to go to the contents' do
|
it 'has a link to go to the contents' do
|
||||||
@ -25,17 +20,21 @@ describe Locomotive::MainMenuCell do
|
|||||||
menu.should have_link('Settings')
|
menu.should have_link('Settings')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'has a link to go the foo tab' do
|
||||||
|
menu.should have_link('My FOO menu')
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'add a new menu item' do
|
describe 'add a new menu item' do
|
||||||
|
|
||||||
before(:each) do
|
before(:all) do
|
||||||
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
|
reset_cell(:main => 'settings', :sub => 'site')
|
||||||
Locomotive::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
|
end
|
||||||
|
|
||||||
it 'has 3 items' do
|
it 'has 4 items now' do
|
||||||
menu.should have_selector('li.entry', :count => 3)
|
menu.should have_selector('li.entry', :count => 4)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has a new link' do
|
it 'has a new link' do
|
||||||
@ -46,13 +45,13 @@ describe Locomotive::MainMenuCell do
|
|||||||
|
|
||||||
describe 'remove a new menu item' do
|
describe 'remove a new menu item' do
|
||||||
|
|
||||||
before(:each) do
|
before(:all) do
|
||||||
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
|
reset_cell(:main => 'settings', :sub => 'site')
|
||||||
Locomotive::MainMenuCell.update_for(:testing_remove) { |m| m.remove(:settings) }
|
Locomotive::MainMenuCell.update_for(:testing_remove) { |m| m.remove(:settings) }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has only 1 item' do
|
it 'has only 2 items' do
|
||||||
menu.should have_selector('li.entry', :count => 1)
|
menu.should have_selector('li.entry', :count => 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not have the link to go to the settings' do
|
it 'does not have the link to go to the settings' do
|
||||||
@ -63,13 +62,13 @@ describe Locomotive::MainMenuCell do
|
|||||||
|
|
||||||
describe 'modify an existing menu item' do
|
describe 'modify an existing menu item' do
|
||||||
|
|
||||||
before(:each) do
|
before(:all) do
|
||||||
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
|
reset_cell(:main => 'settings', :sub => 'site')
|
||||||
Locomotive::MainMenuCell.update_for(:testing_update) { |m| m.modify(:settings, { :label => 'Modified !' }) }
|
Locomotive::MainMenuCell.update_for(:testing_update) { |m| m.modify(:settings, { :label => 'Modified !' }) }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'still has 2 items' do
|
it 'still has 3 items' do
|
||||||
menu.should have_selector('li.entry', :count => 2)
|
menu.should have_selector('li.entry', :count => 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has a modified menu item' do
|
it 'has a modified menu item' do
|
||||||
@ -80,7 +79,21 @@ describe Locomotive::MainMenuCell do
|
|||||||
end
|
end
|
||||||
|
|
||||||
after(:all) do
|
after(:all) do
|
||||||
CellsResetter.clean!
|
reset_cell
|
||||||
|
end
|
||||||
|
|
||||||
|
def reset_cell(attributes = {})
|
||||||
|
::Locomotive.send(:remove_const, 'MainMenuCell')
|
||||||
|
|
||||||
|
cell_path = File.join(File.dirname(__FILE__), '../../../app/cells/locomotive/main_menu_cell.rb')
|
||||||
|
load cell_path
|
||||||
|
|
||||||
|
cell_path = File.join(File.dirname(__FILE__), '../../dummy/app/cells/locomotive/main_menu_cell.rb')
|
||||||
|
load cell_path
|
||||||
|
|
||||||
|
unless attributes.empty?
|
||||||
|
Locomotive::MainMenuCell.any_instance.stubs(:sections).returns(attributes)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Locomotive::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
|
|
||||||
|
|
||||||
let(:menu) { render_cell('locomotive/settings_menu', :show) }
|
let(:menu) { render_cell('locomotive/settings_menu', :show) }
|
||||||
|
|
||||||
describe 'show menu' do
|
describe 'show menu' do
|
||||||
|
|
||||||
before(:each) do
|
before(:all) do
|
||||||
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
|
reset_cell(:main => 'settings', :sub => 'site')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has 3 items' do
|
it 'has 3 items' do
|
||||||
@ -33,8 +30,8 @@ describe Locomotive::SettingsMenuCell do
|
|||||||
|
|
||||||
describe 'add a new menu item' do
|
describe 'add a new menu item' do
|
||||||
|
|
||||||
before(:each) do
|
before(:all) do
|
||||||
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
|
reset_cell(:main => 'settings', :sub => 'site')
|
||||||
Locomotive::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
|
end
|
||||||
|
|
||||||
@ -50,8 +47,8 @@ describe Locomotive::SettingsMenuCell do
|
|||||||
|
|
||||||
describe 'remove a new menu item' do
|
describe 'remove a new menu item' do
|
||||||
|
|
||||||
before(:each) do
|
before(:all) do
|
||||||
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
|
reset_cell(:main => 'settings', :sub => 'site')
|
||||||
Locomotive::SettingsMenuCell.update_for(:testing_remove) { |m| m.remove(:theme_assets) }
|
Locomotive::SettingsMenuCell.update_for(:testing_remove) { |m| m.remove(:theme_assets) }
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -67,8 +64,8 @@ describe Locomotive::SettingsMenuCell do
|
|||||||
|
|
||||||
describe 'modify an existing menu item' do
|
describe 'modify an existing menu item' do
|
||||||
|
|
||||||
before(:each) do
|
before(:all) do
|
||||||
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
|
reset_cell(:main => 'settings', :sub => 'site')
|
||||||
Locomotive::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
|
end
|
||||||
|
|
||||||
@ -84,7 +81,23 @@ describe Locomotive::SettingsMenuCell do
|
|||||||
end
|
end
|
||||||
|
|
||||||
after(:all) do
|
after(:all) do
|
||||||
CellsResetter.clean!
|
reset_cell
|
||||||
|
end
|
||||||
|
|
||||||
|
def reset_cell(attributes = {})
|
||||||
|
::Locomotive.send(:remove_const, 'SettingsMenuCell')
|
||||||
|
|
||||||
|
cell_path = File.join(File.dirname(__FILE__), '../../../app/cells/locomotive/settings_menu_cell.rb')
|
||||||
|
load cell_path
|
||||||
|
|
||||||
|
unless attributes.empty?
|
||||||
|
# weird issue: Locomotive::GlobalActionsCell.any_instance does not work at all
|
||||||
|
Locomotive::SettingsMenuCell.class_eval <<-EOV
|
||||||
|
def sections(*args)
|
||||||
|
#{attributes.inspect}
|
||||||
|
end
|
||||||
|
EOV
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -2,26 +2,27 @@ require 'rspec-cells'
|
|||||||
require 'cell/test_case'
|
require 'cell/test_case'
|
||||||
require 'rspec/rails/example/cell_example_group'
|
require 'rspec/rails/example/cell_example_group'
|
||||||
|
|
||||||
module CellsResetter
|
#
|
||||||
|
# module CellsResetter
|
||||||
def self.method_missing(meth, *args)
|
#
|
||||||
if meth =~ /^new_(.*)_klass/
|
# def self.method_missing(meth, *args)
|
||||||
name = $1
|
# if meth =~ /^new_(.*)_klass/
|
||||||
|
# name = $1
|
||||||
klass_name = name.camelize
|
#
|
||||||
|
# klass_name = name.camelize
|
||||||
::Locomotive.send(:remove_const, klass_name)
|
#
|
||||||
load "locomotive/#{name}.rb"
|
# ::Locomotive.send(:remove_const, klass_name)
|
||||||
|
# load "locomotive/#{name}.rb"
|
||||||
"::Locomotive::#{klass_name}".constantize.any_instance.stubs(:sections).returns(args.first)
|
#
|
||||||
end
|
# "::Locomotive::#{klass_name}".constantize.any_instance.stubs(:sections).returns(args.first)
|
||||||
end
|
# end
|
||||||
|
# end
|
||||||
def self.clean!
|
#
|
||||||
[:menu_cell, :main_menu_cell, :global_actions_cell, :settings_menu_cell].each do |name|
|
# def self.clean!
|
||||||
::Locomotive.send(:remove_const, "#{name.to_s.camelize}")
|
# [:menu_cell, :main_menu_cell, :global_actions_cell, :settings_menu_cell].each do |name|
|
||||||
load "locomotive/#{name}.rb"
|
# ::Locomotive.send(:remove_const, "#{name.to_s.camelize}")
|
||||||
end
|
# load "locomotive/#{name}.rb"
|
||||||
end
|
# end
|
||||||
|
# end
|
||||||
end
|
#
|
||||||
|
# end
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
# tiny patch to add middlewares after the initialization
|
# tiny patch to add middlewares after the initialization
|
||||||
module Rails
|
# module Rails
|
||||||
class Application < Engine
|
# class Application < Engine
|
||||||
def app
|
# def app
|
||||||
@app ||= begin
|
# @app ||= begin
|
||||||
if config.middleware.respond_to?(:merge_into)
|
# if config.middleware.respond_to?(:merge_into)
|
||||||
config.middleware = config.middleware.merge_into(default_middleware_stack)
|
# config.middleware = config.middleware.merge_into(default_middleware_stack)
|
||||||
end
|
# end
|
||||||
config.middleware.build(routes)
|
# config.middleware.build(routes)
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
|
||||||
|
|
||||||
def Locomotive.configure_for_test(force = false)
|
def Locomotive.configure_for_test(force = false)
|
||||||
|
Loading…
Reference in New Issue
Block a user