thinking-sphinx 3.1.4 → 6.0.0
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.
- checksums.yaml +5 -5
- data/.circleci/config.yml +99 -0
- data/.github/actions/test/action.yml +46 -0
- data/.github/workflows/ci.yml +75 -0
- data/.gitignore +7 -2
- data/.travis.yml +31 -16
- data/Appraisals +68 -12
- data/CHANGELOG.markdown +782 -0
- data/Gemfile +13 -4
- data/Procfile.support +2 -0
- data/README.textile +41 -27
- data/Rakefile +2 -0
- data/bin/console +15 -0
- data/bin/loadsphinx +99 -0
- data/bin/testmatrix +48 -0
- data/lib/thinking/sphinx.rb +2 -0
- data/lib/thinking-sphinx.rb +2 -0
- data/lib/thinking_sphinx/active_record/association.rb +2 -0
- data/lib/thinking_sphinx/active_record/association_proxy/attribute_finder.rb +3 -1
- data/lib/thinking_sphinx/active_record/association_proxy/attribute_matcher.rb +2 -0
- data/lib/thinking_sphinx/active_record/association_proxy.rb +3 -2
- data/lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb +3 -1
- data/lib/thinking_sphinx/active_record/attribute/type.rb +20 -4
- data/lib/thinking_sphinx/active_record/attribute/values.rb +2 -0
- data/lib/thinking_sphinx/active_record/attribute.rb +2 -0
- data/lib/thinking_sphinx/active_record/base.rb +43 -11
- data/lib/thinking_sphinx/active_record/callbacks/association_delta_callbacks.rb +21 -0
- data/lib/thinking_sphinx/active_record/callbacks/delete_callbacks.rb +15 -9
- data/lib/thinking_sphinx/active_record/callbacks/delta_callbacks.rb +20 -5
- data/lib/thinking_sphinx/active_record/callbacks/update_callbacks.rb +18 -4
- data/lib/thinking_sphinx/active_record/column.rb +2 -0
- data/lib/thinking_sphinx/active_record/column_sql_presenter.rb +7 -1
- data/lib/thinking_sphinx/active_record/database_adapters/abstract_adapter.rb +2 -0
- data/lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb +9 -1
- data/lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb +2 -0
- data/lib/thinking_sphinx/active_record/database_adapters.rb +3 -1
- data/lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb +32 -0
- data/lib/thinking_sphinx/active_record/depolymorph/base_reflection.rb +32 -0
- data/lib/thinking_sphinx/active_record/depolymorph/conditions_reflection.rb +40 -0
- data/lib/thinking_sphinx/active_record/depolymorph/overridden_reflection.rb +50 -0
- data/lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb +26 -0
- data/lib/thinking_sphinx/active_record/field.rb +2 -0
- data/lib/thinking_sphinx/active_record/filter_reflection.rb +13 -71
- data/lib/thinking_sphinx/active_record/index.rb +7 -5
- data/lib/thinking_sphinx/active_record/interpreter.rb +6 -4
- data/lib/thinking_sphinx/active_record/join_association.rb +5 -1
- data/lib/thinking_sphinx/active_record/log_subscriber.rb +22 -3
- data/lib/thinking_sphinx/active_record/polymorpher.rb +2 -0
- data/lib/thinking_sphinx/active_record/property.rb +2 -0
- data/lib/thinking_sphinx/active_record/property_query.rb +4 -1
- data/lib/thinking_sphinx/active_record/property_sql_presenter.rb +2 -0
- data/lib/thinking_sphinx/active_record/simple_many_query.rb +2 -0
- data/lib/thinking_sphinx/active_record/source_joins.rb +68 -0
- data/lib/thinking_sphinx/active_record/sql_builder/clause_builder.rb +2 -0
- data/lib/thinking_sphinx/active_record/sql_builder/query.rb +13 -0
- data/lib/thinking_sphinx/active_record/sql_builder/statement.rb +2 -0
- data/lib/thinking_sphinx/active_record/sql_builder.rb +5 -18
- data/lib/thinking_sphinx/active_record/sql_source/template.rb +5 -3
- data/lib/thinking_sphinx/active_record/sql_source.rb +35 -9
- data/lib/thinking_sphinx/active_record.rb +14 -1
- data/lib/thinking_sphinx/attribute_types.rb +72 -0
- data/lib/thinking_sphinx/batched_search.rb +2 -0
- data/lib/thinking_sphinx/callbacks/appender.rb +63 -0
- data/lib/thinking_sphinx/callbacks.rb +29 -0
- data/lib/thinking_sphinx/capistrano/v2.rb +2 -0
- data/lib/thinking_sphinx/capistrano/v3.rb +2 -0
- data/lib/thinking_sphinx/capistrano.rb +2 -0
- data/lib/thinking_sphinx/commander.rb +27 -0
- data/lib/thinking_sphinx/commands/base.rb +53 -0
- data/lib/thinking_sphinx/commands/clear_real_time.rb +22 -0
- data/lib/thinking_sphinx/commands/clear_sql.rb +18 -0
- data/lib/thinking_sphinx/commands/configure.rb +15 -0
- data/lib/thinking_sphinx/commands/index_real_time.rb +15 -0
- data/lib/thinking_sphinx/commands/index_sql.rb +25 -0
- data/lib/thinking_sphinx/commands/merge.rb +27 -0
- data/lib/thinking_sphinx/commands/merge_and_update.rb +57 -0
- data/lib/thinking_sphinx/commands/prepare.rb +15 -0
- data/lib/thinking_sphinx/commands/rotate.rb +13 -0
- data/lib/thinking_sphinx/commands/running.rb +15 -0
- data/lib/thinking_sphinx/commands/start_attached.rb +22 -0
- data/lib/thinking_sphinx/commands/start_detached.rb +21 -0
- data/lib/thinking_sphinx/commands/stop.rb +24 -0
- data/lib/thinking_sphinx/commands.rb +20 -0
- data/lib/thinking_sphinx/configuration/consistent_ids.rb +2 -0
- data/lib/thinking_sphinx/configuration/defaults.rb +2 -0
- data/lib/thinking_sphinx/configuration/distributed_indices.rb +3 -1
- data/lib/thinking_sphinx/configuration/duplicate_names.rb +36 -0
- data/lib/thinking_sphinx/configuration/minimum_fields.rb +17 -12
- data/lib/thinking_sphinx/configuration.rb +90 -74
- data/lib/thinking_sphinx/connection/client.rb +74 -0
- data/lib/thinking_sphinx/connection/jruby.rb +58 -0
- data/lib/thinking_sphinx/connection/mri.rb +26 -0
- data/lib/thinking_sphinx/connection.rb +13 -114
- data/lib/thinking_sphinx/core/field.rb +2 -0
- data/lib/thinking_sphinx/core/index.rb +22 -2
- data/lib/thinking_sphinx/core/interpreter.rb +2 -0
- data/lib/thinking_sphinx/core/property.rb +2 -0
- data/lib/thinking_sphinx/core/settings.rb +2 -0
- data/lib/thinking_sphinx/core.rb +2 -0
- data/lib/thinking_sphinx/deletion.rb +33 -13
- data/lib/thinking_sphinx/deltas/default_delta.rb +3 -1
- data/lib/thinking_sphinx/deltas/delete_job.rb +16 -4
- data/lib/thinking_sphinx/deltas/index_job.rb +14 -2
- data/lib/thinking_sphinx/deltas.rb +2 -0
- data/lib/thinking_sphinx/distributed/index.rb +25 -3
- data/lib/thinking_sphinx/distributed.rb +2 -0
- data/lib/thinking_sphinx/errors.rb +47 -3
- data/lib/thinking_sphinx/excerpter.rb +2 -0
- data/lib/thinking_sphinx/facet.rb +4 -3
- data/lib/thinking_sphinx/facet_search.rb +4 -2
- data/lib/thinking_sphinx/float_formatter.rb +2 -0
- data/lib/thinking_sphinx/frameworks/plain.rb +2 -0
- data/lib/thinking_sphinx/frameworks/rails.rb +2 -0
- data/lib/thinking_sphinx/frameworks.rb +2 -0
- data/lib/thinking_sphinx/guard/file.rb +3 -1
- data/lib/thinking_sphinx/guard/files.rb +2 -0
- data/lib/thinking_sphinx/guard/none.rb +7 -0
- data/lib/thinking_sphinx/guard.rb +3 -0
- data/lib/thinking_sphinx/hooks/guard_presence.rb +34 -0
- data/lib/thinking_sphinx/index.rb +2 -0
- data/lib/thinking_sphinx/index_set.rb +27 -4
- data/lib/thinking_sphinx/indexing_strategies/all_at_once.rb +9 -0
- data/lib/thinking_sphinx/indexing_strategies/one_at_a_time.rb +16 -0
- data/lib/thinking_sphinx/interfaces/base.rb +13 -0
- data/lib/thinking_sphinx/interfaces/daemon.rb +27 -0
- data/lib/thinking_sphinx/interfaces/real_time.rb +46 -0
- data/lib/thinking_sphinx/interfaces/sql.rb +53 -0
- data/lib/thinking_sphinx/interfaces.rb +10 -0
- data/lib/thinking_sphinx/logger.rb +2 -0
- data/lib/thinking_sphinx/masks/group_enumerators_mask.rb +6 -4
- data/lib/thinking_sphinx/masks/pagination_mask.rb +2 -0
- data/lib/thinking_sphinx/masks/scopes_mask.rb +8 -0
- data/lib/thinking_sphinx/masks/weight_enumerator_mask.rb +3 -1
- data/lib/thinking_sphinx/masks.rb +2 -0
- data/lib/thinking_sphinx/middlewares/active_record_translator.rb +32 -9
- data/lib/thinking_sphinx/middlewares/geographer.rb +2 -0
- data/lib/thinking_sphinx/middlewares/glazier.rb +14 -1
- data/lib/thinking_sphinx/middlewares/ids_only.rb +2 -0
- data/lib/thinking_sphinx/middlewares/inquirer.rb +3 -1
- data/lib/thinking_sphinx/middlewares/middleware.rb +2 -0
- data/lib/thinking_sphinx/middlewares/sphinxql.rb +18 -16
- data/lib/thinking_sphinx/middlewares/stale_id_checker.rb +3 -1
- data/lib/thinking_sphinx/middlewares/stale_id_filter.rb +4 -2
- data/lib/thinking_sphinx/middlewares/valid_options.rb +25 -0
- data/lib/thinking_sphinx/middlewares.rb +7 -3
- data/lib/thinking_sphinx/panes/attributes_pane.rb +2 -0
- data/lib/thinking_sphinx/panes/distance_pane.rb +2 -0
- data/lib/thinking_sphinx/panes/excerpts_pane.rb +2 -0
- data/lib/thinking_sphinx/panes/weight_pane.rb +3 -1
- data/lib/thinking_sphinx/panes.rb +2 -0
- data/lib/thinking_sphinx/processor.rb +71 -0
- data/lib/thinking_sphinx/query.rb +2 -0
- data/lib/thinking_sphinx/railtie.rb +29 -2
- data/lib/thinking_sphinx/rake_interface.rb +14 -69
- data/lib/thinking_sphinx/real_time/attribute.rb +9 -1
- data/lib/thinking_sphinx/real_time/callbacks/real_time_callbacks.rb +17 -7
- data/lib/thinking_sphinx/real_time/field.rb +2 -0
- data/lib/thinking_sphinx/real_time/index/template.rb +19 -1
- data/lib/thinking_sphinx/real_time/index.rb +11 -5
- data/lib/thinking_sphinx/real_time/interpreter.rb +10 -6
- data/lib/thinking_sphinx/real_time/populator.rb +12 -14
- data/lib/thinking_sphinx/real_time/processor.rb +36 -0
- data/lib/thinking_sphinx/real_time/property.rb +3 -5
- data/lib/thinking_sphinx/real_time/transcribe_instance.rb +38 -0
- data/lib/thinking_sphinx/real_time/transcriber.rb +63 -15
- data/lib/thinking_sphinx/real_time/translator.rb +39 -0
- data/lib/thinking_sphinx/real_time.rb +22 -1
- data/lib/thinking_sphinx/scopes.rb +6 -0
- data/lib/thinking_sphinx/search/batch_inquirer.rb +2 -0
- data/lib/thinking_sphinx/search/context.rb +11 -0
- data/lib/thinking_sphinx/search/glaze.rb +2 -0
- data/lib/thinking_sphinx/search/merger.rb +2 -0
- data/lib/thinking_sphinx/search/query.rb +9 -1
- data/lib/thinking_sphinx/search/stale_ids_exception.rb +7 -3
- data/lib/thinking_sphinx/search.rb +30 -2
- data/lib/thinking_sphinx/settings.rb +128 -0
- data/lib/thinking_sphinx/sinatra.rb +3 -1
- data/lib/thinking_sphinx/subscribers/populator_subscriber.rb +19 -5
- data/lib/thinking_sphinx/tasks.rb +55 -28
- data/lib/thinking_sphinx/test.rb +3 -1
- data/lib/thinking_sphinx/utf8.rb +2 -0
- data/lib/thinking_sphinx/wildcard.rb +3 -1
- data/lib/thinking_sphinx/with_output.rb +13 -0
- data/lib/thinking_sphinx.rb +35 -4
- data/spec/acceptance/association_scoping_spec.rb +7 -5
- data/spec/acceptance/attribute_access_spec.rb +29 -12
- data/spec/acceptance/attribute_updates_spec.rb +5 -3
- data/spec/acceptance/batch_searching_spec.rb +6 -4
- data/spec/acceptance/big_integers_spec.rb +9 -7
- data/spec/acceptance/excerpts_spec.rb +11 -10
- data/spec/acceptance/facets_spec.rb +29 -16
- data/spec/acceptance/geosearching_spec.rb +22 -10
- data/spec/acceptance/grouping_by_attributes_spec.rb +30 -28
- data/spec/acceptance/index_options_spec.rb +18 -16
- data/spec/acceptance/indexing_spec.rb +5 -3
- data/spec/acceptance/merging_spec.rb +90 -0
- data/spec/acceptance/paginating_search_results_spec.rb +21 -3
- data/spec/acceptance/real_time_updates_spec.rb +103 -5
- data/spec/acceptance/remove_deleted_records_spec.rb +64 -8
- data/spec/acceptance/search_counts_spec.rb +4 -2
- data/spec/acceptance/search_for_just_ids_spec.rb +4 -2
- data/spec/acceptance/searching_across_models_spec.rb +15 -6
- data/spec/acceptance/searching_across_schemas_spec.rb +12 -10
- data/spec/acceptance/searching_on_fields_spec.rb +11 -9
- data/spec/acceptance/searching_with_filters_spec.rb +35 -20
- data/spec/acceptance/searching_with_sti_spec.rb +11 -9
- data/spec/acceptance/searching_within_a_model_spec.rb +44 -17
- data/spec/acceptance/sorting_search_results_spec.rb +21 -19
- data/spec/acceptance/spec_helper.rb +2 -13
- data/spec/acceptance/specifying_sql_spec.rb +118 -62
- data/spec/acceptance/sphinx_scopes_spec.rb +30 -21
- data/spec/acceptance/sql_deltas_spec.rb +35 -9
- data/spec/acceptance/support/database_cleaner.rb +3 -1
- data/spec/acceptance/support/sphinx_controller.rb +25 -9
- data/spec/acceptance/support/sphinx_helpers.rb +17 -2
- data/spec/acceptance/suspended_deltas_spec.rb +14 -12
- data/spec/fixtures/database.yml +1 -1
- data/spec/internal/app/indices/admin_person_index.rb +6 -0
- data/spec/internal/app/indices/album_index.rb +9 -0
- data/spec/internal/app/indices/animal_index.rb +2 -0
- data/spec/internal/app/indices/article_index.rb +10 -3
- data/spec/internal/app/indices/bird_index.rb +2 -0
- data/spec/internal/app/indices/book_index.rb +4 -1
- data/spec/internal/app/indices/car_index.rb +2 -0
- data/spec/internal/app/indices/city_index.rb +2 -0
- data/spec/internal/app/indices/colour_index.rb +7 -0
- data/spec/internal/app/indices/product_index.rb +3 -2
- data/spec/internal/app/indices/tee_index.rb +3 -1
- data/spec/internal/app/indices/user_index.rb +2 -0
- data/spec/internal/app/models/admin/person.rb +6 -0
- data/spec/internal/app/models/album.rb +25 -0
- data/spec/internal/app/models/animal.rb +3 -0
- data/spec/internal/app/models/article.rb +4 -0
- data/spec/internal/app/models/bird.rb +3 -0
- data/spec/internal/app/models/book.rb +9 -5
- data/spec/internal/app/models/car.rb +3 -1
- data/spec/internal/app/models/categorisation.rb +10 -1
- data/spec/internal/app/models/category.rb +2 -0
- data/spec/internal/app/models/city.rb +4 -0
- data/spec/internal/app/models/colour.rb +4 -0
- data/spec/internal/app/models/event.rb +2 -0
- data/spec/internal/app/models/flightless_bird.rb +2 -0
- data/spec/internal/app/models/genre.rb +2 -0
- data/spec/internal/app/models/hardcover.rb +2 -0
- data/spec/internal/app/models/mammal.rb +2 -0
- data/spec/internal/app/models/manufacturer.rb +2 -0
- data/spec/internal/app/models/product.rb +3 -1
- data/spec/internal/app/models/tag.rb +2 -0
- data/spec/internal/app/models/tagging.rb +2 -0
- data/spec/internal/app/models/tee.rb +7 -0
- data/spec/internal/app/models/tweet.rb +2 -0
- data/spec/internal/app/models/user.rb +4 -0
- data/spec/internal/config/database.yml +12 -1
- data/spec/internal/db/schema.rb +13 -1
- data/spec/spec_helper.rb +12 -1
- data/spec/support/json_column.rb +35 -0
- data/spec/support/multi_schema.rb +5 -1
- data/spec/support/mysql.rb +25 -0
- data/spec/support/sphinx_yaml_helpers.rb +8 -1
- data/spec/thinking_sphinx/active_record/association_spec.rb +3 -1
- data/spec/thinking_sphinx/active_record/attribute/type_spec.rb +43 -38
- data/spec/thinking_sphinx/active_record/base_spec.rb +31 -29
- data/spec/thinking_sphinx/active_record/callbacks/delete_callbacks_spec.rb +81 -10
- data/spec/thinking_sphinx/active_record/callbacks/delta_callbacks_spec.rb +56 -29
- data/spec/thinking_sphinx/active_record/callbacks/update_callbacks_spec.rb +27 -10
- data/spec/thinking_sphinx/active_record/column_spec.rb +15 -13
- data/spec/thinking_sphinx/active_record/column_sql_presenter_spec.rb +39 -0
- data/spec/thinking_sphinx/active_record/database_adapters/abstract_adapter_spec.rb +7 -5
- data/spec/thinking_sphinx/active_record/database_adapters/mysql_adapter_spec.rb +26 -12
- data/spec/thinking_sphinx/active_record/database_adapters/postgresql_adapter_spec.rb +15 -13
- data/spec/thinking_sphinx/active_record/database_adapters_spec.rb +50 -48
- data/spec/thinking_sphinx/active_record/field_spec.rb +9 -7
- data/spec/thinking_sphinx/active_record/filter_reflection_spec.rb +113 -80
- data/spec/thinking_sphinx/active_record/index_spec.rb +41 -37
- data/spec/thinking_sphinx/active_record/interpreter_spec.rb +62 -59
- data/spec/thinking_sphinx/active_record/polymorpher_spec.rb +16 -14
- data/spec/thinking_sphinx/active_record/property_sql_presenter_spec.rb +69 -67
- data/spec/thinking_sphinx/active_record/sql_builder_spec.rb +146 -154
- data/spec/thinking_sphinx/active_record/sql_source_spec.rb +185 -109
- data/spec/thinking_sphinx/attribute_types_spec.rb +52 -0
- data/spec/thinking_sphinx/commands/clear_real_time_spec.rb +46 -0
- data/spec/thinking_sphinx/commands/clear_sql_spec.rb +52 -0
- data/spec/thinking_sphinx/commands/configure_spec.rb +31 -0
- data/spec/thinking_sphinx/commands/index_real_time_spec.rb +33 -0
- data/spec/thinking_sphinx/commands/index_sql_spec.rb +86 -0
- data/spec/thinking_sphinx/commands/merge_and_update_spec.rb +106 -0
- data/spec/thinking_sphinx/commands/merge_spec.rb +48 -0
- data/spec/thinking_sphinx/commands/prepare_spec.rb +31 -0
- data/spec/thinking_sphinx/commands/running_spec.rb +30 -0
- data/spec/thinking_sphinx/commands/start_detached_spec.rb +67 -0
- data/spec/thinking_sphinx/commands/stop_spec.rb +63 -0
- data/spec/thinking_sphinx/configuration/minimum_fields_spec.rb +60 -0
- data/spec/thinking_sphinx/configuration_spec.rb +247 -94
- data/spec/thinking_sphinx/connection/mri_spec.rb +49 -0
- data/spec/thinking_sphinx/connection_spec.rb +15 -13
- data/spec/thinking_sphinx/deletion_spec.rb +17 -17
- data/spec/thinking_sphinx/deltas/default_delta_spec.rb +28 -21
- data/spec/thinking_sphinx/deltas_spec.rb +14 -12
- data/spec/thinking_sphinx/errors_spec.rb +59 -27
- data/spec/thinking_sphinx/excerpter_spec.rb +12 -9
- data/spec/thinking_sphinx/facet_search_spec.rb +24 -22
- data/spec/thinking_sphinx/hooks/guard_presence_spec.rb +30 -0
- data/spec/thinking_sphinx/index_set_spec.rb +59 -18
- data/spec/thinking_sphinx/index_spec.rb +28 -26
- data/spec/thinking_sphinx/interfaces/daemon_spec.rb +60 -0
- data/spec/thinking_sphinx/interfaces/real_time_spec.rb +109 -0
- data/spec/thinking_sphinx/interfaces/sql_spec.rb +122 -0
- data/spec/thinking_sphinx/masks/pagination_mask_spec.rb +22 -20
- data/spec/thinking_sphinx/masks/scopes_mask_spec.rb +20 -18
- data/spec/thinking_sphinx/middlewares/active_record_translator_spec.rb +45 -21
- data/spec/thinking_sphinx/middlewares/geographer_spec.rb +11 -9
- data/spec/thinking_sphinx/middlewares/glazier_spec.rb +12 -9
- data/spec/thinking_sphinx/middlewares/inquirer_spec.rb +9 -7
- data/spec/thinking_sphinx/middlewares/sphinxql_spec.rb +60 -58
- data/spec/thinking_sphinx/middlewares/stale_id_checker_spec.rb +7 -4
- data/spec/thinking_sphinx/middlewares/stale_id_filter_spec.rb +39 -17
- data/spec/thinking_sphinx/middlewares/valid_options_spec.rb +51 -0
- data/spec/thinking_sphinx/panes/attributes_pane_spec.rb +3 -1
- data/spec/thinking_sphinx/panes/distance_pane_spec.rb +6 -4
- data/spec/thinking_sphinx/panes/excerpts_pane_spec.rb +8 -6
- data/spec/thinking_sphinx/panes/weight_pane_spec.rb +4 -2
- data/spec/thinking_sphinx/rake_interface_spec.rb +17 -235
- data/spec/thinking_sphinx/real_time/attribute_spec.rb +15 -13
- data/spec/thinking_sphinx/real_time/callbacks/real_time_callbacks_spec.rb +114 -28
- data/spec/thinking_sphinx/real_time/field_spec.rb +16 -14
- data/spec/thinking_sphinx/real_time/index_spec.rb +83 -32
- data/spec/thinking_sphinx/real_time/interpreter_spec.rb +44 -42
- data/spec/thinking_sphinx/real_time/transcribe_instance_spec.rb +35 -0
- data/spec/thinking_sphinx/real_time/transcriber_spec.rb +109 -0
- data/spec/thinking_sphinx/real_time/translator_spec.rb +17 -0
- data/spec/thinking_sphinx/scopes_spec.rb +11 -5
- data/spec/thinking_sphinx/search/glaze_spec.rb +17 -15
- data/spec/thinking_sphinx/search/query_spec.rb +19 -10
- data/spec/thinking_sphinx/search_spec.rb +30 -28
- data/spec/thinking_sphinx/wildcard_spec.rb +18 -11
- data/spec/thinking_sphinx_spec.rb +10 -7
- data/thinking-sphinx.gemspec +17 -10
- metadata +157 -49
- data/HISTORY +0 -248
- data/gemfiles/.gitignore +0 -1
- data/gemfiles/rails_3_2.gemfile +0 -11
- data/gemfiles/rails_4_0.gemfile +0 -11
- data/gemfiles/rails_4_1.gemfile +0 -11
- data/gemfiles/rails_4_2.gemfile +0 -11
- data/lib/thinking_sphinx/controller.rb +0 -10
- data/lib/thinking_sphinx/middlewares/utf8.rb +0 -27
- data/lib/thinking_sphinx/sphinxql.rb +0 -23
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe ThinkingSphinx::RealTime::Callbacks::RealTimeCallbacks do
|
|
@@ -9,15 +11,15 @@ describe ThinkingSphinx::RealTime::Callbacks::RealTimeCallbacks do
|
|
|
9
11
|
:settings => {}) }
|
|
10
12
|
let(:index) { double('index', :name => 'my_index', :is_a? => true,
|
|
11
13
|
:document_id_for_key => 123, :fields => [], :attributes => [],
|
|
12
|
-
:conditions => []) }
|
|
14
|
+
:conditions => [], :primary_key => :id) }
|
|
13
15
|
let(:connection) { double('connection', :execute => true) }
|
|
14
16
|
|
|
15
17
|
before :each do
|
|
16
|
-
ThinkingSphinx::Configuration.
|
|
17
|
-
ThinkingSphinx::Connection.
|
|
18
|
+
allow(ThinkingSphinx::Configuration).to receive_messages :instance => config
|
|
19
|
+
allow(ThinkingSphinx::Connection).to receive_message_chain(:pool, :take).and_yield connection
|
|
18
20
|
end
|
|
19
21
|
|
|
20
|
-
describe '#after_save' do
|
|
22
|
+
describe '#after_save, #after_commit' do
|
|
21
23
|
let(:insert) { double('insert', :to_sql => 'REPLACE INTO my_index') }
|
|
22
24
|
let(:time) { 1.day.ago }
|
|
23
25
|
let(:field) { double('field', :name => 'name', :translate => 'Foo') }
|
|
@@ -25,32 +27,52 @@ describe ThinkingSphinx::RealTime::Callbacks::RealTimeCallbacks do
|
|
|
25
27
|
:translate => time) }
|
|
26
28
|
|
|
27
29
|
before :each do
|
|
28
|
-
ThinkingSphinx::Configuration.
|
|
29
|
-
Riddle::Query::Insert.
|
|
30
|
-
insert.
|
|
31
|
-
index.
|
|
30
|
+
allow(ThinkingSphinx::Configuration).to receive_messages :instance => config
|
|
31
|
+
allow(Riddle::Query::Insert).to receive_messages :new => insert
|
|
32
|
+
allow(insert).to receive_messages :replace! => insert
|
|
33
|
+
allow(index).to receive_messages :fields => [field], :attributes => [attribute]
|
|
32
34
|
end
|
|
33
35
|
|
|
34
36
|
it "creates an insert statement with all fields and attributes" do
|
|
35
|
-
Riddle::Query::Insert.
|
|
36
|
-
with('my_index', ['id', 'name', 'created_at'], [123, 'Foo', time]).
|
|
37
|
+
expect(Riddle::Query::Insert).to receive(:new).
|
|
38
|
+
with('my_index', ['id', 'name', 'created_at'], [[123, 'Foo', time]]).
|
|
37
39
|
and_return(insert)
|
|
38
40
|
|
|
39
41
|
callbacks.after_save instance
|
|
40
42
|
end
|
|
41
43
|
|
|
42
44
|
it "switches the insert to a replace statement" do
|
|
43
|
-
insert.
|
|
45
|
+
expect(insert).to receive(:replace!).and_return(insert)
|
|
44
46
|
|
|
45
47
|
callbacks.after_save instance
|
|
46
48
|
end
|
|
47
49
|
|
|
48
50
|
it "sends the insert through to the server" do
|
|
49
|
-
connection.
|
|
51
|
+
expect(connection).to receive(:execute).with('REPLACE INTO my_index')
|
|
50
52
|
|
|
51
53
|
callbacks.after_save instance
|
|
52
54
|
end
|
|
53
55
|
|
|
56
|
+
it "creates an insert statement with all fields and attributes" do
|
|
57
|
+
expect(Riddle::Query::Insert).to receive(:new).
|
|
58
|
+
with('my_index', ['id', 'name', 'created_at'], [[123, 'Foo', time]]).
|
|
59
|
+
and_return(insert)
|
|
60
|
+
|
|
61
|
+
callbacks.after_commit instance
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "switches the insert to a replace statement" do
|
|
65
|
+
expect(insert).to receive(:replace!).and_return(insert)
|
|
66
|
+
|
|
67
|
+
callbacks.after_commit instance
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "sends the insert through to the server" do
|
|
71
|
+
expect(connection).to receive(:execute).with('REPLACE INTO my_index')
|
|
72
|
+
|
|
73
|
+
callbacks.after_commit instance
|
|
74
|
+
end
|
|
75
|
+
|
|
54
76
|
context 'with a given path' do
|
|
55
77
|
let(:callbacks) {
|
|
56
78
|
ThinkingSphinx::RealTime::Callbacks::RealTimeCallbacks.new(
|
|
@@ -61,24 +83,44 @@ describe ThinkingSphinx::RealTime::Callbacks::RealTimeCallbacks do
|
|
|
61
83
|
let(:user) { double('user', :id => 13, :persisted? => true) }
|
|
62
84
|
|
|
63
85
|
it "creates an insert statement with all fields and attributes" do
|
|
64
|
-
Riddle::Query::Insert.
|
|
65
|
-
with('my_index', ['id', 'name', 'created_at'], [123, 'Foo', time]).
|
|
86
|
+
expect(Riddle::Query::Insert).to receive(:new).
|
|
87
|
+
with('my_index', ['id', 'name', 'created_at'], [[123, 'Foo', time]]).
|
|
66
88
|
and_return(insert)
|
|
67
89
|
|
|
68
90
|
callbacks.after_save instance
|
|
69
91
|
end
|
|
70
92
|
|
|
71
93
|
it "gets the document id for the user object" do
|
|
72
|
-
index.
|
|
94
|
+
expect(index).to receive(:document_id_for_key).with(13).and_return(123)
|
|
73
95
|
|
|
74
96
|
callbacks.after_save instance
|
|
75
97
|
end
|
|
76
98
|
|
|
77
99
|
it "translates values for the user object" do
|
|
78
|
-
field.
|
|
100
|
+
expect(field).to receive(:translate).with(user).and_return('Foo')
|
|
79
101
|
|
|
80
102
|
callbacks.after_save instance
|
|
81
103
|
end
|
|
104
|
+
|
|
105
|
+
it "creates an insert statement with all fields and attributes" do
|
|
106
|
+
expect(Riddle::Query::Insert).to receive(:new).
|
|
107
|
+
with('my_index', ['id', 'name', 'created_at'], [[123, 'Foo', time]]).
|
|
108
|
+
and_return(insert)
|
|
109
|
+
|
|
110
|
+
callbacks.after_commit instance
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "gets the document id for the user object" do
|
|
114
|
+
expect(index).to receive(:document_id_for_key).with(13).and_return(123)
|
|
115
|
+
|
|
116
|
+
callbacks.after_commit instance
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it "translates values for the user object" do
|
|
120
|
+
expect(field).to receive(:translate).with(user).and_return('Foo')
|
|
121
|
+
|
|
122
|
+
callbacks.after_commit instance
|
|
123
|
+
end
|
|
82
124
|
end
|
|
83
125
|
|
|
84
126
|
context 'with a path returning multiple objects' do
|
|
@@ -93,26 +135,48 @@ describe ThinkingSphinx::RealTime::Callbacks::RealTimeCallbacks do
|
|
|
93
135
|
let(:user_b) { double('user', :id => 14, :persisted? => true) }
|
|
94
136
|
|
|
95
137
|
it "creates insert statements with all fields and attributes" do
|
|
96
|
-
Riddle::Query::Insert.
|
|
97
|
-
with('my_index', ['id', 'name', 'created_at'], [123, 'Foo', time]).
|
|
138
|
+
expect(Riddle::Query::Insert).to receive(:new).twice.
|
|
139
|
+
with('my_index', ['id', 'name', 'created_at'], [[123, 'Foo', time]]).
|
|
98
140
|
and_return(insert)
|
|
99
141
|
|
|
100
142
|
callbacks.after_save instance
|
|
101
143
|
end
|
|
102
144
|
|
|
103
145
|
it "gets the document id for each reader" do
|
|
104
|
-
index.
|
|
105
|
-
index.
|
|
146
|
+
expect(index).to receive(:document_id_for_key).with(13).and_return(123)
|
|
147
|
+
expect(index).to receive(:document_id_for_key).with(14).and_return(123)
|
|
106
148
|
|
|
107
149
|
callbacks.after_save instance
|
|
108
150
|
end
|
|
109
151
|
|
|
110
152
|
it "translates values for each reader" do
|
|
111
|
-
field.
|
|
112
|
-
field.
|
|
153
|
+
expect(field).to receive(:translate).with(user_a).and_return('Foo')
|
|
154
|
+
expect(field).to receive(:translate).with(user_b).and_return('Foo')
|
|
113
155
|
|
|
114
156
|
callbacks.after_save instance
|
|
115
157
|
end
|
|
158
|
+
|
|
159
|
+
it "creates insert statements with all fields and attributes" do
|
|
160
|
+
expect(Riddle::Query::Insert).to receive(:new).twice.
|
|
161
|
+
with('my_index', ['id', 'name', 'created_at'], [[123, 'Foo', time]]).
|
|
162
|
+
and_return(insert)
|
|
163
|
+
|
|
164
|
+
callbacks.after_commit instance
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
it "gets the document id for each reader" do
|
|
168
|
+
expect(index).to receive(:document_id_for_key).with(13).and_return(123)
|
|
169
|
+
expect(index).to receive(:document_id_for_key).with(14).and_return(123)
|
|
170
|
+
|
|
171
|
+
callbacks.after_commit instance
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
it "translates values for each reader" do
|
|
175
|
+
expect(field).to receive(:translate).with(user_a).and_return('Foo')
|
|
176
|
+
expect(field).to receive(:translate).with(user_b).and_return('Foo')
|
|
177
|
+
|
|
178
|
+
callbacks.after_commit instance
|
|
179
|
+
end
|
|
116
180
|
end
|
|
117
181
|
|
|
118
182
|
context 'with a block instead of a path' do
|
|
@@ -127,26 +191,48 @@ describe ThinkingSphinx::RealTime::Callbacks::RealTimeCallbacks do
|
|
|
127
191
|
let(:user_b) { double('user', :id => 14, :persisted? => true) }
|
|
128
192
|
|
|
129
193
|
it "creates insert statements with all fields and attributes" do
|
|
130
|
-
Riddle::Query::Insert.
|
|
131
|
-
with('my_index', ['id', 'name', 'created_at'], [123, 'Foo', time]).
|
|
194
|
+
expect(Riddle::Query::Insert).to receive(:new).twice.
|
|
195
|
+
with('my_index', ['id', 'name', 'created_at'], [[123, 'Foo', time]]).
|
|
132
196
|
and_return(insert)
|
|
133
197
|
|
|
134
198
|
callbacks.after_save instance
|
|
135
199
|
end
|
|
136
200
|
|
|
137
201
|
it "gets the document id for each reader" do
|
|
138
|
-
index.
|
|
139
|
-
index.
|
|
202
|
+
expect(index).to receive(:document_id_for_key).with(13).and_return(123)
|
|
203
|
+
expect(index).to receive(:document_id_for_key).with(14).and_return(123)
|
|
140
204
|
|
|
141
205
|
callbacks.after_save instance
|
|
142
206
|
end
|
|
143
207
|
|
|
144
208
|
it "translates values for each reader" do
|
|
145
|
-
field.
|
|
146
|
-
field.
|
|
209
|
+
expect(field).to receive(:translate).with(user_a).and_return('Foo')
|
|
210
|
+
expect(field).to receive(:translate).with(user_b).and_return('Foo')
|
|
147
211
|
|
|
148
212
|
callbacks.after_save instance
|
|
149
213
|
end
|
|
214
|
+
|
|
215
|
+
it "creates insert statements with all fields and attributes" do
|
|
216
|
+
expect(Riddle::Query::Insert).to receive(:new).twice.
|
|
217
|
+
with('my_index', ['id', 'name', 'created_at'], [[123, 'Foo', time]]).
|
|
218
|
+
and_return(insert)
|
|
219
|
+
|
|
220
|
+
callbacks.after_commit instance
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
it "gets the document id for each reader" do
|
|
224
|
+
expect(index).to receive(:document_id_for_key).with(13).and_return(123)
|
|
225
|
+
expect(index).to receive(:document_id_for_key).with(14).and_return(123)
|
|
226
|
+
|
|
227
|
+
callbacks.after_commit instance
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
it "translates values for each reader" do
|
|
231
|
+
expect(field).to receive(:translate).with(user_a).and_return('Foo')
|
|
232
|
+
expect(field).to receive(:translate).with(user_b).and_return('Foo')
|
|
233
|
+
|
|
234
|
+
callbacks.after_commit instance
|
|
235
|
+
end
|
|
150
236
|
end
|
|
151
237
|
end
|
|
152
238
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe ThinkingSphinx::RealTime::Field do
|
|
@@ -6,11 +8,11 @@ describe ThinkingSphinx::RealTime::Field do
|
|
|
6
8
|
|
|
7
9
|
describe '#column' do
|
|
8
10
|
it 'returns the provided Column object' do
|
|
9
|
-
field.column.
|
|
11
|
+
expect(field.column).to eq(column)
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
it 'translates symbols to Column objects' do
|
|
13
|
-
ThinkingSphinx::ActiveRecord::Column.
|
|
15
|
+
expect(ThinkingSphinx::ActiveRecord::Column).to receive(:new).with(:title).
|
|
14
16
|
and_return(column)
|
|
15
17
|
|
|
16
18
|
ThinkingSphinx::RealTime::Field.new :title
|
|
@@ -20,11 +22,11 @@ describe ThinkingSphinx::RealTime::Field do
|
|
|
20
22
|
describe '#name' do
|
|
21
23
|
it "uses the provided option by default" do
|
|
22
24
|
field = ThinkingSphinx::RealTime::Field.new column, :as => :foo
|
|
23
|
-
field.name.
|
|
25
|
+
expect(field.name).to eq('foo')
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
it "falls back to the column's name" do
|
|
27
|
-
field.name.
|
|
29
|
+
expect(field.name).to eq('created_at')
|
|
28
30
|
end
|
|
29
31
|
end
|
|
30
32
|
|
|
@@ -34,34 +36,34 @@ describe ThinkingSphinx::RealTime::Field do
|
|
|
34
36
|
let(:parent) { klass.new 'the parent name', nil }
|
|
35
37
|
|
|
36
38
|
it "returns the column's name if it's a string" do
|
|
37
|
-
column.
|
|
39
|
+
allow(column).to receive_messages :__name => 'value'
|
|
38
40
|
|
|
39
|
-
field.translate(object).
|
|
41
|
+
expect(field.translate(object)).to eq('value')
|
|
40
42
|
end
|
|
41
43
|
|
|
42
44
|
it "returns the column's name as a string if it's an integer" do
|
|
43
|
-
column.
|
|
45
|
+
allow(column).to receive_messages :__name => 404
|
|
44
46
|
|
|
45
|
-
field.translate(object).
|
|
47
|
+
expect(field.translate(object)).to eq('404')
|
|
46
48
|
end
|
|
47
49
|
|
|
48
50
|
it "returns the object's method matching the column's name" do
|
|
49
|
-
object.
|
|
51
|
+
allow(object).to receive_messages :created_at => 'a time'
|
|
50
52
|
|
|
51
|
-
field.translate(object).
|
|
53
|
+
expect(field.translate(object)).to eq('a time')
|
|
52
54
|
end
|
|
53
55
|
|
|
54
56
|
it "uses the column's stack to navigate through the object tree" do
|
|
55
|
-
column.
|
|
57
|
+
allow(column).to receive_messages :__name => :name, :__stack => [:parent]
|
|
56
58
|
|
|
57
|
-
field.translate(object).
|
|
59
|
+
expect(field.translate(object)).to eq('the parent name')
|
|
58
60
|
end
|
|
59
61
|
|
|
60
62
|
it "returns a blank string if any element in the object tree is nil" do
|
|
61
|
-
column.
|
|
63
|
+
allow(column).to receive_messages :__name => :name, :__stack => [:parent]
|
|
62
64
|
object.parent = nil
|
|
63
65
|
|
|
64
|
-
field.translate(object).
|
|
66
|
+
expect(field.translate(object)).to eq('')
|
|
65
67
|
end
|
|
66
68
|
end
|
|
67
69
|
end
|
|
@@ -1,47 +1,98 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe ThinkingSphinx::RealTime::Index do
|
|
4
6
|
let(:index) { ThinkingSphinx::RealTime::Index.new :user }
|
|
5
|
-
let(:indices_path) { double('indices path', :join => '') }
|
|
6
7
|
let(:config) { double('config', :settings => {},
|
|
7
|
-
:indices_location =>
|
|
8
|
+
:indices_location => 'location', :next_offset => 8,
|
|
9
|
+
:index_set_class => index_set_class) }
|
|
10
|
+
let(:index_set_class) { double(:index_set_class, :reference_name => :user) }
|
|
8
11
|
|
|
9
12
|
before :each do
|
|
10
|
-
ThinkingSphinx::Configuration.
|
|
13
|
+
allow(ThinkingSphinx::Configuration).to receive_messages :instance => config
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe '#add_attribute' do
|
|
17
|
+
let(:attribute) { double('attribute', name: 'my_attribute') }
|
|
18
|
+
|
|
19
|
+
it "appends attributes to the collection" do
|
|
20
|
+
index.add_attribute attribute
|
|
21
|
+
|
|
22
|
+
expect(index.attributes.collect(&:name)).to include('my_attribute')
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "replaces attributes with the same name" do
|
|
26
|
+
index.add_attribute double('attribute', name: 'my_attribute')
|
|
27
|
+
index.add_attribute attribute
|
|
28
|
+
|
|
29
|
+
matching = index.attributes.select { |attr| attr.name == attribute.name }
|
|
30
|
+
|
|
31
|
+
expect(matching).to eq([attribute])
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe '#add_field' do
|
|
36
|
+
let(:field) { double('field', name: 'my_field') }
|
|
37
|
+
|
|
38
|
+
it "appends fields to the collection" do
|
|
39
|
+
index.add_field field
|
|
40
|
+
|
|
41
|
+
expect(index.fields.collect(&:name)).to include('my_field')
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "replaces fields with the same name" do
|
|
45
|
+
index.add_field double('field', name: 'my_field')
|
|
46
|
+
index.add_field field
|
|
47
|
+
|
|
48
|
+
matching = index.fields.select { |fld| fld.name == field.name }
|
|
49
|
+
|
|
50
|
+
expect(matching).to eq([field])
|
|
51
|
+
end
|
|
11
52
|
end
|
|
12
53
|
|
|
13
54
|
describe '#attributes' do
|
|
14
55
|
it "has the internal id attribute by default" do
|
|
15
|
-
index.attributes.collect(&:name).
|
|
56
|
+
expect(index.attributes.collect(&:name)).to include('sphinx_internal_id')
|
|
16
57
|
end
|
|
17
58
|
|
|
18
59
|
it "has the class name attribute by default" do
|
|
19
|
-
index.attributes.collect(&:name).
|
|
60
|
+
expect(index.attributes.collect(&:name)).to include('sphinx_internal_class')
|
|
20
61
|
end
|
|
21
62
|
|
|
22
63
|
it "has the internal deleted attribute by default" do
|
|
23
|
-
index.attributes.collect(&:name).
|
|
64
|
+
expect(index.attributes.collect(&:name)).to include('sphinx_deleted')
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "does not have an internal updated_at attribute by default" do
|
|
68
|
+
expect(index.attributes.collect(&:name)).to_not include('sphinx_updated_at')
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "has an internal updated_at attribute if real_time_tidy is true" do
|
|
72
|
+
config.settings["real_time_tidy"] = true
|
|
73
|
+
|
|
74
|
+
expect(index.attributes.collect(&:name)).to include('sphinx_updated_at')
|
|
24
75
|
end
|
|
25
76
|
end
|
|
26
77
|
|
|
27
78
|
describe '#delta?' do
|
|
28
79
|
it "always returns false" do
|
|
29
|
-
index.
|
|
80
|
+
expect(index).not_to be_delta
|
|
30
81
|
end
|
|
31
82
|
end
|
|
32
83
|
|
|
33
84
|
describe '#document_id_for_key' do
|
|
34
85
|
it "calculates the document id based on offset and number of indices" do
|
|
35
|
-
config.
|
|
36
|
-
config.
|
|
86
|
+
allow(config).to receive_message_chain(:indices, :count).and_return(5)
|
|
87
|
+
allow(config).to receive_messages :next_offset => 7
|
|
37
88
|
|
|
38
|
-
index.document_id_for_key(123).
|
|
89
|
+
expect(index.document_id_for_key(123)).to eq(622)
|
|
39
90
|
end
|
|
40
91
|
end
|
|
41
92
|
|
|
42
93
|
describe '#fields' do
|
|
43
94
|
it "has the internal class field by default" do
|
|
44
|
-
index.fields.collect(&:name).
|
|
95
|
+
expect(index.fields.collect(&:name)).to include('sphinx_internal_class_name')
|
|
45
96
|
end
|
|
46
97
|
end
|
|
47
98
|
|
|
@@ -53,14 +104,14 @@ describe ThinkingSphinx::RealTime::Index do
|
|
|
53
104
|
end
|
|
54
105
|
|
|
55
106
|
it "interprets the definition block" do
|
|
56
|
-
ThinkingSphinx::RealTime::Interpreter.
|
|
107
|
+
expect(ThinkingSphinx::RealTime::Interpreter).to receive(:translate!).
|
|
57
108
|
with(index, block)
|
|
58
109
|
|
|
59
110
|
index.interpret_definition!
|
|
60
111
|
end
|
|
61
112
|
|
|
62
113
|
it "only interprets the definition block once" do
|
|
63
|
-
ThinkingSphinx::RealTime::Interpreter.
|
|
114
|
+
expect(ThinkingSphinx::RealTime::Interpreter).to receive(:translate!).
|
|
64
115
|
once
|
|
65
116
|
|
|
66
117
|
index.interpret_definition!
|
|
@@ -69,16 +120,16 @@ describe ThinkingSphinx::RealTime::Index do
|
|
|
69
120
|
end
|
|
70
121
|
|
|
71
122
|
describe '#model' do
|
|
72
|
-
let(:model) { double('model') }
|
|
123
|
+
let(:model) { double('model', :primary_key => :id) }
|
|
73
124
|
|
|
74
125
|
it "translates symbol references to model class" do
|
|
75
|
-
ActiveSupport::Inflector.
|
|
126
|
+
allow(ActiveSupport::Inflector).to receive_messages(:constantize => model)
|
|
76
127
|
|
|
77
|
-
index.model.
|
|
128
|
+
expect(index.model).to eq(model)
|
|
78
129
|
end
|
|
79
130
|
|
|
80
131
|
it "memoizes the result" do
|
|
81
|
-
ActiveSupport::Inflector.
|
|
132
|
+
expect(ActiveSupport::Inflector).to receive(:constantize).with('User').once.
|
|
82
133
|
and_return(model)
|
|
83
134
|
|
|
84
135
|
index.model
|
|
@@ -88,7 +139,7 @@ describe ThinkingSphinx::RealTime::Index do
|
|
|
88
139
|
|
|
89
140
|
describe '#morphology' do
|
|
90
141
|
before :each do
|
|
91
|
-
|
|
142
|
+
skip
|
|
92
143
|
end
|
|
93
144
|
|
|
94
145
|
context 'with a render' do
|
|
@@ -98,7 +149,7 @@ describe ThinkingSphinx::RealTime::Index do
|
|
|
98
149
|
rescue Riddle::Configuration::ConfigurationError
|
|
99
150
|
end
|
|
100
151
|
|
|
101
|
-
index.morphology.
|
|
152
|
+
expect(index.morphology).to be_nil
|
|
102
153
|
end
|
|
103
154
|
|
|
104
155
|
it "reads from the settings file if provided" do
|
|
@@ -109,7 +160,7 @@ describe ThinkingSphinx::RealTime::Index do
|
|
|
109
160
|
rescue Riddle::Configuration::ConfigurationError
|
|
110
161
|
end
|
|
111
162
|
|
|
112
|
-
index.morphology.
|
|
163
|
+
expect(index.morphology).to eq('stem_en')
|
|
113
164
|
end
|
|
114
165
|
end
|
|
115
166
|
end
|
|
@@ -117,21 +168,21 @@ describe ThinkingSphinx::RealTime::Index do
|
|
|
117
168
|
describe '#name' do
|
|
118
169
|
it "always uses the core suffix" do
|
|
119
170
|
index = ThinkingSphinx::RealTime::Index.new :user
|
|
120
|
-
index.name.
|
|
171
|
+
expect(index.name).to eq('user_core')
|
|
121
172
|
end
|
|
122
173
|
end
|
|
123
174
|
|
|
124
175
|
describe '#offset' do
|
|
125
176
|
before :each do
|
|
126
|
-
config.
|
|
177
|
+
allow(config).to receive_messages :next_offset => 4
|
|
127
178
|
end
|
|
128
179
|
|
|
129
180
|
it "uses the next offset value from the configuration" do
|
|
130
|
-
index.offset.
|
|
181
|
+
expect(index.offset).to eq(4)
|
|
131
182
|
end
|
|
132
183
|
|
|
133
184
|
it "uses the reference to get a unique offset" do
|
|
134
|
-
config.
|
|
185
|
+
expect(config).to receive(:next_offset).with(:user).and_return(2)
|
|
135
186
|
|
|
136
187
|
index.offset
|
|
137
188
|
end
|
|
@@ -139,11 +190,11 @@ describe ThinkingSphinx::RealTime::Index do
|
|
|
139
190
|
|
|
140
191
|
describe '#render' do
|
|
141
192
|
before :each do
|
|
142
|
-
FileUtils.
|
|
193
|
+
allow(FileUtils).to receive_messages :mkdir_p => true
|
|
143
194
|
end
|
|
144
195
|
|
|
145
196
|
it "interprets the provided definition" do
|
|
146
|
-
index.
|
|
197
|
+
expect(index).to receive(:interpret_definition!).at_least(:once)
|
|
147
198
|
|
|
148
199
|
begin
|
|
149
200
|
index.render
|
|
@@ -154,26 +205,26 @@ describe ThinkingSphinx::RealTime::Index do
|
|
|
154
205
|
end
|
|
155
206
|
|
|
156
207
|
describe '#scope' do
|
|
157
|
-
let(:model) { double('model') }
|
|
208
|
+
let(:model) { double('model', :primary_key => :id) }
|
|
158
209
|
|
|
159
210
|
it "returns the model by default" do
|
|
160
|
-
ActiveSupport::Inflector.
|
|
211
|
+
allow(ActiveSupport::Inflector).to receive_messages(:constantize => model)
|
|
161
212
|
|
|
162
|
-
index.scope.
|
|
213
|
+
expect(index.scope).to eq(model)
|
|
163
214
|
end
|
|
164
215
|
|
|
165
216
|
it "returns the evaluated scope if provided" do
|
|
166
217
|
index.scope = lambda { :foo }
|
|
167
218
|
|
|
168
|
-
index.scope.
|
|
219
|
+
expect(index.scope).to eq(:foo)
|
|
169
220
|
end
|
|
170
221
|
end
|
|
171
222
|
|
|
172
223
|
describe '#unique_attribute_names' do
|
|
173
224
|
it "returns all attribute names" do
|
|
174
|
-
index.unique_attribute_names.
|
|
225
|
+
expect(index.unique_attribute_names).to eq([
|
|
175
226
|
'sphinx_internal_id', 'sphinx_internal_class', 'sphinx_deleted'
|
|
176
|
-
]
|
|
227
|
+
])
|
|
177
228
|
end
|
|
178
229
|
end
|
|
179
230
|
end
|