2010-10-28 23:36:45 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Locomotive::Import::Job do
|
|
|
|
|
|
|
|
context 'when successful' do
|
|
|
|
|
|
|
|
before(:all) do
|
2011-08-25 21:28:56 +00:00
|
|
|
@site = FactoryGirl.create(:site)
|
2010-10-28 23:36:45 +00:00
|
|
|
|
|
|
|
job = Locomotive::Import::Job.new(FixturedTheme.duplicate_and_open('default.zip'), @site, { :samples => true, :reset => true })
|
|
|
|
job.perform
|
|
|
|
|
|
|
|
job.success nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates the site information' do
|
|
|
|
@site.name.should_not == "HTML5 portfolio"
|
|
|
|
@site.meta_keywords.should == "html5 portfolio theme locomotive cms"
|
|
|
|
@site.meta_description.should == "portfolio powered by html5"
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'adds content types' do
|
2011-06-17 21:32:54 +00:00
|
|
|
@site.content_types.count.should == 4
|
2010-10-28 23:36:45 +00:00
|
|
|
content_type = @site.content_types.where(:slug => 'projects').first
|
2011-06-17 21:32:54 +00:00
|
|
|
content_type.content_custom_fields.size.should == 9
|
2010-10-28 23:36:45 +00:00
|
|
|
end
|
2011-08-13 23:24:02 +00:00
|
|
|
|
2011-08-15 21:39:53 +00:00
|
|
|
it 'replaces the target and the reverse_lookup values by the correct ones in a has_many relationship' do
|
|
|
|
content_type = @site.content_types.where(:slug => 'clients').first
|
|
|
|
field = content_type.content_custom_fields.last
|
|
|
|
field.target.should match /^ContentContentType/
|
|
|
|
field.reverse_lookup.should == 'custom_field_8'
|
|
|
|
end
|
|
|
|
|
2011-07-28 04:22:44 +00:00
|
|
|
it 'correctly imports content type names' do
|
|
|
|
content_type = @site.content_types.where(:slug => 'projects').first
|
|
|
|
content_type.name.should == 'My projects'
|
|
|
|
end
|
2010-10-28 23:36:45 +00:00
|
|
|
|
|
|
|
it 'converts correctly the order_by option for content types' do
|
|
|
|
content_type = @site.content_types.where(:slug => 'messages').first
|
2010-10-30 22:30:30 +00:00
|
|
|
content_type.order_by.should == 'created_at'
|
2010-10-28 23:36:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'adds samples coming with content types' do
|
|
|
|
content_type = @site.content_types.where(:slug => 'projects').first
|
|
|
|
content_type.contents.size.should == 5
|
|
|
|
|
|
|
|
content = content_type.contents.first
|
2011-07-28 09:53:36 +00:00
|
|
|
content._permalink.should == 'locomotivecms'
|
|
|
|
content.seo_title.should == 'My open source CMS'
|
|
|
|
content.meta_description.should == 'bla bla bla'
|
|
|
|
content.meta_keywords.should == 'cms ruby engine mongodb'
|
2010-10-28 23:36:45 +00:00
|
|
|
content.name.should == 'Locomotive App'
|
|
|
|
content.thumbnail.url.should_not be_nil
|
|
|
|
content.featured.should == true
|
2011-06-17 21:32:54 +00:00
|
|
|
content.client.name.should == 'My client #1'
|
|
|
|
content.team.first.name.should == 'Michael Scott'
|
2010-10-28 23:36:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'inserts theme assets' do
|
|
|
|
@site.theme_assets.count.should == 10
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'inserts all the pages' do
|
2011-03-02 23:50:22 +00:00
|
|
|
@site.pages.count.should == 11
|
2010-10-28 23:36:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'inserts the index and 404 pages' do
|
2011-01-27 09:49:42 +00:00
|
|
|
@site.pages.root.first.should_not be_nil
|
2010-10-28 23:36:45 +00:00
|
|
|
@site.pages.not_found.first.should_not be_nil
|
|
|
|
end
|
|
|
|
|
2011-07-27 22:39:59 +00:00
|
|
|
it 'sets the editable text for a page from the site config file' do
|
|
|
|
page = @site.pages.where(:title => 'Contact').first
|
|
|
|
page.find_editable_element('content', 'address').content.should == '<p>Our office address: 215 Vine Street, Scranton, PA 18503</p>'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sets the editable file for a page from the site config file' do
|
|
|
|
page = @site.pages.where(:title => 'Contact').first
|
|
|
|
page.find_editable_element('content', 'office').source_filename.should == 'office.jpg'
|
|
|
|
end
|
2011-08-13 23:24:02 +00:00
|
|
|
|
2011-08-03 06:58:47 +00:00
|
|
|
it 'sets the empty editable file for a page from the site config file' do
|
|
|
|
page = @site.pages.where(:title => 'Contact').first
|
|
|
|
page.find_editable_element('content', 'office2').source_filename.should be_nil
|
|
|
|
end
|
2011-07-28 09:53:36 +00:00
|
|
|
|
2010-10-28 23:36:45 +00:00
|
|
|
it 'inserts templatized page' do
|
|
|
|
page = @site.pages.where(:templatized => true).first
|
|
|
|
page.should_not be_nil
|
|
|
|
page.fullpath.should == 'portfolio/content_type_template'
|
|
|
|
end
|
2011-07-28 09:53:36 +00:00
|
|
|
|
2011-01-10 13:57:44 +00:00
|
|
|
it 'inserts redirection page' do
|
|
|
|
page = @site.pages.where(:redirect => true).first
|
|
|
|
page.should_not be_nil
|
|
|
|
page.redirect_url.should == 'http://blog.locomotivecms.com'
|
|
|
|
end
|
2011-07-28 09:53:36 +00:00
|
|
|
|
2011-07-07 14:59:50 +00:00
|
|
|
it 'inserts snippets' do
|
|
|
|
@site.snippets.count.should == 1
|
|
|
|
end
|
|
|
|
|
2010-10-28 23:36:45 +00:00
|
|
|
after(:all) do
|
|
|
|
Site.destroy_all
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2011-08-13 23:24:02 +00:00
|
|
|
|
2011-07-28 04:22:44 +00:00
|
|
|
context 'with an existing site' do
|
|
|
|
before(:all) do
|
2011-08-25 21:28:56 +00:00
|
|
|
@site = FactoryGirl.create('existing site')
|
2011-07-28 04:22:44 +00:00
|
|
|
|
2011-07-28 05:08:52 +00:00
|
|
|
job = Locomotive::Import::Job.new(FixturedTheme.duplicate_and_open('default.zip'), @site, { :samples => true, :reset => false })
|
2011-07-28 04:22:44 +00:00
|
|
|
job.perform
|
|
|
|
|
|
|
|
job.success nil
|
|
|
|
end
|
2011-08-13 23:24:02 +00:00
|
|
|
|
2011-07-28 04:22:44 +00:00
|
|
|
context 'updates to content_type attributes' do
|
|
|
|
before(:all) do
|
|
|
|
@projects = content_type = @site.content_types.where(:slug => 'projects').first
|
|
|
|
end
|
2011-08-13 23:24:02 +00:00
|
|
|
|
2011-07-28 04:22:44 +00:00
|
|
|
it 'includes new name' do
|
|
|
|
@projects.name.should == 'My projects'
|
|
|
|
end
|
2011-08-13 23:24:02 +00:00
|
|
|
|
2011-07-28 04:22:44 +00:00
|
|
|
it 'includes new description' do
|
|
|
|
@projects.description.should == 'My portfolio'
|
|
|
|
end
|
2011-08-13 23:24:02 +00:00
|
|
|
|
2011-07-28 04:22:44 +00:00
|
|
|
it 'includes new order by' do
|
|
|
|
@projects.order_by.should == '_position_in_list'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2010-10-28 23:36:45 +00:00
|
|
|
|
2011-08-03 06:58:47 +00:00
|
|
|
end
|