diff options
Diffstat (limited to 'vendor/plugins/thinking-sphinx/spec/unit/thinking_sphinx_spec.rb')
| -rw-r--r-- | vendor/plugins/thinking-sphinx/spec/unit/thinking_sphinx_spec.rb | 133 |
1 files changed, 0 insertions, 133 deletions
diff --git a/vendor/plugins/thinking-sphinx/spec/unit/thinking_sphinx_spec.rb b/vendor/plugins/thinking-sphinx/spec/unit/thinking_sphinx_spec.rb deleted file mode 100644 index 375e158..0000000 --- a/vendor/plugins/thinking-sphinx/spec/unit/thinking_sphinx_spec.rb +++ /dev/null | |||
| @@ -1,133 +0,0 @@ | |||
| 1 | require 'spec/spec_helper' | ||
| 2 | |||
| 3 | describe ThinkingSphinx do | ||
| 4 | it "should define indexes by default" do | ||
| 5 | ThinkingSphinx.define_indexes?.should be_true | ||
| 6 | end | ||
| 7 | |||
| 8 | it "should disable index definition" do | ||
| 9 | ThinkingSphinx.define_indexes = false | ||
| 10 | ThinkingSphinx.define_indexes?.should be_false | ||
| 11 | end | ||
| 12 | |||
| 13 | it "should enable index definition" do | ||
| 14 | ThinkingSphinx.define_indexes = false | ||
| 15 | ThinkingSphinx.define_indexes?.should be_false | ||
| 16 | ThinkingSphinx.define_indexes = true | ||
| 17 | ThinkingSphinx.define_indexes?.should be_true | ||
| 18 | end | ||
| 19 | |||
| 20 | it "should index deltas by default" do | ||
| 21 | ThinkingSphinx.deltas_enabled = nil | ||
| 22 | ThinkingSphinx.deltas_enabled?.should be_true | ||
| 23 | end | ||
| 24 | |||
| 25 | it "should disable delta indexing" do | ||
| 26 | ThinkingSphinx.deltas_enabled = false | ||
| 27 | ThinkingSphinx.deltas_enabled?.should be_false | ||
| 28 | end | ||
| 29 | |||
| 30 | it "should enable delta indexing" do | ||
| 31 | ThinkingSphinx.deltas_enabled = false | ||
| 32 | ThinkingSphinx.deltas_enabled?.should be_false | ||
| 33 | ThinkingSphinx.deltas_enabled = true | ||
| 34 | ThinkingSphinx.deltas_enabled?.should be_true | ||
| 35 | end | ||
| 36 | |||
| 37 | it "should update indexes by default" do | ||
| 38 | ThinkingSphinx.updates_enabled = nil | ||
| 39 | ThinkingSphinx.updates_enabled?.should be_true | ||
| 40 | end | ||
| 41 | |||
| 42 | it "should disable index updating" do | ||
| 43 | ThinkingSphinx.updates_enabled = false | ||
| 44 | ThinkingSphinx.updates_enabled?.should be_false | ||
| 45 | end | ||
| 46 | |||
| 47 | it "should enable index updating" do | ||
| 48 | ThinkingSphinx.updates_enabled = false | ||
| 49 | ThinkingSphinx.updates_enabled?.should be_false | ||
| 50 | ThinkingSphinx.updates_enabled = true | ||
| 51 | ThinkingSphinx.updates_enabled?.should be_true | ||
| 52 | end | ||
| 53 | |||
| 54 | describe "use_group_by_shortcut? method" do | ||
| 55 | before :each do | ||
| 56 | adapter = defined?(JRUBY_VERSION) ? :JdbcAdapter : :MysqlAdapter | ||
| 57 | unless ::ActiveRecord::ConnectionAdapters.const_defined?(adapter) | ||
| 58 | pending "No MySQL" | ||
| 59 | return | ||
| 60 | end | ||
| 61 | |||
| 62 | @connection = ::ActiveRecord::ConnectionAdapters.const_get(adapter).stub_instance( | ||
| 63 | :select_all => true, | ||
| 64 | :config => {:adapter => defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql'} | ||
| 65 | ) | ||
| 66 | ::ActiveRecord::Base.stub_method( | ||
| 67 | :connection => @connection | ||
| 68 | ) | ||
| 69 | end | ||
| 70 | |||
| 71 | it "should return true if no ONLY_FULL_GROUP_BY" do | ||
| 72 | @connection.stub_method( | ||
| 73 | :select_all => {:a => "OTHER SETTINGS"} | ||
| 74 | ) | ||
| 75 | |||
| 76 | ThinkingSphinx.use_group_by_shortcut?.should be_true | ||
| 77 | end | ||
| 78 | |||
| 79 | it "should return true if NULL value" do | ||
| 80 | @connection.stub_method( | ||
| 81 | :select_all => {:a => nil} | ||
| 82 | ) | ||
| 83 | |||
| 84 | ThinkingSphinx.use_group_by_shortcut?.should be_true | ||
| 85 | end | ||
| 86 | |||
| 87 | it "should return false if ONLY_FULL_GROUP_BY is set" do | ||
| 88 | @connection.stub_method( | ||
| 89 | :select_all => {:a => "OTHER SETTINGS,ONLY_FULL_GROUP_BY,blah"} | ||
| 90 | ) | ||
| 91 | |||
| 92 | ThinkingSphinx.use_group_by_shortcut?.should be_false | ||
| 93 | end | ||
| 94 | |||
| 95 | it "should return false if ONLY_FULL_GROUP_BY is set in any of the values" do | ||
| 96 | @connection.stub_method( | ||
| 97 | :select_all => { | ||
| 98 | :a => "OTHER SETTINGS", | ||
| 99 | :b => "ONLY_FULL_GROUP_BY" | ||
| 100 | } | ||
| 101 | ) | ||
| 102 | |||
| 103 | ThinkingSphinx.use_group_by_shortcut?.should be_false | ||
| 104 | end | ||
| 105 | |||
| 106 | describe "if not using MySQL" do | ||
| 107 | before :each do | ||
| 108 | adapter = defined?(JRUBY_VERSION) ? :JdbcAdapter : :PostgreSQLAdapter | ||
| 109 | unless ::ActiveRecord::ConnectionAdapters.const_defined?(adapter) | ||
| 110 | pending "No PostgreSQL" | ||
| 111 | return | ||
| 112 | end | ||
| 113 | @connection = ::ActiveRecord::ConnectionAdapters.const_get(adapter).stub_instance( | ||
| 114 | :select_all => true, | ||
| 115 | :config => {:adapter => defined?(JRUBY_VERSION) ? 'jdbcpostgresql' : 'postgresql'} | ||
| 116 | ) | ||
| 117 | ::ActiveRecord::Base.stub_method( | ||
| 118 | :connection => @connection | ||
| 119 | ) | ||
| 120 | end | ||
| 121 | |||
| 122 | it "should return false" do | ||
| 123 | ThinkingSphinx.use_group_by_shortcut?.should be_false | ||
| 124 | end | ||
| 125 | |||
| 126 | it "should not call select_all" do | ||
| 127 | ThinkingSphinx.use_group_by_shortcut? | ||
| 128 | |||
| 129 | @connection.should_not have_received(:select_all) | ||
| 130 | end | ||
| 131 | end | ||
| 132 | end | ||
| 133 | end | ||
