moneypools-thinking-sphinx 1.2.13 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. data/VERSION.yml +3 -2
  2. data/features/searching_across_models.feature +1 -1
  3. data/features/step_definitions/common_steps.rb +0 -1
  4. data/features/step_definitions/facet_steps.rb +1 -1
  5. data/features/support/{db/database.example.yml → database.example.yml} +0 -0
  6. data/features/support/db/fixtures/robots.rb +1 -1
  7. data/features/support/db/migrations/create_robots.rb +1 -2
  8. data/features/support/env.rb +13 -1
  9. data/features/support/models/robot.rb +4 -0
  10. data/lib/cucumber/thinking_sphinx/external_world.rb +41 -0
  11. data/lib/cucumber/thinking_sphinx/internal_world.rb +125 -0
  12. data/lib/cucumber/thinking_sphinx/sql_logger.rb +20 -0
  13. data/lib/thinking_sphinx.rb +3 -2
  14. data/lib/thinking_sphinx/active_record.rb +2 -2
  15. data/lib/thinking_sphinx/adapters/mysql_adapter.rb +1 -1
  16. data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +18 -11
  17. data/lib/thinking_sphinx/attribute.rb +3 -3
  18. data/lib/thinking_sphinx/deltas.rb +0 -2
  19. data/lib/thinking_sphinx/tasks.rb +1 -33
  20. data/spec/lib/thinking_sphinx/active_record_spec.rb +6 -6
  21. data/spec/lib/thinking_sphinx_spec.rb +4 -0
  22. data/tasks/distribution.rb +2 -15
  23. data/tasks/testing.rb +8 -19
  24. data/vendor/riddle/lib/riddle.rb +1 -1
  25. data/vendor/riddle/lib/riddle/controller.rb +8 -15
  26. metadata +8 -36
  27. data/features/a.rb +0 -17
  28. data/features/datetime_deltas.feature +0 -66
  29. data/features/delayed_delta_indexing.feature +0 -37
  30. data/features/step_definitions/datetime_delta_steps.rb +0 -15
  31. data/features/step_definitions/delayed_delta_indexing_steps.rb +0 -7
  32. data/features/support/db/fixtures/delayed_betas.rb +0 -10
  33. data/features/support/db/fixtures/thetas.rb +0 -10
  34. data/features/support/db/migrations/create_delayed_betas.rb +0 -17
  35. data/features/support/db/migrations/create_thetas.rb +0 -5
  36. data/features/support/models/delayed_beta.rb +0 -7
  37. data/features/support/models/theta.rb +0 -7
  38. data/features/support/z.rb +0 -19
  39. data/lib/thinking_sphinx/deltas/datetime_delta.rb +0 -50
  40. data/lib/thinking_sphinx/deltas/delayed_delta.rb +0 -34
  41. data/lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb +0 -24
  42. data/lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb +0 -27
  43. data/lib/thinking_sphinx/deltas/delayed_delta/job.rb +0 -26
  44. data/spec/lib/thinking_sphinx/deltas/job_spec.rb +0 -32
@@ -1,4 +1,5 @@
1
1
  ---
2
+ :patch: 1
2
3
  :major: 1
3
- :minor: 2
4
- :patch: 13
4
+ :build:
5
+ :minor: 3
@@ -17,4 +17,4 @@ Feature: Searching across multiple model
17
17
  Scenario: Retrieving results from multiple models
18
18
  Given Sphinx is running
19
19
  When I search for ten
20
- Then I should get 6 results
20
+ Then I should get 4 results
@@ -1,6 +1,5 @@
1
1
  Before do
2
2
  $queries_executed = []
3
- ThinkingSphinx::Deltas::Job.cancel_thinking_sphinx_jobs
4
3
 
5
4
  @model = nil
6
5
  @method = :search
@@ -1,4 +1,4 @@
1
- When "I am requesting facet results$" do
1
+ When /^I am requesting facet results$/ do
2
2
  @results = nil
3
3
  @method = :facets
4
4
  end
@@ -1,6 +1,6 @@
1
1
  # Reset the primary key to allow us to create robots with specific internal_ids
2
2
  class Robot < ActiveRecord::Base
3
- set_primary_key :id
3
+ set_primary_key :alternate_primary_key
4
4
  end
5
5
 
6
6
  Robot.create :name => 'Fritz', :internal_id => 'F0001'
@@ -1,5 +1,4 @@
1
- ActiveRecord::Base.connection.create_table :robots, :id => false, :force => true do |t|
2
- t.column :alternate_primary_key, "int(11) DEFAULT NULL auto_increment PRIMARY KEY"
1
+ ActiveRecord::Base.connection.create_table :robots, :primary_key => :alternate_primary_key, :force => true do |t|
3
2
  t.column :name, :string, :null => false
4
3
  t.column :internal_id, :string, :null => false
5
4
  end
@@ -3,4 +3,16 @@ require 'cucumber'
3
3
  require 'spec'
4
4
  require 'fileutils'
5
5
  require 'ginger'
6
- require 'will_paginate'
6
+ require 'will_paginate'
7
+ require 'active_record'
8
+
9
+ $:.unshift File.dirname(__FILE__) + '/../../lib'
10
+
11
+ require 'cucumber/thinking_sphinx/internal_world'
12
+
13
+ world = Cucumber::ThinkingSphinx::InternalWorld.new
14
+ world.configure_database
15
+
16
+ require 'thinking_sphinx'
17
+
18
+ world.setup
@@ -5,4 +5,8 @@ class Robot < ActiveRecord::Base
5
5
  define_index do
6
6
  indexes :name
7
7
  end
8
+
9
+ def id
10
+ internal_id
11
+ end
8
12
  end
