add more tests for cells + disable the cas_create_user option for the bushi.do env

This commit is contained in:
did 2011-07-26 03:02:13 +02:00
parent 5ef92e6951
commit 7b8053241d
4 changed files with 225 additions and 72 deletions

View File

@ -72,8 +72,9 @@ module Locomotive
def setup_cas_client
::Devise.setup do |config|
config.cas_base_url = 'https://auth.bushi.do/cas'
config.cas_logout_url = 'https://auth.bushi.do/cas/logout'
config.cas_base_url = 'https://auth.bushi.do/cas'
config.cas_logout_url = 'https://auth.bushi.do/cas/logout'
config.cas_create_user = false
end
Admin::SessionsController.class_eval do

View File

@ -0,0 +1,101 @@
# require 'spec_helper'
#
# module Resetter
#
# @@original_global_actions_cell_klass = Admin::GlobalActionsCell
#
# def self.original_global_actions_cell_klass
# @@original_global_actions_cell_klass
# end
#
# def self.reset_global_actions_cell_klass
# ::Admin.send(:remove_const, 'GlobalActionsCell')
# ::Admin.const_set('GlobalActionsCell', self.original_global_actions_cell_klass.clone)
# ::Admin::GlobalActionsCell.any_instance.stubs(:sections).returns({ :main => 'settings', :sub => 'site' })
# end
#
# end
#
# describe Admin::GlobalActionsCell do
#
# render_views
#
# let(:menu) { render_cell('admin/global_actions', :show) }
#
# describe 'show menu' do
#
# before(:each) do
# Resetter.reset_global_actions_cell_klass
# end
#
# it 'has 3 links' do
# menu.should have_selector('li', :count => 3)
# end
#
# it 'has a link to edit my account' 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
#
# before(:each) do
# Resetter.reset_global_actions_cell_klass
# 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('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
#
# before(:each) do
# Resetter.reset_global_actions_cell_klass
# Admin::GlobalActionsCell.update_for(:testing_remove) { |m| m.remove(:theme_assets) }
# 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
#
# describe 'modify an existing menu item' do
#
# before(:each) do
# Resetter.reset_global_actions_cell_klass
# Admin::GlobalActionsCell.update_for(:testing_update) { |m| m.modify(:theme_assets, { :label => 'Modified !' }) }
# 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
#
# end

View File

@ -0,0 +1,97 @@
require 'spec_helper'
module Resetter
@@original_main_menu_cell_klass = Admin::MainMenuCell
def self.original_main_menu_cell_klass
@@original_main_menu_cell_klass
end
def self.reset_main_menu_cell_klass
::Admin.send(:remove_const, 'MainMenuCell')
::Admin.const_set('MainMenuCell', self.original_main_menu_cell_klass.clone)
::Admin::MainMenuCell.any_instance.stubs(:sections).returns({ :main => 'settings', :sub => 'site' })
end
end
describe Admin::MainMenuCell do
render_views
let(:menu) { render_cell('admin/main_menu', :show) }
describe 'show menu' do
before(:each) do
Resetter.reset_main_menu_cell_klass
end
it 'has 2 items' do
menu.should have_selector('li.item', :count => 2)
end
it 'has a link to go to the contents' do
menu.should have_link('Contents')
end
it 'has a link to go the settings' do
menu.should have_link('Settings')
end
end
describe 'add a new menu item' do
before(:each) do
Resetter.reset_main_menu_cell_klass
Admin::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.item', :count => 3)
end
it 'has a new link' do
menu.should have_link('Shop')
end
end
describe 'remove a new menu item' do
before(:each) do
Resetter.reset_main_menu_cell_klass
Admin::MainMenuCell.update_for(:testing_remove) { |m| m.remove(:settings) }
end
it 'has only 1 item' do
menu.should have_selector('li.item', :count => 1)
end
it 'does not have the link to go to the settings' do
menu.should_not have_link('Settings')
end
end
describe 'modify an existing menu item' do
before(:each) do
Resetter.reset_main_menu_cell_klass
Admin::MainMenuCell.update_for(:testing_update) { |m| m.modify(:settings, { :label => 'Modified !' }) }
end
it 'still has 2 items' do
menu.should have_selector('li.item', :count => 2)
end
it 'has a modified menu item' do
menu.should_not have_link('Settings')
menu.should have_link('Modified !')
end
end
end

View File

