Sha256: 4a64bfd396548ce99c6a8ef0f5bfc7d1811ceb76bd2f0ed05175a005a74d1812
Contents?: true
Size: 1.46 KB
Versions: 11
Compression:
Stored size: 1.46 KB
Contents
require 'spec_helper' module Ransack module Adapters module ActiveRecord describe Context do subject { Context.new(Person) } describe '#evaluate' do it 'evaluates search obects' do search = Search.new(Person, :name_eq => 'Joe Blow') result = subject.evaluate(search) result.should be_an ::ActiveRecord::Relation result.to_sql.should match /"name" = 'Joe Blow'/ end it 'SELECTs DISTINCT when :distinct => true' do search = Search.new(Person, :name_eq => 'Joe Blow') result = subject.evaluate(search, :distinct => true) result.should be_an ::ActiveRecord::Relation result.to_sql.should match /SELECT DISTINCT/ end end it 'contextualizes strings to attributes' do attribute = subject.contextualize 'children_children_parent_name' attribute.should be_a Arel::Attributes::Attribute attribute.name.to_s.should eq 'name' attribute.relation.table_alias.should eq 'parents_people' end it 'builds new associations if not yet built' do attribute = subject.contextualize 'children_articles_title' attribute.should be_a Arel::Attributes::Attribute attribute.name.to_s.should eq 'title' attribute.relation.name.should eq 'articles' attribute.relation.table_alias.should be_nil end end end end end
Version data entries
11 entries across 11 versions & 2 rubygems