Sha256: bb0c25eafedced410938c63909d1d53e6e7412a470155450c5e39032270a5ee2
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
require 'spec_helper' module Ransack module Adapters module ActiveRecord describe Context do subject { Context.new(Person) } describe '#relation_for' do it 'returns relation for given object' do subject.object.should be_an ::ActiveRecord::Relation end end describe '#evaluate' do it 'evaluates search objects' do search = Search.new(Person, :name_eq => 'Joe Blow') result = subject.evaluate(search) result.should be_an ::ActiveRecord::Relation result.to_sql.should match /#{quote_column_name("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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ransack-1.1.0 | spec/ransack/adapters/active_record/context_spec.rb |