Sha256: 098979a0d8c7b534e93c9689115d2393185f9cc7ef3d4abf1c5bc32e6b32016b
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
require 'spec/spec_helper' describe ThinkingSphinx::Field do describe "to_select_sql method" do before :each do @index = Person.indexes.first @index.link! end it "should concat with spaces if there are multiple columns" do @index.fields.first.to_select_sql.should match(/CONCAT_WS\(' ', /) end it "should concat with spaces if a column has more than one association" do @index.fields[1].to_select_sql.should match(/CONCAT_WS\(' ', /) end it "should group if any association for any column is a has_many or has_and_belongs_to_many" do @index.fields[2].to_select_sql.should match(/GROUP_CONCAT/) end end describe "to_group_sql method" do before :each do @field = ThinkingSphinx::Field.new([]) @field.stub_methods(:is_many? => false) ThinkingSphinx.stub_method(:use_group_by_shortcut? => false) end it "should return nil if is_many?" do @field.stub_method(:is_many? => true) @field.to_group_sql.should be_nil end it "should return nil if group_by shortcut is allowed" do ThinkingSphinx.stub_method(:use_group_by_shortcut? => true) @field.to_group_sql.should be_nil end it "should return an array if neither is_many? or shortcut allowed" do @field.to_group_sql.should be_a_kind_of(Array) end after :each do ThinkingSphinx.unstub_method(:use_group_by_shortcut?) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
freelancing-god-thinking-sphinx-0.9.5 | spec/unit/thinking_sphinx/field_spec.rb |
freelancing-god-thinking-sphinx-0.9.6 | spec/unit/thinking_sphinx/field_spec.rb |