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', :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 'unicorn' # Using unicorn_rails instead of webrick (default server)
|
||||
@ -28,16 +28,16 @@ end
|
||||
group :test do
|
||||
gem 'launchy'
|
||||
|
||||
gem 'autotest', :platforms => :mri
|
||||
gem 'ZenTest', :platforms => :mri
|
||||
# gem 'autotest', :platforms => :mri
|
||||
# gem 'ZenTest', :platforms => :mri
|
||||
|
||||
gem 'growl-glue'
|
||||
# gem 'growl-glue'
|
||||
|
||||
gem 'cucumber-rails'
|
||||
gem 'rspec-rails', '2.6.1'
|
||||
# gem 'cucumber-rails'
|
||||
gem 'rspec-rails', '~> 2.8.0'
|
||||
gem 'shoulda-matchers'
|
||||
|
||||
gem 'factory_girl_rails', '~> 1.3.0'
|
||||
gem 'factory_girl_rails', '~> 1.6.0'
|
||||
gem 'pickle'
|
||||
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/
|
||||
specs:
|
||||
RedCloth (4.2.9)
|
||||
ZenTest (4.6.2)
|
||||
actionmailer (3.2.1)
|
||||
actionpack (= 3.2.1)
|
||||
mail (~> 2.4.0)
|
||||
@ -97,8 +96,6 @@ GEM
|
||||
multi_json (~> 1.0)
|
||||
addressable (2.2.6)
|
||||
arel (3.0.0)
|
||||
autotest (4.4.6)
|
||||
ZenTest (>= 4.4.1)
|
||||
bcrypt-ruby (3.0.1)
|
||||
bson (1.5.2)
|
||||
bson_ext (1.5.2)
|
||||
@ -138,10 +135,6 @@ GEM
|
||||
gherkin (~> 2.7.1)
|
||||
json (>= 1.4.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)
|
||||
devise (1.5.3)
|
||||
bcrypt-ruby (~> 3.0)
|
||||
@ -155,10 +148,10 @@ GEM
|
||||
excon (0.7.12)
|
||||
execjs (1.3.0)
|
||||
multi_json (~> 1.0)
|
||||
factory_girl (2.2.0)
|
||||
activesupport
|
||||
factory_girl_rails (1.3.0)
|
||||
factory_girl (~> 2.2.0)
|
||||
factory_girl (2.5.2)
|
||||
activesupport (>= 2.3.9)
|
||||
factory_girl_rails (1.6.0)
|
||||
factory_girl (~> 2.5.0)
|
||||
railties (>= 3.0.0)
|
||||
ffi (1.0.11)
|
||||
flash_cookie_session (1.1.1)
|
||||
@ -179,7 +172,6 @@ GEM
|
||||
fssm (0.2.8.1)
|
||||
gherkin (2.7.6)
|
||||
json (>= 1.4.6)
|
||||
growl-glue (1.0.7)
|
||||
haml (3.1.4)
|
||||
highline (1.6.11)
|
||||
hike (1.2.1)
|
||||
@ -262,23 +254,23 @@ GEM
|
||||
json (~> 1.4)
|
||||
responders (0.6.5)
|
||||
rmagick (2.12.2)
|
||||
rspec (2.6.0)
|
||||
rspec-core (~> 2.6.0)
|
||||
rspec-expectations (~> 2.6.0)
|
||||
rspec-mocks (~> 2.6.0)
|
||||
rspec (2.8.0)
|
||||
rspec-core (~> 2.8.0)
|
||||
rspec-expectations (~> 2.8.0)
|
||||
rspec-mocks (~> 2.8.0)
|
||||
rspec-cells (0.1.2)
|
||||
cells (~> 3.4)
|
||||
rails (~> 3.0)
|
||||
rspec-rails (~> 2.2)
|
||||
rspec-core (2.6.4)
|
||||
rspec-expectations (2.6.0)
|
||||
rspec-core (2.8.0)
|
||||
rspec-expectations (2.8.0)
|
||||
diff-lcs (~> 1.1.2)
|
||||
rspec-mocks (2.6.0)
|
||||
rspec-rails (2.6.1)
|
||||
actionpack (~> 3.0)
|
||||
activesupport (~> 3.0)
|
||||
railties (~> 3.0)
|
||||
rspec (~> 2.6.0)
|
||||
rspec-mocks (2.8.0)
|
||||
rspec-rails (2.8.1)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec (~> 2.8.0)
|
||||
ruby-hmac (0.4.0)
|
||||
rubyzip (0.9.5)
|
||||
sanitize (2.0.3)
|
||||
@ -321,23 +313,19 @@ PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
ZenTest
|
||||
autotest
|
||||
capybara
|
||||
coffee-rails (~> 3.2.2)
|
||||
compass!
|
||||
compass-rails!
|
||||
cucumber-rails
|
||||
custom_fields!
|
||||
database_cleaner
|
||||
factory_girl_rails (~> 1.3.0)
|
||||
growl-glue
|
||||
factory_girl_rails (~> 1.6.0)
|
||||
launchy
|
||||
locomotive_cms!
|
||||
mocha (= 0.9.12)
|
||||
pickle
|
||||
rspec-cells
|
||||
rspec-rails (= 2.6.1)
|
||||
rspec-rails (~> 2.8.0)
|
||||
sass-rails (~> 3.2.4)
|
||||
shoulda-matchers
|
||||
uglifier (~> 1.2.3)
|
||||
|
172
Rakefile
172
Rakefile
@ -1,77 +1,107 @@
|
||||
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
|
||||
#!/usr/bin/env rake
|
||||
begin
|
||||
require 'bundler/setup'
|
||||
rescue LoadError
|
||||
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
||||
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
|
||||
# begin
|
||||
# require 'rdoc/task'
|
||||
# rescue LoadError
|
||||
# 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
|
||||
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(' ')
|
||||
load 'lib/tasks/locomotive.rake'
|
||||
|
||||
sh "bundle exec rspec #{files}"
|
||||
end
|
||||
# FIXME: it is disabled because it loaded twice the Locomotive engine
|
||||
# load 'rails/tasks/engine.rake'
|
||||
|
||||
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
|
||||
require 'rspec/core/rake_task'
|
||||
RSpec::Core::RakeTask.new(:spec)
|
||||
|
||||
task :default => :spec
|
||||
|
||||
Bundler::GemHelper.install_tasks
|
||||
|
||||
|
||||
# # 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
|
||||
|
||||
require 'locomotive'
|
||||
require 'highline/import'
|
||||
# require 'locomotive'
|
||||
# require 'highline/import'
|
||||
|
||||
namespace :locomotive do
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
require 'spec_helper'
|
||||
|
||||
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') }
|
||||
|
||||
describe 'show menu' do
|
||||
|
||||
before(:each) do
|
||||
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
|
||||
before(:all) do
|
||||
reset_cell(:main => 'settings', :sub => 'site')
|
||||
end
|
||||
|
||||
it 'has 3 links' do
|
||||
@ -14,6 +15,7 @@ describe Locomotive::GlobalActionsCell do
|
||||
end
|
||||
|
||||
it 'has a link to edit my account' do
|
||||
puts "last test"
|
||||
menu.should have_link('Admin')
|
||||
end
|
||||
|
||||
@ -29,8 +31,8 @@ describe Locomotive::GlobalActionsCell do
|
||||
|
||||
describe 'add a new menu item' do
|
||||
|
||||
before(:each) do
|
||||
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
|
||||
before(:all) do
|
||||
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') }
|
||||
end
|
||||
|
||||
@ -46,8 +48,8 @@ describe Locomotive::GlobalActionsCell do
|
||||
|
||||
describe 'remove a new menu item' do
|
||||
|
||||
before(:each) do
|
||||
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
|
||||
before(:all) do
|
||||
reset_cell(:main => 'settings', :sub => 'site')
|
||||
Locomotive::GlobalActionsCell.update_for(:testing_remove) { |m| m.remove(:see) }
|
||||
end
|
||||
|
||||
@ -63,8 +65,8 @@ describe Locomotive::GlobalActionsCell do
|
||||
|
||||
describe 'modify an existing menu item' do
|
||||
|
||||
before(:each) do
|
||||
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
|
||||
before(:all) do
|
||||
reset_cell(:main => 'settings', :sub => 'site')
|
||||
Locomotive::GlobalActionsCell.update_for(:testing_update) { |m| m.modify(:see, { :label => 'Modified !' }) }
|
||||
end
|
||||
|
||||
@ -80,7 +82,18 @@ describe Locomotive::GlobalActionsCell do
|
||||
end
|
||||
|
||||
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
|
||||
|
@ -1,20 +1,15 @@
|
||||
require 'spec_helper'
|
||||
|
||||
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) }
|
||||
|
||||
describe 'show menu' do
|
||||
|
||||
before(:each) do
|
||||
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
|
||||
end
|
||||
before(:all) { reset_cell }
|
||||
|
||||
it 'has 2 items' do
|
||||
menu.should have_selector('li.entry', :count => 2)
|
||||
it 'has 3 items' do
|
||||
menu.should have_selector('li.entry', :count => 3)
|
||||
end
|
||||
|
||||
it 'has a link to go to the contents' do
|
||||
@ -25,17 +20,21 @@ describe Locomotive::MainMenuCell do
|
||||
menu.should have_link('Settings')
|
||||
end
|
||||
|
||||
it 'has a link to go the foo tab' do
|
||||
menu.should have_link('My FOO menu')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'add a new menu item' do
|
||||
|
||||
before(:each) do
|
||||
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
|
||||
before(:all) do
|
||||
reset_cell(:main => 'settings', :sub => 'site')
|
||||
Locomotive::MainMenuCell.update_for(:testing_add) { |m| m.add(:my_link, :label => 'Shop', :url => 'http://www.locomotivecms.com') }
|
||||
end
|
||||
|
||||
it 'has 3 items' do
|
||||
menu.should have_selector('li.entry', :count => 3)
|
||||
it 'has 4 items now' do
|
||||
menu.should have_selector('li.entry', :count => 4)
|
||||
end
|
||||
|
||||
it 'has a new link' do
|
||||
@ -46,13 +45,13 @@ describe Locomotive::MainMenuCell do
|
||||
|
||||
describe 'remove a new menu item' do
|
||||
|
||||
before(:each) do
|
||||
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
|
||||
before(:all) do
|
||||
reset_cell(:main => 'settings', :sub => 'site')
|
||||
Locomotive::MainMenuCell.update_for(:testing_remove) { |m| m.remove(:settings) }
|
||||
end
|
||||
|
||||
it 'has only 1 item' do
|
||||
menu.should have_selector('li.entry', :count => 1)
|
||||
it 'has only 2 items' do
|
||||
menu.should have_selector('li.entry', :count => 2)
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
before(:each) do
|
||||
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
|
||||
before(:all) do
|
||||
reset_cell(:main => 'settings', :sub => 'site')
|
||||
Locomotive::MainMenuCell.update_for(:testing_update) { |m| m.modify(:settings, { :label => 'Modified !' }) }
|
||||
end
|
||||
|
||||
it 'still has 2 items' do
|
||||
menu.should have_selector('li.entry', :count => 2)
|
||||
it 'still has 3 items' do
|
||||
menu.should have_selector('li.entry', :count => 3)
|
||||
end
|
||||
|
||||
it 'has a modified menu item' do
|
||||
@ -80,7 +79,21 @@ describe Locomotive::MainMenuCell do
|
||||
end
|
||||
|
||||
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
|
||||
|
@ -1,16 +1,13 @@
|
||||
require 'spec_helper'
|
||||
|
||||
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) }
|
||||
|
||||
describe 'show menu' do
|
||||
|
||||
before(:each) do
|
||||
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
|
||||
before(:all) do
|
||||
reset_cell(:main => 'settings', :sub => 'site')
|
||||
end
|
||||
|
||||
it 'has 3 items' do
|
||||
@ -33,8 +30,8 @@ describe Locomotive::SettingsMenuCell do
|
||||
|
||||
describe 'add a new menu item' do
|
||||
|
||||
before(:each) do
|
||||
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
|
||||
before(:all) do
|
||||
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') }
|
||||
end
|
||||
|
||||
@ -50,8 +47,8 @@ describe Locomotive::SettingsMenuCell do
|
||||
|
||||
describe 'remove a new menu item' do
|
||||
|
||||
before(:each) do
|
||||
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
|
||||
before(:all) do
|
||||
reset_cell(:main => 'settings', :sub => 'site')
|
||||
Locomotive::SettingsMenuCell.update_for(:testing_remove) { |m| m.remove(:theme_assets) }
|
||||
end
|
||||
|
||||
@ -67,8 +64,8 @@ describe Locomotive::SettingsMenuCell do
|
||||
|
||||
describe 'modify an existing menu item' do
|
||||
|
||||
before(:each) do
|
||||
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
|
||||
before(:all) do
|
||||
reset_cell(:main => 'settings', :sub => 'site')
|
||||
Locomotive::SettingsMenuCell.update_for(:testing_update) { |m| m.modify(:theme_assets, { :label => 'Modified !' }) }
|
||||
end
|
||||
|
||||
@ -84,7 +81,23 @@ describe Locomotive::SettingsMenuCell do
|
||||
end
|
||||
|
||||
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
|
||||
|
@ -2,26 +2,27 @@ require 'rspec-cells'
|
||||
require 'cell/test_case'
|
||||
require 'rspec/rails/example/cell_example_group'
|
||||
|
||||
module CellsResetter
|
||||
|
||||
def self.method_missing(meth, *args)
|
||||
if meth =~ /^new_(.*)_klass/
|
||||
name = $1
|
||||
|
||||
klass_name = name.camelize
|
||||
|
||||
::Locomotive.send(:remove_const, klass_name)
|
||||
load "locomotive/#{name}.rb"
|
||||
|
||||
"::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|
|
||||
::Locomotive.send(:remove_const, "#{name.to_s.camelize}")
|
||||
load "locomotive/#{name}.rb"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
#
|
||||
# module CellsResetter
|
||||
#
|
||||
# def self.method_missing(meth, *args)
|
||||
# if meth =~ /^new_(.*)_klass/
|
||||
# name = $1
|
||||
#
|
||||
# klass_name = name.camelize
|
||||
#
|
||||
# ::Locomotive.send(:remove_const, klass_name)
|
||||
# load "locomotive/#{name}.rb"
|
||||
#
|
||||
# "::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|
|
||||
# ::Locomotive.send(:remove_const, "#{name.to_s.camelize}")
|
||||
# load "locomotive/#{name}.rb"
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# end
|
||||
|
@ -1,16 +1,16 @@
|
||||
# tiny patch to add middlewares after the initialization
|
||||
module Rails
|
||||
class Application < Engine
|
||||
def app
|
||||
@app ||= begin
|
||||
if config.middleware.respond_to?(:merge_into)
|
||||
config.middleware = config.middleware.merge_into(default_middleware_stack)
|
||||
end
|
||||
config.middleware.build(routes)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# module Rails
|
||||
# class Application < Engine
|
||||
# def app
|
||||
# @app ||= begin
|
||||
# if config.middleware.respond_to?(:merge_into)
|
||||
# config.middleware = config.middleware.merge_into(default_middleware_stack)
|
||||
# end
|
||||
# config.middleware.build(routes)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
|
||||
def Locomotive.configure_for_test(force = false)
|
||||
|
Loading…
Reference in New Issue
Block a user