@@ -0,0 +1,41 @@
1
+ module Cucumber
2
+ module ThinkingSphinx
3
+ class ExternalWorld
4
+ def initialize(suppress_delta_output = true)
5
+ set_flags suppress_delta_output
6
+ create_indexes_folder
7
+ prepare_and_start_daemon
8
+ configure_cleanup
9
+ end
10
+
11
+ private
12
+
13
+ def config
14
+ @config ||= ::ThinkingSphinx::Configuration.instance
15
+ end
16
+
17
+ def set_flags(suppress_delta_output)
18
+ ::ThinkingSphinx.deltas_enabled = true
19
+ ::ThinkingSphinx.updates_enabled = true
20
+ ::ThinkingSphinx.suppress_delta_output = suppress_delta_output
21
+ end
22
+
23
+ def create_indexes_folder
24
+ FileUtils.mkdir_p config.searchd_file_path
25
+ end
26
+
27
+ def prepare_and_start_daemon
28
+ config.build
29
+ config.controller.index
30
+ config.controller.start
31
+ end
32
+
33
+ def configure_cleanup
34
+ Kernel.at_exit do
35
+ config.controller.stop
36
+ sleep(0.5) # Ensure Sphinx has shut down completely
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,125 @@
1
+ require 'cucumber/thinking_sphinx/sql_logger'
2
+
3
+ module Cucumber
4
+ module ThinkingSphinx
5
+ class InternalWorld
6
+ attr_accessor :temporary_directory, :migrations_directory,
7
+ :models_directory, :fixtures_directory, :database_file
8
+ attr_accessor :adapter, :database, :username,
9
+ :password, :host
10
+
11
+ def initialize
12
+ @temporary_directory = "#{Dir.pwd}/tmp"
13
+ @migrations_directory = "features/support/db/migrations"
14
+ @models_directory = "features/support/models"
15
+ @fixtures_directory = "features/support/db/fixtures"
16
+ @database_file = "features/support/database.yml"
17
+
18
+ @adapter = ENV['DATABASE'] || 'mysql'
19
+ @database = 'thinking_sphinx'
20
+ @username = 'thinking_sphinx'
21
+ # @password = 'thinking_sphinx'
22
+ @host = 'localhost'
23
+ end
24
+
25
+ def setup
26
+ make_temporary_directory
27
+
28
+ configure_cleanup
29
+ configure_thinking_sphinx
30
+ configure_active_record
31
+
32
+ prepare_data
33
+ setup_sphinx
34
+
35
+ self
36
+ end
37
+
38
+ def configure_database
39
+ ActiveRecord::Base.establish_connection database_settings
40
+ self
41
+ end
42
+
43
+ private
44
+
45
+ def config
46
+ @config ||= ::ThinkingSphinx::Configuration.instance
47
+ end
48
+
49
+ def make_temporary_directory
50
+ FileUtils.mkdir_p temporary_directory
51
+ Dir["#{temporary_directory}/*"].each do |file|
52
+ FileUtils.rm_rf file
53
+ end
54
+ end
55
+
56
+ def configure_thinking_sphinx
57
+ config.config_file = "#{temporary_directory}/sphinx.conf"
58
+ config.searchd_log_file = "#{temporary_directory}/searchd.log"
59
+ config.query_log_file = "#{temporary_directory}/searchd.query.log"
60
+ config.pid_file = "#{temporary_directory}/searchd.pid"
61
+ config.searchd_file_path = "#{temporary_directory}/indexes/"
62
+
63
+ ::ThinkingSphinx.suppress_delta_output = true
64
+ end
65
+
66
+ def configure_cleanup
67
+ Kernel.at_exit do
68
+ ::ThinkingSphinx::Configuration.instance.controller.stop
69
+ sleep(0.5) # Ensure Sphinx has shut down completely
70
+ ActiveRecord::Base.logger.close
71
+ end
72
+ end
73
+
74
+ def yaml_database_settings
75
+ return {} unless File.exist?(@database_file)
76
+
77
+ YAML.load open(@database_file)
78
+ end
79
+
80
+ def database_settings
81
+ {
82
+ :adapter => @adapter,
83
+ :database => @database,
84
+ :username => @username,
85
+ :password => @password,
86
+ :host => @host
87
+ }.merge yaml_database_settings
88
+ end
89
+
90
+ def configure_active_record
91
+ ActiveRecord::Base.logger = Logger.new(
92
+ open("#{temporary_directory}/active_record.log", "a")
93
+ )
94
+
95
+ ActiveRecord::Base.connection.class.send(
96
+ :include, Cucumber::ThinkingSphinx::SqlLogger
97
+ )
98
+ end
99
+
100
+ def prepare_data
101
+ ::ThinkingSphinx.deltas_enabled = false
102
+
103
+ load_files migrations_directory
104
+ load_files models_directory
105
+ load_files fixtures_directory
106
+
107
+ ::ThinkingSphinx.deltas_enabled = true
108
+ end
109
+
110
+ def load_files(path)
111
+ Dir["#{path}/*.rb"].each do |file|
112
+ require file.gsub(/\.rb$/, '')
113
+ end
114
+ end
115
+
116
+ def setup_sphinx
117
+ FileUtils.mkdir_p config.searchd_file_path
118
+
119
+ config.build
120
+ config.controller.index
121
+ config.controller.start
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,20 @@
1
+ module Cucumber
2
+ module ThinkingSphinx
3
+ module SqlLogger
4
+ def self.included(base)
5
+ base.send :alias_method_chain, :execute, :query_record
6
+ end
7
+
8
+ IGNORED_SQL = [
9
+ /^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/,
10
+ /^SELECT @@ROWCOUNT/, /^SHOW FIELDS/
11
+ ]
12
+
13
+ def execute_with_query_record(sql, name = nil, &block)
14
+ $queries_executed ||= []
15
+ $queries_executed << sql unless IGNORED_SQL.any? { |r| sql =~ r }
16
+ execute_without_query_record(sql, name, &block)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -131,12 +131,13 @@ module ThinkingSphinx
131
131
  def self.suppress_delta_output=(value)
132
132
  @@suppress_delta_output = value
133
133
  end
134
-
134
+
135
+ @@use_group_by_shortcut = nil
135
136
  # Checks to see if MySQL will allow simplistic GROUP BY statements. If not,
136
137
  # or if not using MySQL, this will return false.
137
138
  #
138
139
  def self.use_group_by_shortcut?
