Lots of spec fixes (mostly namespacing), down to 107 failing specs.

This commit is contained in:
Mario Visic 2011-11-26 17:24:34 +11:00
parent 9f1ce08136
commit ad6273e2fd
15 changed files with 55 additions and 55 deletions

View File

@ -7,7 +7,7 @@ module Locomotive
included do
referenced_in :content_type
referenced_in :content_type, :class_name => 'Locomotive::ContentType'
field :templatized, :type => Boolean, :default => false
@ -27,4 +27,4 @@ module Locomotive
end
end
end
end
end

View File

@ -29,7 +29,7 @@ module Locomotive
def email=(email)
@email = email
self.account = Account.where(:email => email).first
self.account = Locomotive::Account.where(:email => email).first
end
def process!
@ -72,4 +72,4 @@ module Locomotive
end
end
end
end

View File

@ -33,13 +33,13 @@ module Locomotive
def require_site
return true if current_site
redirect_to installation_url and return false if Account.count == 0 || Site.count == 0
redirect_to installation_url and return false if Locomotive::Account.count == 0 || Locomotive::Site.count == 0
render_no_site_error and return false
end
def render_no_site_error
render :template => '/admin/errors/no_site', :layout => false, :status => :not_found
render :template => '/Locomotive/errors/no_site', :layout => false, :status => :not_found
end
def validate_site_membership

View File

