Fixed a bunch of model tests.
This commit is contained in:
parent
a50df5ad8e
commit
06f4fc98e3
@ -3,7 +3,7 @@ require 'spec_helper'
|
||||
describe Locomotive::ContentType do
|
||||
|
||||
before(:each) do
|
||||
Site.any_instance.stubs(:create_default_pages!).returns(true)
|
||||
Locomotive::Site.any_instance.stubs(:create_default_pages!).returns(true)
|
||||
end
|
||||
|
||||
context 'when validating' do
|
||||
@ -96,12 +96,12 @@ describe Locomotive::ContentType do
|
||||
|
||||
before(:each) do
|
||||
site = FactoryGirl.build(:site)
|
||||
Site.stubs(:find).returns(site)
|
||||
Locomotive::Site.stubs(:find).returns(site)
|
||||
@content_type = FactoryGirl.build(:content_type, :site => site, :highlighted_field_name => 'custom_field_1')
|
||||
@content_type.content_custom_fields.build :label => 'My Description', :_alias => 'description', :kind => 'text'
|
||||
@content_type.content_custom_fields.build :label => 'Active', :kind => 'boolean'
|
||||
# ContentType.logger = Logger.new($stdout)
|
||||
# ContentType.db.connection.instance_variable_set(:@logger, Logger.new($stdout))
|
||||
# Locomotive::ContentType.logger = Logger.new($stdout)
|
||||
# Locomotive::ContentType.db.connection.instance_variable_set(:@logger, Logger.new($stdout))
|
||||
end
|
||||
|
||||
context 'unit' do
|
||||
@ -187,7 +187,7 @@ describe Locomotive::ContentType do
|
||||
it 'should not modify contents from another collection' do
|
||||
asset = build_content(@content_type)
|
||||
asset.save and @content_type.reload
|
||||
new_collection = ContentType.new
|
||||
new_collection = Locomotive::ContentType.new
|
||||
lambda { new_collection.contents.build.description }.should raise_error
|
||||
end
|
||||
|
||||
@ -244,14 +244,14 @@ describe Locomotive::ContentType do
|
||||
|
||||
it 'updates/removes fields' do
|
||||
field = @content_type.content_custom_fields.build :label => 'Title', :kind => 'String'
|
||||
@content_type.save; @content_type = ContentType.find(@content_type.id)
|
||||
@content_type.save; @content_type = Locomotive::ContentType.find(@content_type.id)
|
||||
@content_type.update_attributes(:content_custom_fields_attributes => {
|
||||
'0' => { 'id' => lookup_field_id(0), 'label' => 'My Description', 'kind' => 'Text', '_destroy' => '1' },
|
||||
'1' => { 'id' => lookup_field_id(1), 'label' => 'Active', 'kind' => 'Boolean', '_destroy' => '1' },
|
||||
'2' => { 'id' => lookup_field_id(2), 'label' => 'My Title !', 'kind' => 'String' },
|
||||
'new_record' => { 'label' => 'Published at', 'kind' => 'String' }
|
||||
})
|
||||
@content_type = ContentType.find(@content_type.id)
|
||||
@content_type = Locomotive::ContentType.find(@content_type.id)
|
||||
@content_type.content_custom_fields.size.should == 2
|
||||
@content_type.content_custom_fields.first.label.should == 'My Title !'
|
||||
end
|
||||
|
@ -13,8 +13,8 @@ describe Locomotive::Membership do
|
||||
end
|
||||
|
||||
it 'should assign account from email' do
|
||||
Account.stubs(:where).returns([FactoryGirl.build(:account)])
|
||||
Account.stubs(:find).returns(FactoryGirl.build(:account))
|
||||
Locomotive::Account.stubs(:where).returns([FactoryGirl.build(:account)])
|
||||
Locomotive::Account.stubs(:find).returns(FactoryGirl.build(:account))
|
||||
membership = FactoryGirl.build(:membership, :account => nil)
|
||||
membership.email = 'bart@simpson.net'
|
||||
membership.account.should_not be_nil
|
||||
@ -27,8 +27,8 @@ describe Locomotive::Membership do
|
||||
@membership = FactoryGirl.build(:membership, :site => FactoryGirl.build(:site))
|
||||
@account = FactoryGirl.build(:account)
|
||||
@account.stubs(:save).returns(true)
|
||||
Account.stubs(:where).returns([@account])
|
||||
Account.stubs(:find).returns(@account)
|
||||
Locomotive::Account.stubs(:where).returns([@account])
|
||||
Locomotive::Account.stubs(:find).returns(@account)
|
||||
end
|
||||
|
||||
it 'should tell error' do
|
||||
@ -36,7 +36,7 @@ describe Locomotive::Membership do
|
||||
end
|
||||
|
||||
it 'should tell we need to create a new account' do
|
||||
Account.stubs(:where).returns([])
|
||||
Locomotive::Account.stubs(:where).returns([])
|
||||
@membership.email = 'homer@simpson'
|
||||
@membership.process!.should == :create_account
|
||||
end
|
||||
|
@ -5,8 +5,8 @@ require 'spec_helper'
|
||||
describe Locomotive::Page do
|
||||
|
||||
before(:each) do
|
||||
Site.any_instance.stubs(:create_default_pages!).returns(true)
|
||||
Page.any_instance.stubs(:set_default_raw_template).returns(true)
|
||||
Locomotive::Site.any_instance.stubs(:create_default_pages!).returns(true)
|
||||
Locomotive::Page.any_instance.stubs(:set_default_raw_template).returns(true)
|
||||
end
|
||||
|
||||
it 'should have a valid factory' do
|
||||
@ -95,7 +95,7 @@ describe Locomotive::Page do
|
||||
lambda {
|
||||
@page.destroy.should be_false
|
||||
@page.errors.first == 'You can not remove index or 404 pages'
|
||||
}.should_not change(Page, :count)
|
||||
}.should_not change(Locomotive::Page, :count)
|
||||
end
|
||||
|
||||
it 'does not delete the 404 page' do
|
||||
@ -103,7 +103,7 @@ describe Locomotive::Page do
|
||||
lambda {
|
||||
@page.destroy.should be_false
|
||||
@page.errors.first == 'You can not remove index or 404 pages'
|
||||
}.should_not change(Page, :count)
|
||||
}.should_not change(Locomotive::Page, :count)
|
||||
end
|
||||
|
||||
end
|
||||
@ -117,13 +117,13 @@ describe Locomotive::Page do
|
||||
|
||||
it 'should add root elements' do
|
||||
page_404 = FactoryGirl.create(:page, :title => 'Page not found', :slug => '404', :site => @home.site)
|
||||
Page.roots.count.should == 2
|
||||
Page.roots.should == [@home, page_404]
|
||||
Locomotive::Page.roots.count.should == 2
|
||||
Locomotive::Page.roots.should == [@home, page_404]
|
||||
end
|
||||
|
||||
it 'should add sub pages' do
|
||||
child_2 = FactoryGirl.create(:page, :title => 'Subpage 2', :slug => 'bar', :parent => @home, :site => @home.site)
|
||||
@home = Page.find(@home.id)
|
||||
@home = Locomotive::Page.find(@home.id)
|
||||
@home.children.count.should == 2
|
||||
@home.children.should == [@child_1, child_2]
|
||||
end
|
||||
@ -148,7 +148,7 @@ describe Locomotive::Page do
|
||||
it 'should destroy descendants as well' do
|
||||
FactoryGirl.create(:page, :title => 'Sub Subpage 1', :slug => 'bar', :parent_id => @child_1._id, :site => @home.site)
|
||||
@child_1.destroy
|
||||
Page.where(:slug => 'bar').first.should be_nil
|
||||
Locomotive::Page.where(:slug => 'bar').first.should be_nil
|
||||
end
|
||||
|
||||
end
|
||||
@ -177,7 +177,7 @@ describe Locomotive::Page do
|
||||
|
||||
before(:each) do
|
||||
@page = FactoryGirl.build(:page, :site => nil, :templatized => true, :content_type_id => 42)
|
||||
ContentType.stubs(:find).returns(FactoryGirl.build(:content_type, :site => nil))
|
||||
Locomotive::ContentType.stubs(:find).returns(FactoryGirl.build(:content_type, :site => nil))
|
||||
end
|
||||
|
||||
it 'is considered as a templatized page' do
|
||||
|
@ -68,19 +68,19 @@ describe Locomotive::Site do
|
||||
site_1 = FactoryGirl.create(:site, :domains => %w{www.acme.net})
|
||||
site_2 = FactoryGirl.create(:site, :subdomain => 'test', :domains => %w{www.example.com})
|
||||
|
||||
sites = Site.match_domain('www.acme.net')
|
||||
sites = Locomotive::Site.match_domain('www.acme.net')
|
||||
sites.size.should == 1
|
||||
sites.first.should == site_1
|
||||
|
||||
sites = Site.match_domain('www.example.com')
|
||||
sites = Locomotive::Site.match_domain('www.example.com')
|
||||
sites.size.should == 1
|
||||
sites.first.should == site_2
|
||||
|
||||
sites = Site.match_domain('test.example.com')
|
||||
sites = Locomotive::Site.match_domain('test.example.com')
|
||||
sites.size.should == 1
|
||||
sites.first.should == site_2
|
||||
|
||||
sites = Site.match_domain('www.unknown.com')
|
||||
sites = Locomotive::Site.match_domain('www.unknown.com')
|
||||
sites.should be_empty
|
||||
end
|
||||
|
||||
@ -125,7 +125,7 @@ describe Locomotive::Site do
|
||||
it 'should also destroy pages' do
|
||||
lambda {
|
||||
@site.destroy
|
||||
}.should change(Page, :count).by(-2)
|
||||
}.should change(Locomotive::Page, :count).by(-2)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ describe Locomotive::ThemeAsset do
|
||||
describe 'attaching a file' do
|
||||
|
||||
before(:each) do
|
||||
ThemeAsset.any_instance.stubs(:site_id).returns('test')
|
||||
Locomotive::ThemeAsset.any_instance.stubs(:site_id).returns('test')
|
||||
@asset = FactoryGirl.build(:theme_asset)
|
||||
end
|
||||
|
||||
@ -93,7 +93,7 @@ describe Locomotive::ThemeAsset do
|
||||
describe 'creating from plain text' do
|
||||
|
||||
before(:each) do
|
||||
ThemeAsset.any_instance.stubs(:site_id).returns('test')
|
||||
Locomotive::ThemeAsset.any_instance.stubs(:site_id).returns('test')
|
||||
@asset = FactoryGirl.build(:theme_asset, {
|
||||
:site => FactoryGirl.build(:site),
|
||||
:plain_text_name => 'test',
|
||||
|
Loading…
Reference in New Issue
Block a user