Merge branch 'master' into rails_3_1
Conflicts: app/models/content_type.rb config/boot.rb
This commit is contained in:
commit
9a1a0f016f
@ -101,7 +101,7 @@ module Locomotive
|
||||
end
|
||||
|
||||
self.contents.where(conditions_with_names)
|
||||
end).sort { |a, b| (a.send(column) || 0) <=> (b.send(column) || 0) }
|
||||
end).sort { |a, b| (a.send(column) && b.send(column)) ? (a.send(column) || 0) <=> (b.send(column) || 0) : 0 }
|
||||
|
||||
return list if self.order_manually?
|
||||
|
||||
|
@ -305,7 +305,7 @@ module Locomotive
|
||||
content.send(field.safe_alias.to_sym)
|
||||
end)
|
||||
|
||||
hash[field._alias] = value unless value.blank?
|
||||
hash[field._alias] = value if value.present? || value == false # False values should be preserved in the export
|
||||
end
|
||||
|
||||
data << { content.highlighted_field_value => hash }
|
||||
|
@ -9,7 +9,7 @@ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
|
||||
# delayed job version is released?
|
||||
#
|
||||
require 'yaml'
|
||||
YAML::ENGINE.yamler = 'syck'
|
||||
YAML::ENGINE.yamler = 'syck' if defined?(YAML::ENGINE)
|
||||
|
||||
if File.exist?(gemfile)
|
||||
ENV['BUNDLE_GEMFILE'] = gemfile
|
||||
|
@ -25,7 +25,8 @@ describe Locomotive::Export do
|
||||
end
|
||||
|
||||
it 'deals with real booleans' do
|
||||
@project_data.first.values.first['active'].should be_true
|
||||
@project_data.first.values.first['active'].should === true
|
||||
@project_data.last.values.first['active'].should === false
|
||||
end
|
||||
|
||||
it 'stores the list of highlighted values in a has_many relationship' do
|
||||
|
@ -89,6 +89,20 @@ describe Locomotive::ContentType do
|
||||
@content_type.order_direction = 'desc'
|
||||
@content_type.ordered_contents.collect(&:name).should == %w(Sacha Did)
|
||||
end
|
||||
|
||||
it 'returns a list of contents ordered by a Date column when first instance is missing the value' do
|
||||
@content_type = FactoryGirl.build(:content_type, :order_by => 'created_at')
|
||||
@content_type.content_custom_fields.build :label => 'Active at', :name => 'active_at', :kind => 'Date'
|
||||
e = Date.parse('01/01/2001')
|
||||
l = Date.parse('02/02/2002')
|
||||
[nil,e,l].each { |d| @content_type.contents << @content_type.content_klass.new(:active_at => d) }
|
||||
@content_type.order_by = 'active_at'
|
||||
@content_type.order_direction = 'asc'
|
||||
lambda { @content_type.ordered_contents }.should_not raise_error(ArgumentError)
|
||||
@content_type.ordered_contents.map(&:active_at).should == [nil,e,l]
|
||||
@content_type.order_direction = 'desc'
|
||||
@content_type.ordered_contents.map(&:active_at).should == [l,e,nil]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user