2011-07-26 19:20:03 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Admin::GlobalActionsCell do
|
|
|
|
|
|
|
|
render_views
|
|
|
|
|
2011-08-25 21:28:56 +00:00
|
|
|
let(:menu) { render_cell('admin/global_actions', :show, :current_admin => FactoryGirl.build('admin user'), :current_site_url => 'http://www.yahoo.fr') }
|
2011-07-26 19:20:03 +00:00
|
|
|
|
|
|
|
describe 'show menu' do
|
|
|
|
|
|
|
|
before(:each) do
|
2011-08-13 23:24:02 +00:00
|
|
|
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
|
2011-07-26 19:20:03 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has 3 links' do
|
|
|
|
menu.should have_selector('a', :count => 4)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a link to edit my account' do
|
|
|
|
menu.should have_link('Admin')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a link to see my website' do
|
|
|
|
menu.should have_link('See website')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a link to log out' do
|
|
|
|
menu.should have_link('Log out')
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'add a new menu item' do
|
|
|
|
|
|
|
|
before(:each) do
|
2011-08-13 23:24:02 +00:00
|
|
|
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
|
2011-07-26 19:20:03 +00:00
|
|
|
Admin::GlobalActionsCell.update_for(:testing_add) { |m| m.add(:my_link, :label => 'My link', :url => 'http://www.locomotivecms.com') }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has 4 items' do
|
|
|
|
menu.should have_selector('a', :count => 5)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a new link' do
|
|
|
|
menu.should have_link('My link')
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'remove a new menu item' do
|
|
|
|
|
|
|
|
before(:each) do
|
2011-08-13 23:24:02 +00:00
|
|
|
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
|
2011-07-26 19:20:03 +00:00
|
|
|
Admin::GlobalActionsCell.update_for(:testing_remove) { |m| m.remove(:see) }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has 2 items' do
|
|
|
|
menu.should have_selector('a', :count => 3)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not have the link to see my website' do
|
|
|
|
menu.should_not have_link('See website')
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'modify an existing menu item' do
|
|
|
|
|
|
|
|
before(:each) do
|
2011-08-13 23:24:02 +00:00
|
|
|
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
|
2011-07-26 19:20:03 +00:00
|
|
|
Admin::GlobalActionsCell.update_for(:testing_update) { |m| m.modify(:see, { :label => 'Modified !' }) }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'still has 3 items' do
|
|
|
|
menu.should have_selector('a', :count => 4)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a modified menu item' do
|
|
|
|
menu.should_not have_link('See website')
|
|
|
|
menu.should have_link('Modified !')
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2011-08-13 23:24:02 +00:00
|
|
|
after(:all) do
|
|
|
|
CellsResetter.clean!
|
|
|
|
end
|
|
|
|
|
2011-07-26 19:20:03 +00:00
|
|
|
end
|