@ -5,7 +5,7 @@ describe Locomotive::GlobalActionsCell do
# as if it were a controller.
# render_views
let(:menu) { render_cell('admin/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
@ -18,7 +18,7 @@ describe Locomotive::GlobalActionsCell do
end
it 'has a link to edit my account' do
menu.should have_link('Admin')
menu.should have_link('Locomotive')
end
it 'has a link to see my website' do
@ -35,7 +35,7 @@ describe Locomotive::GlobalActionsCell do
before(:each) do
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::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
it 'has 4 items' do
@ -52,7 +52,7 @@ describe Locomotive::GlobalActionsCell do
before(:each) do
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::GlobalActionsCell.update_for(:testing_remove) { |m| m.remove(:see) }
Locomotive::GlobalActionsCell.update_for(:testing_remove) { |m| m.remove(:see) }
end
it 'has 2 items' do
@ -69,7 +69,7 @@ describe Locomotive::GlobalActionsCell do
before(:each) do
CellsResetter.new_global_actions_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::GlobalActionsCell.update_for(:testing_update) { |m| m.modify(:see, { :label => 'Modified !' }) }
Locomotive::GlobalActionsCell.update_for(:testing_update) { |m| m.modify(:see, { :label => 'Modified !' }) }
end
it 'still has 3 items' do

View File

@ -5,7 +5,7 @@ describe Locomotive::MainMenuCell do
# as if it were a controller.
# render_views
let(:menu) { render_cell('admin/main_menu', :show) }
let(:menu) { render_cell('locomotive/main_menu', :show) }
describe 'show menu' do
@ -31,7 +31,7 @@ describe Locomotive::MainMenuCell do
before(:each) do
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::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
it 'has 3 items' do
@ -48,7 +48,7 @@ describe Locomotive::MainMenuCell do
before(:each) do
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::MainMenuCell.update_for(:testing_remove) { |m| m.remove(:settings) }
Locomotive::MainMenuCell.update_for(:testing_remove) { |m| m.remove(:settings) }
end
it 'has only 1 item' do
@ -65,7 +65,7 @@ describe Locomotive::MainMenuCell do
before(:each) do
CellsResetter.new_main_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::MainMenuCell.update_for(:testing_update) { |m| m.modify(:settings, { :label => 'Modified !' }) }
Locomotive::MainMenuCell.update_for(:testing_update) { |m| m.modify(:settings, { :label => 'Modified !' }) }
end
it 'still has 2 items' do

View File

@ -5,7 +5,7 @@ describe Locomotive::SettingsMenuCell do
# as if it were a controller.
# render_views
let(:menu) { render_cell('admin/settings_menu', :show) }
let(:menu) { render_cell('locomotive/settings_menu', :show) }
describe 'show menu' do
@ -35,7 +35,7 @@ describe Locomotive::SettingsMenuCell do
before(:each) do
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::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
it 'has 4 items' do
@ -52,7 +52,7 @@ describe Locomotive::SettingsMenuCell do
before(:each) do
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::SettingsMenuCell.update_for(:testing_remove) { |m| m.remove(:theme_assets) }
Locomotive::SettingsMenuCell.update_for(:testing_remove) { |m| m.remove(:theme_assets) }
end
it 'has 2 items' do
@ -69,7 +69,7 @@ describe Locomotive::SettingsMenuCell do
before(:each) do
CellsResetter.new_settings_menu_cell_klass({ :main => 'settings', :sub => 'site' })
Admin::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
it 'still has 3 items' do

View File

@ -11,13 +11,13 @@ describe Locomotive::Liquid::Drops::Page do
before(:each) do
@home.stubs(:children).returns([
Page.new(:title => 'Child #1'),
Page.new(:title => 'Child #2'),
Page.new(:title => 'Child #3')
Locomotive::Page.new(:title => 'Child #1'),
Locomotive::Page.new(:title => 'Child #2'),
Locomotive::Page.new(:title => 'Child #3')
])
@home.children.last.stubs(:children).returns([
Page.new(:title => 'Child #3.1'),
Page.new(:title => 'Child #3.2')
Locomotive::Page.new(:title => 'Child #3.1'),
Locomotive::Page.new(:title => 'Child #3.2')
])
end

View File

@ -21,7 +21,7 @@ describe Locomotive::Liquid::Tags::Editable::Content do
context 'output' do
before :each do
EditableElement.any_instance.stubs(:content).returns("test string")
Locomotive::EditableElement.any_instance.stubs(:content).returns("test string")
end
context 'inheriting from a parent' do

View File

@ -5,18 +5,18 @@ describe Locomotive::Liquid::Tags::Nav do
before(:each) do
@home = FactoryGirl.build(:page)
home_children = [
Page.new(:title => 'Child #1', :fullpath => 'child_1', :slug => 'child_1', :published => true),
Page.new(:title => 'Child #2', :fullpath => 'child_2', :slug => 'child_2', :published => true)
Locomotive::Page.new(:title => 'Child #1', :fullpath => 'child_1', :slug => 'child_1', :published => true),
Locomotive::Page.new(:title => 'Child #2', :fullpath => 'child_2', :slug => 'child_2', :published => true)
]
@home.stubs(:children_with_minimal_attributes).returns(home_children)
@home.stubs(:children).returns(home_children)
other_children = [
Page.new(:title => 'Child #2.1', :fullpath => 'child_2/sub_child_1', :slug => 'sub_child_1', :published => true),
Page.new(:title => 'Child #2.2', :fullpath => 'child_2/sub_child_2', :slug => 'sub_child_2', :published => true),
Page.new(:title => 'Unpublished #2.2', :fullpath => 'child_2/sub_child_unpublishd_2', :slug => 'sub_child_unpublished_2', :published => false),
Page.new(:title => 'Templatized #2.3', :fullpath => 'child_2/sub_child_template_3', :slug => 'sub_child_template_3', :published => true, :templatized => true),
Page.new(:title => 'Unlisted #2.4', :fullpath => 'child_2/sub_child_unlisted_4', :slug => 'sub_child_unlisted_4', :published => true, :listed => false)
Locomotive::Page.new(:title => 'Child #2.1', :fullpath => 'child_2/sub_child_1', :slug => 'sub_child_1', :published => true),
Locomotive::Page.new(:title => 'Child #2.2', :fullpath => 'child_2/sub_child_2', :slug => 'sub_child_2', :published => true),
Locomotive::Page.new(:title => 'Unpublished #2.2', :fullpath => 'child_2/sub_child_unpublishd_2', :slug => 'sub_child_unpublished_2', :published => false),
Locomotive::Page.new(:title => 'Templatized #2.3', :fullpath => 'child_2/sub_child_template_3', :slug => 'sub_child_template_3', :published => true, :templatized => true),
Locomotive::Page.new(:title => 'Unlisted #2.4', :fullpath => 'child_2/sub_child_unlisted_4', :slug => 'sub_child_unlisted_4', :published => true, :listed => false)
]
@home.children.last.stubs(:children_with_minimal_attributes).returns(other_children)
@home.children.last.stubs(:children).returns(other_children)

View File

@ -5,9 +5,9 @@ describe 'Locomotive rendering system' do
before(:each) do
@controller = Locomotive::TestController.new
Site.any_instance.stubs(:create_default_pages!).returns(true)
Locomotive::Site.any_instance.stubs(:create_default_pages!).returns(true)
@site = FactoryGirl.build(:site)
Site.stubs(:find).returns(@site)
Locomotive::Site.stubs(:find).returns(@site)
@controller.current_site = @site
@page = FactoryGirl.build(:page, :site => nil, :published => true)
end
@ -101,7 +101,7 @@ describe 'Locomotive rendering system' do
it 'should return the 404 page if the page does not exist' do
@controller.request.fullpath = '/contact'
(klass = Page).expects(:published).returns([true])
(klass = Locomotive::Page).expects(:published).returns([true])
@controller.current_site.pages.expects(:not_found).returns(klass)
@controller.send(:locomotive_page).should be_true
end
@ -141,7 +141,7 @@ describe 'Locomotive rendering system' do
it 'returns the 404 page if the instance does not exist' do
@content_type.contents.stubs(:where).returns([])
(klass = Page).expects(:published).returns([true])
(klass = Locomotive::Page).expects(:published).returns([true])
@controller.current_site.pages.expects(:not_found).returns(klass)
@controller.send(:locomotive_page).should be_true
@controller.instance_variable_get(:@content_instance).should be_nil
@ -150,7 +150,7 @@ describe 'Locomotive rendering system' do
it 'returns the 404 page if the instance is not visible' do
@content._visible = false
@content_type.contents.stubs(:where).returns([@content])
(klass = Page).expects(:published).returns([true])
(klass = Locomotive::Page).expects(:published).returns([true])
@controller.current_site.pages.expects(:not_found).returns(klass)
@controller.send(:locomotive_page).should be_true
end
@ -167,7 +167,7 @@ describe 'Locomotive rendering system' do
it 'should return the 404 page if the page has not been published yet' do
@controller.request.fullpath = '/contact'
@controller.current_site.pages.expects(:any_in).with({ :fullpath => %w{contact content_type_template} }).returns([@page])
(klass = Page).expects(:published).returns([true])
(klass = Locomotive::Page).expects(:published).returns([true])
@controller.current_site.pages.expects(:not_found).returns(klass)
@controller.send(:locomotive_page).should be_true
end

View File

@ -39,7 +39,7 @@ describe Locomotive::Routing::SiteDispatcher do
end
it 'returns the site with matching domain if there is no current site instance' do
Site.expects(:match_domain).with('host').returns([@site])
Locomotive::Site.expects(:match_domain).with('host').returns([@site])
@controller.send(:fetch_site).should == @site
end
@ -80,7 +80,7 @@ describe Locomotive::Routing::SiteDispatcher do
context 'when there are no accounts' do
before :each do
Account.expects(:count).returns(0)
Locomotive::Account.expects(:count).returns(0)
@controller.instance_variable_set('@_response', ActionDispatch::Response.new)
@controller.expects(:current_site).returns(false)
@ -102,8 +102,8 @@ describe Locomotive::Routing::SiteDispatcher do
context 'when there are no sites' do
before :each do
Account.expects(:count).returns(1)
Site.expects(:count).returns(0)
Locomotive::Account.expects(:count).returns(1)
Locomotive::Site.expects(:count).returns(0)
@controller.instance_variable_set('@_response', ActionDispatch::Response.new)
@controller.expects(:current_site).returns(false)
@ -125,8 +125,8 @@ describe Locomotive::Routing::SiteDispatcher do
context 'when there is no current site' do
before :each do
Account.expects(:count).returns(1)
Site.expects(:count).returns(1)
Locomotive::Account.expects(:count).returns(1)
Locomotive::Site.expects(:count).returns(1)
@controller.instance_variable_set('@_response', ActionDispatch::Response.new)
@controller.expects(:current_site).returns(false)

View File

@ -31,7 +31,7 @@ describe Locomotive::Snippet do
it 'updates templates with the new snippet template' do
@snippet.update_attributes(:template => 'a new template')
Page.find(@page.id).render({}).should == 'a new template'
Locomotive::Page.find(@page.id).render({}).should == 'a new template'
end
end
@ -44,7 +44,7 @@ describe Locomotive::Snippet do
it 'updates templates with the new snippet template' do
@snippet.update_attributes(:template => 'a new template')
Page.find(@page.id).render({}).should == 'a new template'
Locomotive::Page.find(@page.id).render({}).should == 'a new template'
end
end

View File

@ -3,7 +3,7 @@ require 'spec_helper'
describe 'Locomotive::Middlewares::SeoTrailingSlash' do
before(:all) do
Locomotive::Application.instance.instance_variable_set(:@app, nil) # re-initialize the stack
Dummy::Application.instance.instance_variable_set(:@app, nil) # re-initialize the stack
end
it 'does not process the "/" url' do
@ -26,4 +26,4 @@ describe 'Locomotive::Middlewares::SeoTrailingSlash' do
response.status.should be(301)
end
end
end

View File

@ -10,18 +10,18 @@ module CellsResetter
klass_name = name.camelize
::Admin.send(:remove_const, klass_name)
load "#{name}.rb"
::Locomotive.send(:remove_const, klass_name)
load "locomotive/#{name}.rb"
"::Admin::#{klass_name}".constantize.any_instance.stubs(:sections).returns(args.first)
"::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|
::Admin.send(:remove_const, "#{name.to_s.camelize}")
load "#{name}.rb"
::Locomotive.send(:remove_const, "#{name.to_s.camelize}")
load "locomotive/#{name}.rb"
end
end
end
end

View File

@ -76,7 +76,7 @@ FactoryGirl.define do
## Memberships ##
factory :membership, :class => Locomotive::Membership do
role 'admin'
account { Account.where(:name => "Bart Simpson").first || Factory('admin user') }
account { Locomotive::Account.where(:name => "Bart Simpson").first || Factory('admin user') }
factory :admin do
role 'admin'