fix issue #360
This commit is contained in:
parent
9267725c9f
commit
9b4fc56e82
4
Gemfile
4
Gemfile
@ -8,8 +8,8 @@ gemspec # Include gemspec dependencies
|
|||||||
# The rest of the dependencies are for use when in the locomotive development environment
|
# The rest of the dependencies are for use when in the locomotive development environment
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
# gem 'custom_fields', :path => '../gems/custom_fields' # for Developers
|
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', :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-rails', '~> 2.8.0' # In order to have rspec tasks and generators
|
||||||
gem 'rspec-cells'
|
gem 'rspec-cells'
|
||||||
|
20
Gemfile.lock
20
Gemfile.lock
@ -15,16 +15,6 @@ GIT
|
|||||||
fssm (>= 0.2.7)
|
fssm (>= 0.2.7)
|
||||||
sass (~> 3.1)
|
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
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
@ -37,7 +27,7 @@ PATH
|
|||||||
carrierwave-mongoid (~> 0.1.3)
|
carrierwave-mongoid (~> 0.1.3)
|
||||||
cells (~> 3.8.0)
|
cells (~> 3.8.0)
|
||||||
codemirror-rails (~> 2.21)
|
codemirror-rails (~> 2.21)
|
||||||
custom_fields (~> 2.0.0.rc9)
|
custom_fields (~> 2.0.0.rc10)
|
||||||
devise (~> 1.5.3)
|
devise (~> 1.5.3)
|
||||||
dragonfly (~> 0.9.8)
|
dragonfly (~> 0.9.8)
|
||||||
flash_cookie_session (~> 1.1.1)
|
flash_cookie_session (~> 1.1.1)
|
||||||
@ -65,6 +55,14 @@ PATH
|
|||||||
sanitize (~> 2.0.3)
|
sanitize (~> 2.0.3)
|
||||||
unidecoder (~> 1.1.1)
|
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
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
|
@ -63,12 +63,9 @@ module Locomotive
|
|||||||
conditions = HashWithIndifferentAccess.new(@context['with_scope'])
|
conditions = HashWithIndifferentAccess.new(@context['with_scope'])
|
||||||
order_by = conditions.delete(:order_by).try(:split)
|
order_by = conditions.delete(:order_by).try(:split)
|
||||||
|
|
||||||
if order_by.nil?
|
list.filtered(conditions, order_by)
|
||||||
list.where(conditions).ordered
|
|
||||||
else
|
|
||||||
list.where(conditions).order_by(order_by)
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
|
# no filter, default order
|
||||||
list.ordered
|
list.ordered
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -30,7 +30,7 @@ Gem::Specification.new do |s|
|
|||||||
s.add_dependency 'mongoid', '~> 2.4.6'
|
s.add_dependency 'mongoid', '~> 2.4.6'
|
||||||
s.add_dependency 'locomotive-mongoid-tree', '~> 0.6.2'
|
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'
|
s.add_dependency 'kaminari', '~> 0.13.0'
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ describe Locomotive::Liquid::Drops::ContentEntry do
|
|||||||
before(:each) do
|
before(:each) do
|
||||||
@list = mock('list')
|
@list = mock('list')
|
||||||
@list.stubs(:all).returns(true)
|
@list.stubs(:all).returns(true)
|
||||||
|
# @list.stubs(:to_liquid).returns(true)
|
||||||
@category = Locomotive::Liquid::Drops::ContentEntry.new(mock('category', :projects => @list))
|
@category = Locomotive::Liquid::Drops::ContentEntry.new(mock('category', :projects => @list))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -21,8 +22,7 @@ describe Locomotive::Liquid::Drops::ContentEntry do
|
|||||||
it 'filters the list' do
|
it 'filters the list' do
|
||||||
template = %({% with_scope order_by: 'name ASC', active: true %}{% for project in category.projects %}{{ project }},{% endfor %}{% endwith_scope %})
|
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(:filtered).with({ 'active' => true }, ['name', 'ASC']).returns(%w(a b))
|
||||||
@list.expects(:where).with({ 'active' => true }).returns(@list)
|
|
||||||
|
|
||||||
render(template, { 'category' => @category }).should == 'a,b,'
|
render(template, { 'category' => @category }).should == 'a,b,'
|
||||||
end
|
end
|
||||||
@ -30,8 +30,7 @@ describe Locomotive::Liquid::Drops::ContentEntry do
|
|||||||
it 'filters the list and uses the default order' 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 %})
|
template = %({% with_scope active: true %}{% for project in category.projects %}{{ project }},{% endfor %}{% endwith_scope %})
|
||||||
|
|
||||||
@list.expects(:ordered).returns(%w(a b))
|
@list.expects(:filtered).with({ 'active' => true }, nil).returns(%w(a b))
|
||||||
@list.expects(:where).with({ 'active' => true }).returns(@list)
|
|
||||||
|
|
||||||
render(template, { 'category' => @category }).should == 'a,b,'
|
render(template, { 'category' => @category }).should == 'a,b,'
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user