Sha256: 3dbe756489697562cc0c9be18637fa27f78d7c26d79b9dec6c6c362bb977653f
Contents?: true
Size: 1.52 KB
Versions: 2
Compression:
Stored size: 1.52 KB
Contents
require 'test_helper' module Rails3JQueryAutocomplete module Orm class MongoidTest < Test::Unit::TestCase include Rails3JQueryAutocomplete::Orm::Mongoid context "#get_autocomplete_order" do context "order is specified" do should 'returns the parametrized order for Mongoid' do assert_equal [[:field, :asc], [:state, :desc]], get_autocomplete_order(:method, :order => 'field ASC, state DESC') end end context 'order is not specified' do should 'return the method ordered ASC by default' do assert_equal [[:method, :asc]], get_autocomplete_order(:method, {}) end end end context "#get_autocomplete_items" do setup do @model = mock(Object) @parameters = { :model => @model, :method => :field, :term => 'query', :options => {:full => false} } mock(self).get_autocomplete_limit(anything) { 10 } mock(self).get_autocomplete_order(anything, anything) { [[:order, :asc]] } end context 'not a full search' do should 'do stuff' do mock(@model).where({:field=>/^query.*/i}).mock!.limit(10). mock!.order_by([[:order, :asc]]) get_autocomplete_items(@parameters) end end context 'full search' do should 'return a full search query' do @parameters[:options] = {:full => true} mock(@model).where({:field=>/.*query.*/i}).mock!.limit(10). mock!.order_by([[:order, :asc]]) get_autocomplete_items(@parameters) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails3-jquery-autocomplete-0.9.1 | test/lib/rails3-jquery-autocomplete/orm/mongoid_test.rb |
rails3-jquery-autocomplete-0.9.0 | test/lib/rails3-jquery-autocomplete/orm/mongoid_test.rb |