diff --git a/Gemfile b/Gemfile index 5c881251..99091b1d 100755 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index 3ceb1da5..b484e925 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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: diff --git a/lib/locomotive/liquid/drops/content_entry.rb b/lib/locomotive/liquid/drops/content_entry.rb index 99420387..237292b4 100644 --- a/lib/locomotive/liquid/drops/content_entry.rb +++ b/lib/locomotive/liquid/drops/content_entry.rb @@ -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 diff --git a/locomotive_cms.gemspec b/locomotive_cms.gemspec index 9202b52a..4463f05d 100755 --- a/locomotive_cms.gemspec +++ b/locomotive_cms.gemspec @@ -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' diff --git a/spec/lib/locomotive/liquid/drops/content_entry_spec.rb b/spec/lib/locomotive/liquid/drops/content_entry_spec.rb index 0b6cd6a1..2a96bd75 100644 --- a/spec/lib/locomotive/liquid/drops/content_entry_spec.rb +++ b/spec/lib/locomotive/liquid/drops/content_entry_spec.rb @@ -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