2011-07-26 00:00:35 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2011-11-26 05:33:57 +00:00
|
|
|
describe Locomotive::SettingsMenuCell do
|
2011-07-26 00:00:35 +00:00
|
|
|
|
2011-11-26 06:24:34 +00:00
|
|
|
let(:menu) { render_cell('locomotive/settings_menu', :show) }
|
2011-07-26 00:00:35 +00:00
|
|
|
|
|
|
|
describe 'show menu' do
|
|
|
|
|
2012-02-16 00:32:37 +00:00
|
|
|
before(:all) do
|
|
|
|
reset_cell(:main => 'settings', :sub => 'site')
|
2011-07-26 00:00:35 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has 3 items' do
|
|
|
|
menu.should have_selector('li', :count => 3)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a link to edit the current site' do
|
|
|
|
menu.should have_link('Site')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a link to edit the template files' do
|
|
|
|
menu.should have_link('Theme files')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a link to edit my account' do
|
|
|
|
menu.should have_link('My account')
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'add a new menu item' do
|
|
|
|
|
2012-02-16 00:32:37 +00:00
|
|
|
before(:all) do
|
|
|
|
reset_cell(:main => 'settings', :sub => 'site')
|
2011-11-26 06:24:34 +00:00
|
|
|
Locomotive::SettingsMenuCell.update_for(:testing_add) { |m| m.add(:my_link, :label => 'My link', :url => 'http://www.locomotivecms.com') }
|
2011-07-26 00:00:35 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has 4 items' do
|
|
|
|
menu.should have_selector('li', :count => 4)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a new link' do
|
|
|
|
menu.should have_link('My link')
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'remove a new menu item' do
|
|
|
|
|
2012-02-16 00:32:37 +00:00
|
|
|
before(:all) do
|
|
|
|
reset_cell(:main => 'settings', :sub => 'site')
|
2011-11-26 06:24:34 +00:00
|
|
|
Locomotive::SettingsMenuCell.update_for(:testing_remove) { |m| m.remove(:theme_assets) }
|
2011-07-26 00:00:35 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has 2 items' do
|
|
|
|
menu.should have_selector('li', :count => 2)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not have the link to edit the template files' do
|
|
|
|
menu.should_not have_link('Theme files')
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2011-07-26 01:02:13 +00:00
|
|
|
describe 'modify an existing menu item' do
|
|
|
|
|
2012-02-16 00:32:37 +00:00
|
|
|
before(:all) do
|
|
|
|
reset_cell(:main => 'settings', :sub => 'site')
|
2011-11-26 06:24:34 +00:00
|
|
|
Locomotive::SettingsMenuCell.update_for(:testing_update) { |m| m.modify(:theme_assets, { :label => 'Modified !' }) }
|
2011-07-26 01:02:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'still has 3 items' do
|
|
|
|
menu.should have_selector('li', :count => 3)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a modified menu item' do
|
|
|
|
menu.should_not have_link('Theme files')
|
|
|
|
menu.should have_link('Modified !')
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2011-07-26 00:00:35 +00:00
|
|
|
|
2011-08-13 23:24:02 +00:00
|
|
|
after(:all) do
|
2012-02-16 00:32:37 +00:00
|
|
|
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
|
2011-08-13 23:24:02 +00:00
|
|
|
end
|
|
|
|
|
2011-11-26 05:33:57 +00:00
|
|
|
end
|