139
- !!(
140
+ @@use_group_by_shortcut ||= !!(
140
141
  mysql? && ::ActiveRecord::Base.connection.select_all(
141
142
  "SELECT @@global.sql_mode, @@session.sql_mode;"
142
143
  ).all? { |key,value| value.nil? || value[/ONLY_FULL_GROUP_BY/].nil? }
@@ -269,13 +269,13 @@ module ThinkingSphinx
269
269
  client.update(
270
270
  "#{self.class.sphinx_indexes.first.name}_core",
271
271
  ['sphinx_deleted'],
272
- {self.sphinx_document_id => 1}
272
+ {self.sphinx_document_id => [1]}
273
273
  ) if self.in_core_index?
274
274
 
275
275
  client.update(
276
276
  "#{self.class.sphinx_indexes.first.name}_delta",
277
277
  ['sphinx_deleted'],
278
- {self.sphinx_document_id => 1}
278
+ {self.sphinx_document_id => [1]}
279
279
  ) if self.class.sphinx_indexes.any? { |index| index.delta? } &&
280
280
  self.toggled_delta?
281
281
  rescue ::ThinkingSphinx::ConnectionError
@@ -13,7 +13,7 @@ module ThinkingSphinx
13
13
  end
14
14
 
15
15
  def group_concatenate(clause, separator = ' ')
16
- "GROUP_CONCAT(DISTINCT #{clause} SEPARATOR '#{separator}')"
16
+ "GROUP_CONCAT(DISTINCT IFNULL(#{clause}, '0') SEPARATOR '#{separator}')"
17
17
  end
18
18
 
19
19
  def cast_to_string(clause)
@@ -10,18 +10,17 @@ module ThinkingSphinx
10
10
  end
11
11
 
12
12
  def concatenate(clause, separator = ' ')
13
- clause.split(', ').collect { |field|
14
- case field
15
- when /COALESCE/, "'')"
16
- field
17
- else
18
- "COALESCE(CAST(#{field} as varchar), '')"
19
- end
20
- }.join(" || '#{separator}' || ")
13
+ if clause[/^COALESCE/]
14
+ clause.split('), ').join(") || '#{separator}' || ")
15
+ else
16
+ clause.split(', ').collect { |field|
17
+ "CAST(COALESCE(#{field}, '') as varchar)"
18
+ }.join(" || '#{separator}' || ")
19
+ end
21
20
  end
22
21
 
23
22
  def group_concatenate(clause, separator = ' ')
24
- "array_to_string(array_accum(#{clause}), '#{separator}')"
23
+ "array_to_string(array_accum(COALESCE(#{clause}, '0')), '#{separator}')"
25
24
  end
26
25
 
27
26
  def cast_to_string(clause)
@@ -37,8 +36,16 @@ module ThinkingSphinx
37
36
  end
38
37
 
39
38
  def convert_nulls(clause, default = '')
40
- default = "'#{default}'" if default.is_a?(String)
41
- default = 'NULL' if default.nil?
39
+ default = case default
40
+ when String
41
+ "'#{default}'"
42
+ when NilClass
43
+ 'NULL'
44
+ when Fixnum
45
+ "#{default}::bigint"
46
+ else
47
+ default
48
+ end
42
49
 
43
50
  "COALESCE(#{clause}, #{default})"
44
51
  end
@@ -101,14 +101,14 @@ module ThinkingSphinx
101
101
  when :datetime
102
102
  adapter.cast_to_datetime(part)
103
103
  when :multi
104
- part = adapter.cast_to_datetime(part) if is_many_datetimes?
105
- adapter.convert_nulls(part, 0)
104
+ part = adapter.cast_to_datetime(part) if is_many_datetimes?
105
+ part = adapter.convert_nulls(part, '0') if is_many_ints?
106
+ part
106
107
  else
107
108
  part
108
109
  end
109
110
  }.join(', ')
110
111
 
111
- # clause = adapter.cast_to_datetime(clause) if type == :datetime
112
112
  clause = adapter.crc(clause) if @crc
113
113
  clause = adapter.concatenate(clause, separator) if concat_ws?
114
114
  clause = adapter.group_concatenate(clause, separator) if is_many?
@@ -1,5 +1,4 @@
1
1
  require 'thinking_sphinx/deltas/default_delta'
2
- require 'thinking_sphinx/deltas/datetime_delta'
3
2
 
4
3
  module ThinkingSphinx
5
4
  module Deltas
@@ -9,7 +8,6 @@ module ThinkingSphinx
9
8
  when TrueClass, :default
10
9
  DefaultDelta.new index, index.local_options
11
10
  when :delayed
12
- require 'thinking_sphinx/deltas/delayed_delta'
13
11
  DelayedDelta.new index, index.local_options
14
12
  when :datetime
15
13
  DatetimeDelta.new index, index.local_options
@@ -65,14 +65,12 @@ namespace :thinking_sphinx do
65
65
 
66
66
  desc "Index data for Sphinx using Thinking Sphinx's settings"
67
67
  task :index => :app_env do
68
- ThinkingSphinx::Deltas::Job.cancel_thinking_sphinx_jobs
69
-
70
68
  config = ThinkingSphinx::Configuration.instance
71
69
  unless ENV["INDEX_ONLY"] == "true"
72
70
  puts "Generating Configuration to #{config.config_file}"
73
71
  config.build
74
72
  end
75
-
73
+
76
74
  FileUtils.mkdir_p config.searchd_file_path
77
75
  cmd = "#{config.bin_path}#{config.indexer_binary_name} --config \"#{config.config_file}\" --all"
78
76
  cmd << " --rotate" if sphinx_running?
@@ -86,30 +84,6 @@ namespace :thinking_sphinx do
86
84
  Rake::Task["thinking_sphinx:index"].invoke
87
85
  Rake::Task["thinking_sphinx:start"].invoke
88
86
  end
89
-
90
- namespace :index do
91
- task :delta => :app_env do
92
- ThinkingSphinx.indexed_models.select { |model|
93
- model.constantize.sphinx_indexes.any? { |index| index.delta? }
94
- }.each do |model|
95
- model.constantize.sphinx_indexes.select { |index|
96
- index.delta? && index.delta_object.respond_to?(:delayed_index)
97
- }.each { |index|
98
- index.delta_object.delayed_index(index.model)
99
- }
100
- end
101
- end
102
- end
103
-
104
- desc "Process stored delta index requests"
105
- task :delayed_delta => :app_env do
106
- require 'delayed/worker'
107
-
108
- Delayed::Worker.new(
109
- :min_priority => ENV['MIN_PRIORITY'],
110
- :max_priority => ENV['MAX_PRIORITY']
111
- ).start
112
- end
113
87
  end
114
88
 
115
89
  namespace :ts do
@@ -123,10 +97,6 @@ namespace :ts do
123
97
  task :stop => "thinking_sphinx:stop"
124
98
  desc "Index data for Sphinx using Thinking Sphinx's settings"
125
99
  task :in => "thinking_sphinx:index"
126
- namespace :in do
127
- desc "Index Thinking Sphinx datetime delta indexes"
128
- task :delta => "thinking_sphinx:index:delta"
129
- end
130
100
  task :index => "thinking_sphinx:index"
131
101
  desc "Restart Sphinx"
132
102
  task :restart => "thinking_sphinx:restart"
@@ -136,8 +106,6 @@ namespace :ts do
136
106
  task :config => "thinking_sphinx:configure"
137
107
  desc "Stop Sphinx (if it's running), rebuild the indexes, and start Sphinx"
138
108
  task :rebuild => "thinking_sphinx:rebuild"
139
- desc "Process stored delta index requests"
140
- task :dd => "thinking_sphinx:delayed_delta"
141
109
  end
142
110
 
143
111
  def sphinx_pid
@@ -203,7 +203,7 @@ describe ThinkingSphinx::ActiveRecord do
203
203
 
204
204
  it "should update the core index's deleted flag if in core index" do
205
205
  @client.should_receive(:update).with(
206
- "person_core", ["sphinx_deleted"], {@person.sphinx_document_id => 1}
206
+ "person_core", ["sphinx_deleted"], {@person.sphinx_document_id => [1]}
207
207
  )
208
208
 
209
209
  @person.toggle_deleted
@@ -212,7 +212,7 @@ describe ThinkingSphinx::ActiveRecord do
212
212
  it "shouldn't update the core index's deleted flag if the record isn't in it" do
213
213
  @person.stub!(:in_core_index? => false)
214
214
  @client.should_not_receive(:update).with(
215
- "person_core", ["sphinx_deleted"], {@person.sphinx_document_id => 1}
215
+ "person_core", ["sphinx_deleted"], {@person.sphinx_document_id => [1]}
216
216
  )
217
217
 
218
218
  @person.toggle_deleted
@@ -231,7 +231,7 @@ describe ThinkingSphinx::ActiveRecord do
231
231
  Person.sphinx_indexes.each { |index| index.stub!(:delta? => true) }
232
232
  @person.delta = true
233
233
  @client.should_receive(:update).with(
234
- "person_delta", ["sphinx_deleted"], {@person.sphinx_document_id => 1}
234
+ "person_delta", ["sphinx_deleted"], {@person.sphinx_document_id => [1]}
235
235
  )
236
236
 
237
237
  @person.toggle_deleted
@@ -242,7 +242,7 @@ describe ThinkingSphinx::ActiveRecord do
242
242
  Person.sphinx_indexes.each { |index| index.stub!(:delta? => true) }
243
243
  @person.delta = false
244
244
  @client.should_not_receive(:update).with(
245
- "person_delta", ["sphinx_deleted"], {@person.sphinx_document_id => 1}
245
+ "person_delta", ["sphinx_deleted"], {@person.sphinx_document_id => [1]}
246
246
  )
247
247
 
248
248
  @person.toggle_deleted
@@ -253,7 +253,7 @@ describe ThinkingSphinx::ActiveRecord do
253
253
  Person.sphinx_indexes.each { |index| index.stub!(:delta? => true) }
254
254
  @person.delta = 0
255
255
  @client.should_not_receive(:update).with(
256
- "person_delta", ["sphinx_deleted"], {@person.sphinx_document_id => 1}
256
+ "person_delta", ["sphinx_deleted"], {@person.sphinx_document_id => [1]}
257
257
  )
258
258
 
259
259
  @person.toggle_deleted
@@ -262,7 +262,7 @@ describe ThinkingSphinx::ActiveRecord do
262
262
  it "shouldn't update the delta index if delta indexes are disabled" do
263
263
  ThinkingSphinx.deltas_enabled = true
264
264
  @client.should_not_receive(:update).with(
265
- "person_delta", ["sphinx_deleted"], {@person.sphinx_document_id => 1}
265
+ "person_delta", ["sphinx_deleted"], {@person.sphinx_document_id => [1]}
266
266
  )
267
267
 
268
268
  @person.toggle_deleted
@@ -93,6 +93,10 @@ describe ThinkingSphinx do
93
93
  ::ActiveRecord::Base.stub!(
94
94
  :connection => @connection
95
95
  )
96
+
97
+ ThinkingSphinx.module_eval do
98
+ class_variable_set :@@use_group_by_shortcut, nil
99
+ end
96
100
  end
97
101
 
98
102
  it "should return true if no ONLY_FULL_GROUP_BY" do
@@ -33,21 +33,8 @@ Jeweler::Tasks.new do |gem|
33
33
  gem.add_dependency 'activerecord', '>= 1.15.6'
34
34
 
35
35
  gem.post_install_message = <<-MESSAGE
36
- With the release of Thinking Sphinx 1.1.18, there is one important change to
37
- note: previously, the default morphology for indexing was 'stem_en'. The new
38
- default is nil, to avoid any unexpected behavior. If you wish to keep the old
39
- value though, you will need to add the following settings to your
40
- config/sphinx.yml file:
41
-
42
- development:
43
- morphology: stem_en
44
- test:
45
- morphology: stem_en
46
- production:
47
- morphology: stem_en
48
-
49
- To understand morphologies/stemmers better, visit the following link:
50
- http://www.sphinxsearch.com/docs/manual-0.9.8.html#conf-morphology
36
+ If you're upgrading, you should read this:
37
+ http://freelancing-god.github.com/ts/en/upgrading.html
51
38
 
52
39
  MESSAGE
53
40
  end
@@ -10,17 +10,17 @@ end
10
10
 
11
11
  desc "Run all feature-set configurations"
12
12
  task :features do |t|
13
- puts "rake features:mysql"
14
- system "rake features:mysql"
15
- puts "rake features:postgresql"
16
- system "rake features:postgresql"
13
+ databases = ENV['DATABASES'] || 'mysql,postgresql'
14
+ databases.split(',').each do |database|
15
+ puts "rake features:#{database}"
16
+ system "rake features:#{database}"
17
+ end
17
18
  end
18
19
 
19
20
  namespace :features do
20
21
  def add_task(name, description)
21
22
  Cucumber::Rake::Task.new(name, description) do |t|
22
- t.cucumber_opts = "--format pretty"
23
- t.profile = name
23
+ t.cucumber_opts = "--format pretty features/*.feature DATABASE=#{name}"
24
24
  end
25
25
  end
26
26
 
@@ -62,22 +62,11 @@ end
62
62
 
63
63
  desc "Build cucumber.yml file"
64
64
  task :cucumber_defaults do
65
- default_requires = %w(
66
- --require features/support/env.rb
67
- --require features/support/db/mysql.rb
68
- --require features/support/db/active_record.rb
69
- --require features/support/post_database.rb
70
- ).join(" ")
71
-
72
- step_definitions = FileList["features/step_definitions/**.rb"].collect { |path|
65
+ steps = FileList["features/step_definitions/**.rb"].collect { |path|
73
66
  "--require #{path}"
74
67
  }.join(" ")
75
68
 
76
- features = FileList["features/*.feature"].join(" ")
77
-
78
69
  File.open('cucumber.yml', 'w') { |f|
79
- f.write "default: \"#{default_requires} #{step_definitions}\"\n\n"
80
- f.write "mysql: \"#{default_requires} #{step_definitions} #{features}\"\n\n"
81
- f.write "postgresql: \"#{default_requires.gsub(/mysql/, 'postgresql')} #{step_definitions} #{features}\""
70
+ f.write "default: \"--require features/support/env.rb #{steps}\"\n"
82
71
  }
83
72
  end
@@ -18,7 +18,7 @@ module Riddle #:nodoc:
18
18
  Rev = 1533
19
19
  # Release number to mark my own fixes, beyond feature parity with
20
20
  # Sphinx itself.
21
- Release = 10
21
+ Release = 11
22
22
 
23
23
  String = [Major, Minor, Tiny].join('.')
24
24
  GemVersion = [Major, Minor, Tiny, Rev, Release].join('.')
@@ -5,14 +5,14 @@ module Riddle
5
5
  @path = path
6
6
  end
7
7
 
8
- def index
9
- run_index('--all')
10
- end
11
-
12
- def partially_index(indexes)
13
- run_index(indexes.join(" "))
8
+ def index(*indexes)
9
+ indexes << '--all' if indexes.empty?
10
+
11
+ cmd = "indexer --config #{@path} #{indexes.join(' ')}"
12
+ cmd << " --rotate" if running?
13
+ `#{cmd}`
14
14
  end
15
-
15
+
16
16
  def start
17
17
  return if running?
18
18
 
@@ -51,12 +51,5 @@ module Riddle
51
51
  rescue
52
52
  false
53
53
  end
54
-
55
- private
56
- def run_index(name)
57
- cmd = "indexer --config #{@path} #{name}"
58
- cmd << " --rotate" if running?
59
- `#{cmd}`
60
- end
61
54
  end
62
- end
55
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moneypools-thinking-sphinx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.13
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-30 00:00:00 -05:00
12
+ date: 2009-11-04 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -34,6 +34,9 @@ files:
34
34
  - LICENCE
35
35
  - README.textile
36
36
  - VERSION.yml
37
+ - lib/cucumber/thinking_sphinx/external_world.rb
38
+ - lib/cucumber/thinking_sphinx/internal_world.rb
39
+ - lib/cucumber/thinking_sphinx/sql_logger.rb
37
40
  - lib/thinking_sphinx.rb
38
41
  - lib/thinking_sphinx/active_record.rb
39
42
  - lib/thinking_sphinx/active_record/attribute_updates.rb
@@ -50,12 +53,7 @@ files:
50
53
  - lib/thinking_sphinx/core/array.rb
51
54
  - lib/thinking_sphinx/core/string.rb
52
55
  - lib/thinking_sphinx/deltas.rb
53
- - lib/thinking_sphinx/deltas/datetime_delta.rb
54
56
  - lib/thinking_sphinx/deltas/default_delta.rb
55
- - lib/thinking_sphinx/deltas/delayed_delta.rb
56
- - lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb
57
- - lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb
58
- - lib/thinking_sphinx/deltas/delayed_delta/job.rb
59
57
  - lib/thinking_sphinx/deploy/capistrano.rb
60
58
  - lib/thinking_sphinx/excerpter.rb
61
59
  - lib/thinking_sphinx/facet.rb
@@ -105,21 +103,8 @@ homepage: http://ts.freelancing-gods.com
105
103
  licenses: []
106
104
 
107
105
  post_install_message: |+
108
- With the release of Thinking Sphinx 1.1.18, there is one important change to
109
- note: previously, the default morphology for indexing was 'stem_en'. The new
110
- default is nil, to avoid any unexpected behavior. If you wish to keep the old
111
- value though, you will need to add the following settings to your
112
- config/sphinx.yml file:
113
-
114
- development:
115
- morphology: stem_en
116
- test:
117
- morphology: stem_en
118
- production:
119
- morphology: stem_en
120
-
121
- To understand morphologies/stemmers better, visit the following link:
122
- http://www.sphinxsearch.com/docs/manual-0.9.8.html#conf-morphology
106
+ If you're upgrading, you should read this:
107
+ http://freelancing-god.github.com/ts/en/upgrading.html
123
108
 
124
109
  rdoc_options:
125
110
  - --charset=UTF-8
@@ -145,12 +130,9 @@ signing_key:
145
130
  specification_version: 3
146
131
  summary: ActiveRecord/Rails Sphinx library
147
132
  test_files:
148
- - features/a.rb
149
133
  - features/alternate_primary_key.feature
150
134
  - features/attribute_transformation.feature
151
135
  - features/attribute_updates.feature
152
- - features/datetime_deltas.feature
153
- - features/delayed_delta_indexing.feature
154
136
  - features/deleting_instances.feature
155
137
  - features/direct_attributes.feature
156
138
  - features/excerpts.feature
@@ -167,8 +149,6 @@ test_files:
167
149
  - features/step_definitions/alpha_steps.rb
168
150
  - features/step_definitions/beta_steps.rb
169
151
  - features/step_definitions/common_steps.rb
170
- - features/step_definitions/datetime_delta_steps.rb
171
- - features/step_definitions/delayed_delta_indexing_steps.rb
172
152
  - features/step_definitions/extensible_delta_indexing_steps.rb
173
153
  - features/step_definitions/facet_steps.rb
174
154
  - features/step_definitions/find_arguments_steps.rb
@@ -177,8 +157,8 @@ test_files:
177
157
  - features/step_definitions/search_steps.rb
178
158
  - features/step_definitions/sphinx_steps.rb
179
159
  - features/sti_searching.feature
160
+ - features/support/database.example.yml
180
161
  - features/support/db/active_record.rb
181
- - features/support/db/database.example.yml
182
162
  - features/support/db/fixtures/alphas.rb
183
163
  - features/support/db/fixtures/authors.rb
184
164
  - features/support/db/fixtures/betas.rb
@@ -186,7 +166,6 @@ test_files:
186
166
  - features/support/db/fixtures/categories.rb
187
167
  - features/support/db/fixtures/cats.rb
188
168
  - features/support/db/fixtures/comments.rb
189
- - features/support/db/fixtures/delayed_betas.rb
190
169
  - features/support/db/fixtures/developers.rb
191
170
  - features/support/db/fixtures/dogs.rb
192
171
  - features/support/db/fixtures/extensible_betas.rb
@@ -195,7 +174,6 @@ test_files:
195
174
  - features/support/db/fixtures/posts.rb
196
175
  - features/support/db/fixtures/robots.rb
197
176
  - features/support/db/fixtures/tags.rb
198
- - features/support/db/fixtures/thetas.rb
199
177
  - features/support/db/migrations/create_alphas.rb
200
178
  - features/support/db/migrations/create_animals.rb
201
179
  - features/support/db/migrations/create_authors.rb
@@ -204,7 +182,6 @@ test_files:
204
182
  - features/support/db/migrations/create_boxes.rb
205
183
  - features/support/db/migrations/create_categories.rb
206
184
  - features/support/db/migrations/create_comments.rb
207
- - features/support/db/migrations/create_delayed_betas.rb
208
185
  - features/support/db/migrations/create_developers.rb
209
186
  - features/support/db/migrations/create_extensible_betas.rb
210
187
  - features/support/db/migrations/create_gammas.rb
@@ -213,7 +190,6 @@ test_files:
213
190
  - features/support/db/migrations/create_robots.rb
214
191
  - features/support/db/migrations/create_taggings.rb
215
192
  - features/support/db/migrations/create_tags.rb
216
- - features/support/db/migrations/create_thetas.rb
217
193
  - features/support/db/mysql.rb
218
194
  - features/support/db/postgresql.rb
219
195
  - features/support/env.rb
@@ -226,7 +202,6 @@ test_files:
226
202
  - features/support/models/cat.rb
227
203
  - features/support/models/category.rb
228
204
  - features/support/models/comment.rb
229
- - features/support/models/delayed_beta.rb
230
205
  - features/support/models/developer.rb
231
206
  - features/support/models/dog.rb
232
207
  - features/support/models/extensible_beta.rb
@@ -236,9 +211,7 @@ test_files:
236
211
  - features/support/models/robot.rb
237
212
  - features/support/models/tag.rb
238
213
  - features/support/models/tagging.rb
239
- - features/support/models/theta.rb
240
214
  - features/support/post_database.rb
241
- - features/support/z.rb
242
215
  - spec/lib/thinking_sphinx/active_record/delta_spec.rb
243
216
  - spec/lib/thinking_sphinx/active_record/has_many_association_spec.rb
244
217
  - spec/lib/thinking_sphinx/active_record/scopes_spec.rb
@@ -248,7 +221,6 @@ test_files:
248
221
  - spec/lib/thinking_sphinx/configuration_spec.rb
249
222
  - spec/lib/thinking_sphinx/core/array_spec.rb
250
223
  - spec/lib/thinking_sphinx/core/string_spec.rb
251
- - spec/lib/thinking_sphinx/deltas/job_spec.rb
252
224
  - spec/lib/thinking_sphinx/excerpter_spec.rb
253
225
  - spec/lib/thinking_sphinx/facet_search_spec.rb
254
226
  - spec/lib/thinking_sphinx/facet_spec.rb
@@ -1,17 +0,0 @@
1
- # This file exists because Cucumber likes to auto-load all ruby files
2
- puts <<-MESSAGE
3
- Cucumber 0.1.12 defaults to loading all ruby files within the features folder
4
- alphabetically. This is annoying, because some files need to be loaded before
5
- others (and others perhaps not at all, given missing dependencies). Hence this
6
- place-holder imaginatively named 'a.rb', to force this message.
7
-
8
- A work-around is to use cucumber profiles. You will find the default profile in
9
- cucumber.yml should serve your needs fine, unless you add new step definitions.
10
- When you do that, you can regenerate the YAML file by running:
11
- rake cucumber_defaults
12
-
13
- And then run specific features as follows is slightly more verbose, but it
14
- works, whereas this doesn't.
15
- cucumber -p default features/something.feature
16
- MESSAGE
17
- exit 0
@@ -1,66 +0,0 @@
1
- Feature: Datetime Delta Indexing
2
- In order to have delta indexing on frequently-updated sites
3
- Developers
4
- Should be able to use an existing datetime column to track changes
5
-
6
- Scenario: Delta Index should not fire automatically
7
- Given Sphinx is running
8
- And I am searching on thetas
9
- When I search for one
10
- Then I should get 1 result
11
-
12
- When I change the name of theta one to eleven
13
- And I wait for Sphinx to catch up
14
- And I search for one
15
- Then I should get 1 result
16
-
17
- When I search for eleven
18
- Then I should get 0 results
19
-
20
- Scenario: Delta Index should fire when jobs are run
21
- Given Sphinx is running
22
- And I am searching on thetas
23
- When I search for two
24
- Then I should get 1 result
25
-
26
- When I change the name of theta two to twelve
27
- And I wait for Sphinx to catch up
28
- And I search for twelve
29
- Then I should get 0 results
30
-
31
- When I index the theta datetime delta
32
- And I wait for Sphinx to catch up
33
- And I search for twelve
34
- Then I should get 1 result
35
-
36
- When I search for two
37
- Then I should get 0 results
38
-
39
- Scenario: New records should be merged into the core index
40
- Given Sphinx is running
41
- And I am searching on thetas
42
- When I search for thirteen
43
- Then I should get 0 results
44
-
45
- When I create a new theta named thirteen
46
- And I search for thirteen
47
- Then I should get 0 results
48
-
49
- When I index the theta datetime delta
50
- And I wait for Sphinx to catch up
51
- And I search for thirteen
52
- Then I should get 1 result
53
-
54
- When I search for the document id of theta thirteen in the theta_core index
55
- Then it should exist
56
-
57
- Scenario: Deleting records
58
- Given Sphinx is running
59
- And I am searching on thetas
60
- When I search for three
61
- Then I should get 1 result
62
-
63
- When I delete the theta named three
64
- And I wait for Sphinx to catch up
65
- And I search for three
66
- Then I should get 0 results
@@ -1,37 +0,0 @@
1
- Feature: Delayed Delta Indexing
2
- In order to have delta indexing on frequently-updated sites
3
- Developers
4
- Should be able to use delayed_job to handle delta indexes to lower system load
5
-
6
- Scenario: Delta Index should not fire automatically
7
- Given Sphinx is running
8
- And I am searching on delayed betas
9
- When I search for one
10
- Then I should get 1 result
11
-
12
- When I change the name of delayed beta one to eleven
13
- And I wait for Sphinx to catch up
14
- And I search for one
15
- Then I should get 1 result
16
-
17
- When I search for eleven
18
- Then I should get 0 results
19
-
20
- Scenario: Delta Index should fire when jobs are run
21
- Given Sphinx is running
22
- And I am searching on delayed betas
23
- When I search for one
24
- Then I should get 1 result
25
-
26
- When I change the name of delayed beta two to twelve
27
- And I wait for Sphinx to catch up
28
- And I search for twelve
29
- Then I should get 0 results
30
-
31
- When I run the delayed jobs
32
- And I wait for Sphinx to catch up
33
- And I search for twelve
34
- Then I should get 1 result
35
-
36
- When I search for two
37
- Then I should get 0 results
@@ -1,15 +0,0 @@
1
- When /^I index the theta datetime delta$/ do
2
- Theta.sphinx_indexes.first.delta_object.delayed_index(Theta)
3
- end
4
-
5
- When /^I change the name of theta (\w+) to (\w+)$/ do |current, replacement|
6
- Theta.find_by_name(current).update_attributes(:name => replacement)
7
- end
8
-
9
- When /^I create a new theta named (\w+)$/ do |name|
10
- Theta.create(:name => name)
11
- end
12
-
13
- When /^I delete the theta named (\w+)$/ do |name|
14
- Theta.find_by_name(name).destroy
15
- end
@@ -1,7 +0,0 @@
1
- When /^I run the delayed jobs$/ do
2
- Delayed::Job.work_off.inspect
3
- end
4
-
5
- When /^I change the name of delayed beta (\w+) to (\w+)$/ do |current, replacement|
6
- DelayedBeta.find_by_name(current).update_attributes(:name => replacement)
7
- end
@@ -1,10 +0,0 @@
1
- DelayedBeta.create :name => "one"
2
- DelayedBeta.create :name => "two"
3
- DelayedBeta.create :name => "three"
4
- DelayedBeta.create :name => "four"
5
- DelayedBeta.create :name => "five"
6
- DelayedBeta.create :name => "six"
7
- DelayedBeta.create :name => "seven"
8
- DelayedBeta.create :name => "eight"
9
- DelayedBeta.create :name => "nine"
10
- DelayedBeta.create :name => "ten"
@@ -1,10 +0,0 @@
1
- Theta.create :name => "one"
2
- Theta.create :name => "two"
3
- Theta.create :name => "three"
4
- Theta.create :name => "four"
5
- Theta.create :name => "five"
6
- Theta.create :name => "six"
7
- Theta.create :name => "seven"
8
- Theta.create :name => "eight"
9
- Theta.create :name => "nine"
10
- Theta.create :name => "ten"
@@ -1,17 +0,0 @@
1
- ActiveRecord::Base.connection.create_table :delayed_betas, :force => true do |t|
2
- t.column :name, :string, :null => false
3
- t.column :delta, :boolean, :null => false, :default => false
4
- end
5
-
6
- ActiveRecord::Base.connection.create_table :delayed_jobs, :force => true do |t|
7
- t.column :priority, :integer, :default => 0
8
- t.column :attempts, :integer, :default => 0
9
- t.column :handler, :text
10
- t.column :last_error, :string
11
- t.column :run_at, :datetime
12
- t.column :locked_at, :datetime
13
- t.column :failed_at, :datetime
14
- t.column :locked_by, :string
15
- t.column :created_at, :datetime
16
- t.column :updated_at, :datetime
17
- end
@@ -1,5 +0,0 @@
1
- ActiveRecord::Base.connection.create_table :thetas, :force => true do |t|
2
- t.column :name, :string, :null => false
3
- t.column :created_at, :datetime, :null => false
4
- t.column :updated_at, :datetime, :null => false
5
- end
@@ -1,7 +0,0 @@
1
- class DelayedBeta < ActiveRecord::Base
2
- define_index do
3
- indexes :name, :sortable => true
4
-
5
- set_property :delta => :delayed
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- class Theta < ActiveRecord::Base
2
- define_index do
3
- indexes :name, :sortable => true
4
-
5
- set_property :delta => :datetime, :threshold => 1.hour
6
- end
7
- end
@@ -1,19 +0,0 @@
1
- # This file exists because Cucumber likes to auto-load all ruby files
2
- puts <<-MESSAGE
3
- Cucumber 0.1.13 defaults to loading all ruby files within the features folder,
4
- with something approaching reverse-alphabetical order, and preferring the
5
- features/support folder over everything else. This is annoying, because some
6
- files need to be loaded before others (and others perhaps not at all, given
7
- missing dependencies). Hence this place-holder imaginatively named 'z.rb', to
8
- force this message.
9
-
10
- A work-around is to use cucumber profiles. You will find the default profile in
11
- cucumber.yml should serve your needs fine, unless you add new step definitions.
12
- When you do that, you can regenerate the YAML file by running:
13
- rake cucumber_defaults
14
-
15
- And then run specific features as follows is slightly more verbose, but it
16
- works, whereas this doesn't.
17
- cucumber -p default features/something.feature
18
- MESSAGE
19
- exit 0
@@ -1,50 +0,0 @@
1
- module ThinkingSphinx
2
- module Deltas
3
- class DatetimeDelta < ThinkingSphinx::Deltas::DefaultDelta
4
- attr_accessor :column, :threshold
5
-
6
- def initialize(index, options)
7
- @index = index
8
- @column = options.delete(:delta_column) || :updated_at
9
- @threshold = options.delete(:threshold) || 1.day
10
- end
11
-
12
- def index(model, instance = nil)
13
- # do nothing
14
- true
15
- end
16
-
17
- def delayed_index(model)
18
- config = ThinkingSphinx::Configuration.instance
19
- rotate = ThinkingSphinx.sphinx_running? ? "--rotate" : ""
20
-
21
- output = `#{config.bin_path}#{config.indexer_binary_name} --config #{config.config_file} #{rotate} #{delta_index_name model}`
22
- output += `#{config.bin_path}#{config.indexer_binary_name} --config #{config.config_file} #{rotate} --merge #{core_index_name model} #{delta_index_name model} --merge-dst-range sphinx_deleted 0 0`
23
- puts output unless ThinkingSphinx.suppress_delta_output?
24
-
25
- true
26
- end
27
-
28
- def toggle(instance)
29
- # do nothing
30
- end
31
-
32
- def toggled(instance)
33
- instance.send(@column) > @threshold.ago
34
- end
35
-
36
- def reset_query(model)
37
- nil
38
- end
39
-
40
- def clause(model, toggled)
41
- if toggled
42
- "#{model.quoted_table_name}.#{model.connection.quote_column_name(@column.to_s)}" +
43
- " > #{adapter.time_difference(@threshold)}"
44
- else
45
- nil
46
- end
47
- end
48
- end
49
- end
50
- end
@@ -1,34 +0,0 @@
1
- begin
2
- require 'delayed_job'
3
- rescue LoadError
4
- raise "You must have delayed_job installed as a gem or plugin to use a delayed delta"
5
- end
6
-
7
- require 'thinking_sphinx/deltas/delayed_delta/delta_job'
8
- require 'thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job'
9
- require 'thinking_sphinx/deltas/delayed_delta/job'
10
-
11
- module ThinkingSphinx
12
- module Deltas
13
- class DelayedDelta < ThinkingSphinx::Deltas::DefaultDelta
14
- def index(model, instance = nil)
15
- return true unless ThinkingSphinx.updates_enabled? && ThinkingSphinx.deltas_enabled?
16
- return true if instance && !toggled(instance)
17
-
18
- ThinkingSphinx::Deltas::Job.enqueue(
19
- ThinkingSphinx::Deltas::DeltaJob.new(delta_index_name(model)),
20
- ThinkingSphinx::Configuration.instance.delayed_job_priority
21
- )
22
-
23
- Delayed::Job.enqueue(
24
- ThinkingSphinx::Deltas::FlagAsDeletedJob.new(
25
- core_index_name(model), instance.sphinx_document_id
26
- ),
27
- ThinkingSphinx::Configuration.instance.delayed_job_priority
28
- ) if instance
29
-
30
- true
31
- end
32
- end
33
- end
34
- end
@@ -1,24 +0,0 @@
1
- module ThinkingSphinx
2
- module Deltas
3
- class DeltaJob
4
- attr_accessor :index
5
-
6
- def initialize(index)
7
- @index = index
8
- end
9
-
10
- def perform
11
- return true unless ThinkingSphinx.updates_enabled? &&
12
- ThinkingSphinx.deltas_enabled?
13
-
14
- config = ThinkingSphinx::Configuration.instance
15
- client = Riddle::Client.new config.address, config.port
16
-
17
- output = `#{config.bin_path}#{config.indexer_binary_name} --config #{config.config_file} --rotate #{index}`
18
- puts output unless ThinkingSphinx.suppress_delta_output?
19
-
20
- true
21
- end
22
- end
23
- end
24
- end
@@ -1,27 +0,0 @@
1
- module ThinkingSphinx
2
- module Deltas
3
- class FlagAsDeletedJob
4
- attr_accessor :index, :document_id
5
-
6
- def initialize(index, document_id)
7
- @index, @document_id = index, document_id
8
- end
9
-
10
- def perform
11
- return true unless ThinkingSphinx.updates_enabled?
12
-
13
- config = ThinkingSphinx::Configuration.instance
14
- client = Riddle::Client.new config.address, config.port
15
-
16
- client.update(
17
- @index,
18
- ['sphinx_deleted'],
19
- {@document_id => [1]}
20
- ) if ThinkingSphinx.sphinx_running? &&
21
- ThinkingSphinx::Search.search_for_id(@document_id, @index)
22
-
23
- true
24
- end
25
- end
26
- end
27
- end
@@ -1,26 +0,0 @@
1
- module ThinkingSphinx
2
- module Deltas
3
- class Job < Delayed::Job
4
- def self.enqueue(object, priority = 0)
5
- super unless duplicates_exist(object)
6
- end
7
-
8
- def self.cancel_thinking_sphinx_jobs
9
- if connection.tables.include?("delayed_jobs")
10
- delete_all("handler LIKE '--- !ruby/object:ThinkingSphinx::Deltas::%'")
11
- end
12
- end
13
-
14
- private
15
-
16
- def self.duplicates_exist(object)
17
- count(
18
- :conditions => {
19
- :handler => object.to_yaml,
20
- :locked_at => nil
21
- }
22
- ) > 0
23
- end
24
- end
25
- end
26
- end
@@ -1,32 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe ThinkingSphinx::Deltas::Job do
4
- describe '.cancel_thinking_sphinx_jobs' do
5
- before :each do
6
- ThinkingSphinx::Deltas::Job.stub!(:delete_all => true)
7
- end
8
-
9
- it "should not delete any rows if the delayed_jobs table does not exist" do
10
- ThinkingSphinx::Deltas::Job.connection.stub!(:tables => [])
11
- ThinkingSphinx::Deltas::Job.should_not_receive(:delete_all)
12
-
13
- ThinkingSphinx::Deltas::Job.cancel_thinking_sphinx_jobs
14
- end
15
-
16
- it "should delete rows if the delayed_jobs table does exist" do
17
- ThinkingSphinx::Deltas::Job.connection.stub!(:tables => ['delayed_jobs'])
18
- ThinkingSphinx::Deltas::Job.should_receive(:delete_all)
19
-
20
- ThinkingSphinx::Deltas::Job.cancel_thinking_sphinx_jobs
21
- end
22
-
23
- it "should delete only Thinking Sphinx jobs" do
24
- ThinkingSphinx::Deltas::Job.connection.stub!(:tables => ['delayed_jobs'])
25
- ThinkingSphinx::Deltas::Job.should_receive(:delete_all) do |sql|
26
- sql.should match(/handler LIKE '--- !ruby\/object:ThinkingSphinx::Deltas::\%'/)
27
- end
28
-
29
- ThinkingSphinx::Deltas::Job.cancel_thinking_sphinx_jobs
30
- end
31
- end
32
- end