Sha256: f334a840d2cfb50509861e2304e298551a976809f3bc247deb91d5e80addc1e9
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
require 'spec_helper' shared_examples_for 'order parameter' do describe ':order' do if testing_active_record? it 'should be able to order the result set asc' do scope = Post.by_year(Time.zone.now.year, order: 'created_at ASC') expect(scope.order_values).to eq ['created_at ASC'] expect(scope.first.created_at).to eq Time.zone.parse('2014-01-01 17:00:00') end it 'should be able to order the result set desc' do scope = Post.by_year(Time.zone.now.year, order: 'created_at DESC') expect(scope.order_values).to eq ['created_at DESC'] expect(scope.first.created_at).to eq Time.zone.parse('2014-04-15 17:00:00') end elsif testing_mongoid? it 'should be able to order the result set asc' do scope = Post.by_year(Time.zone.now.year, order: {created_at: :asc}) expect(scope.options[:sort]).to eq({'created_at' => 1}) expect(scope.first.created_at).to eq Time.zone.parse('2014-01-01 17:00:00') end it 'should be able to order the result set desc' do scope = Post.by_year(Time.zone.now.year, order: {created_at: :desc}) expect(scope.options[:sort]).to eq({'created_at' => -1}) expect(scope.first.created_at).to eq Time.zone.parse('2014-04-15 17:00:00') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
by_star-4.0.1 | spec/integration/shared/order_parameter.rb |