@ -8,74 +8,39 @@ module Resetter
@@original_settings_menu_cell_klass
end
def self.reset_settings_menu_cell_klass(stubs = false)
def self.reset_settings_menu_cell_klass
::Admin.send(:remove_const, 'SettingsMenuCell')
::Admin.const_set('SettingsMenuCell', self.original_settings_menu_cell_klass.clone)
if stubs
::Admin::SettingsMenuCell.any_instance.stubs(:sections).returns({ :main => 'settings', :sub => 'site' })
end
::Admin::SettingsMenuCell.any_instance.stubs(:sections).returns({ :main => 'settings', :sub => 'site' })
end
end
# puts "initial object_id = #{@original_settings_menu_cell_klass.object_id}"
# def reset_settings_menu_cell!
# ::Admin.send(:remove_const, 'SettingsMenuCell') rescue nil
# load 'admin/settings_menu_cell.rb'
# # ::Admin.const_set('SettingsMenuCell', @original_settings_menu_cell_klass)
# end
describe Admin::SettingsMenuCell, :type => :cells do
describe Admin::SettingsMenuCell do
render_views
# before(:each) do
# puts "1...#{Admin::SettingsMenuCell.object_id}"
# # @original_settings_menu_cell_klass = Admin::SettingsMenuCell.clone
# # ::Admin.send(:remove_const, 'SettingsMenuCell')
# # ::Admin.const_set('SettingsMenuCell', @original_settings_menu_cell_klass.clone)
# # @cell_klass = Class.new(Admin::SettingsMenuCell)
# # reset_settings_menu_cell!
#
# # Resetter.reset_settings_menu_cell_klass
#
# # Admin::SettingsMenuCell.any_instance.stubs(:sections).returns({ :main => 'settings', :sub => 'site' })
# end
#
# after(:each) do
# puts "2....#{Admin::SettingsMenuCell.object_id} (polluted) / clone: #{Resetter.original_settings_menu_cell_klass.object_id} (cleaned)"
# # ::Admin.send(:remove_const, 'SettingsMenuCell')
# # ::Admin.const_set('SettingsMenuCell', @original_settings_menu_cell_klass)
# end
let(:menu) { render_cell('admin/settings_menu', :show) }
describe 'show menu' do
before(:all) do
before(:each) do
Resetter.reset_settings_menu_cell_klass
::Admin::SettingsMenuCell.any_instance.stubs(:sections).returns({ :main => 'settings', :sub => 'site' })
end
it 'has 3 items' do
puts "1...#{Admin::SettingsMenuCell.object_id}"
menu.should have_selector('li', :count => 3)
end
it 'has a link to edit the current site' do
puts "2...#{Admin::SettingsMenuCell.object_id}"
menu.should have_link('Site')
end
it 'has a link to edit the template files' do
puts "3...#{Admin::SettingsMenuCell.object_id}"
menu.should have_link('Theme files')
end
it 'has a link to edit my account' do
puts "4...#{Admin::SettingsMenuCell.object_id}"
menu.should have_link('My account')
end
@ -84,8 +49,8 @@ describe Admin::SettingsMenuCell, :type => :cells do
describe 'add a new menu item' do
before(:each) do
Resetter.reset_settings_menu_cell_klass(true)
Admin::SettingsMenuCell.update_for(:add) { |m| m.add(:my_link, :label => 'My link', :url => 'http://www.locomotivecms.com') }
Resetter.reset_settings_menu_cell_klass
Admin::SettingsMenuCell.update_for(:testing_add) { |m| m.add(:my_link, :label => 'My link', :url => 'http://www.locomotivecms.com') }
end
it 'has 4 items' do
@ -101,8 +66,8 @@ describe Admin::SettingsMenuCell, :type => :cells do
describe 'remove a new menu item' do
before(:each) do
Resetter.reset_settings_menu_cell_klass(true)
Admin::SettingsMenuCell.update_for(:remove) { |m| m.remove(:theme_assets) }
Resetter.reset_settings_menu_cell_klass
Admin::SettingsMenuCell.update_for(:testing_remove) { |m| m.remove(:theme_assets) }
end
it 'has 2 items' do
@ -115,33 +80,22 @@ describe Admin::SettingsMenuCell, :type => :cells do
end
# describe 'add / remove / edit menu items' do
#
#
#
#
# end
describe 'modify an existing menu item' do
# describe "search posts" do
# let(:search) { render_cell(:posts, :search) }
#
# it "should have a search field" do
# search.should have_field("Search by Title")
# end
#
# it "should have a search button" do
# search.should have_button("Search")
# end
# end
#
# describe "latest posts" do
# subject { render_cell(:posts, :latest) }
#
# it { should have_css("h3.title", :text => "Latest Posts") }
# it { should have_table("latest_posts") }
# it { should have_link("View all Posts") }
# it { should_not have_button("Create Post") }
# it { should_not have_field("Search by Title") }
# end
before(:each) do
Resetter.reset_settings_menu_cell_klass
Admin::SettingsMenuCell.update_for(:testing_update) { |m| m.modify(:theme_assets, { :label => 'Modified !' }) }
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
end