Merge pull request #303 from giorgian/export_contents_order

Export contents order
This commit is contained in:
Didier Lafforgue 2012-03-03 05:35:01 -08:00
commit 31669d5253
3 changed files with 23 additions and 1 deletions

View File

@ -277,7 +277,7 @@ module Locomotive
highlighted_field_name = content_type.highlighted_field_name highlighted_field_name = content_type.highlighted_field_name
content_type.contents.each do |content| content_type.ordered_contents.each do |content|
hash = {} hash = {}
content.custom_fields.each do |field| content.custom_fields.each do |field|

View File

@ -136,6 +136,7 @@ FactoryGirl.define do
factory :content_type do factory :content_type do
name 'My project' name 'My project'
site { Site.where(:subdomain => "acme").first || Factory(:site) } site { Site.where(:subdomain => "acme").first || Factory(:site) }
order_by 'created_at'
end end
factory :content_instance do factory :content_instance do

View File

@ -60,6 +60,27 @@ describe Locomotive::Export do
end end
context 'manually ordered content_types' do
before(:each) do
site = FactoryGirl.build('another site')
Site.stubs(:find).returns(site)
@wish_type = build_wish_type(site)
@wish_type.contents.build(:what => 'nothing', :_position_in_list => 2)
@wish_type.contents.build(:what => 'everything', :_position_in_list => 1)
@wish_data = ::Locomotive::Export.new(site).send(:extract_contents, @wish_type)
end
it 'should have the right order' do
@wish_data.should == [{'everything' => {}}, {'nothing' => {}}]
end
end
def build_wish_type(site)
site.content_types.build(:slug => 'wishes', :name => 'Wishes', :site => site, :order_by => '_position_in_list', :order_direction => 'asc', :highlighted_field_name => 'custom_field_1').tap do |content_type|
content_type.content_custom_fields.build :label => 'What', :_alias => 'what', :kind => 'string'
end
end
context '#zipfile' do context '#zipfile' do
before(:all) do before(:all) do