This commit is contained in:
Didier Lafforgue 2012-04-19 16:30:16 +02:00
parent 9267725c9f
commit 9b4fc56e82
5 changed files with 17 additions and 23 deletions

View File

@ -8,8 +8,8 @@ gemspec # Include gemspec dependencies
# The rest of the dependencies are for use when in the locomotive development environment
group :development do
# gem 'custom_fields', :path => '../gems/custom_fields' # for Developers
gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git', :branch => '2.0.0.rc' # Branch on Github
gem 'custom_fields', :path => '../gems/custom_fields' # for Developers
# gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git', :branch => '2.0.0.rc' # Branch on Github
gem 'rspec-rails', '~> 2.8.0' # In order to have rspec tasks and generators
gem 'rspec-cells'

View File

@ -15,16 +15,6 @@ GIT
fssm (>= 0.2.7)
sass (~> 3.1)
GIT
remote: git://github.com/locomotivecms/custom_fields.git
revision: 5b0e68859eaca41ac9d7a0231c6cd68ad66018b8
branch: 2.0.0.rc
specs:
custom_fields (2.0.0.rc9)
activesupport (~> 3.2.1)
carrierwave-mongoid (~> 0.1.3)
mongoid (~> 2.4.7)
PATH
remote: .
specs:
@ -37,7 +27,7 @@ PATH
carrierwave-mongoid (~> 0.1.3)
cells (~> 3.8.0)
codemirror-rails (~> 2.21)
custom_fields (~> 2.0.0.rc9)
custom_fields (~> 2.0.0.rc10)
devise (~> 1.5.3)
dragonfly (~> 0.9.8)
flash_cookie_session (~> 1.1.1)
@ -65,6 +55,14 @@ PATH
sanitize (~> 2.0.3)
unidecoder (~> 1.1.1)
PATH
remote: ../gems/custom_fields
specs:
custom_fields (2.0.0.rc10)
activesupport (~> 3.2.1)
carrierwave-mongoid (~> 0.1.3)
mongoid (~> 2.4.7)
GEM
remote: http://rubygems.org/
specs:

View File

@ -63,12 +63,9 @@ module Locomotive
conditions = HashWithIndifferentAccess.new(@context['with_scope'])
order_by = conditions.delete(:order_by).try(:split)
if order_by.nil?
list.where(conditions).ordered
else
list.where(conditions).order_by(order_by)
end
list.filtered(conditions, order_by)
else
# no filter, default order
list.ordered
end
end

View File

@ -30,7 +30,7 @@ Gem::Specification.new do |s|
s.add_dependency 'mongoid', '~> 2.4.6'
s.add_dependency 'locomotive-mongoid-tree', '~> 0.6.2'
s.add_dependency 'custom_fields', '~> 2.0.0.rc9'
s.add_dependency 'custom_fields', '~> 2.0.0.rc10'
s.add_dependency 'kaminari', '~> 0.13.0'

View File

@ -5,6 +5,7 @@ describe Locomotive::Liquid::Drops::ContentEntry do
before(:each) do
@list = mock('list')
@list.stubs(:all).returns(true)
# @list.stubs(:to_liquid).returns(true)
@category = Locomotive::Liquid::Drops::ContentEntry.new(mock('category', :projects => @list))
end
@ -21,8 +22,7 @@ describe Locomotive::Liquid::Drops::ContentEntry do
it 'filters the list' do
template = %({% with_scope order_by: 'name ASC', active: true %}{% for project in category.projects %}{{ project }},{% endfor %}{% endwith_scope %})
@list.expects(:order_by).with(['name', 'ASC']).returns(%w(a b))
@list.expects(:where).with({ 'active' => true }).returns(@list)
@list.expects(:filtered).with({ 'active' => true }, ['name', 'ASC']).returns(%w(a b))
render(template, { 'category' => @category }).should == 'a,b,'
end
@ -30,8 +30,7 @@ describe Locomotive::Liquid::Drops::ContentEntry do
it 'filters the list and uses the default order' do
template = %({% with_scope active: true %}{% for project in category.projects %}{{ project }},{% endfor %}{% endwith_scope %})
@list.expects(:ordered).returns(%w(a b))
@list.expects(:where).with({ 'active' => true }).returns(@list)
@list.expects(:filtered).with({ 'active' => true }, nil).returns(%w(a b))
render(template, { 'category' => @category }).should == 'a,b,'
end