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::ActiveRecord::DatabaseAdapters do
|
|
@@ -5,21 +7,21 @@ describe ThinkingSphinx::ActiveRecord::DatabaseAdapters do
|
|
|
5
7
|
|
|
6
8
|
describe '.adapter_for' do
|
|
7
9
|
it "returns a MysqlAdapter object for :mysql" do
|
|
8
|
-
ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
9
|
-
|
|
10
|
+
allow(ThinkingSphinx::ActiveRecord::DatabaseAdapters).
|
|
11
|
+
to receive_messages(:adapter_type_for => :mysql)
|
|
10
12
|
|
|
11
|
-
ThinkingSphinx::ActiveRecord::DatabaseAdapters.adapter_for(model).
|
|
12
|
-
|
|
13
|
+
expect(ThinkingSphinx::ActiveRecord::DatabaseAdapters.adapter_for(model)).
|
|
14
|
+
to be_a(
|
|
13
15
|
ThinkingSphinx::ActiveRecord::DatabaseAdapters::MySQLAdapter
|
|
14
16
|
)
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
it "returns a PostgreSQLAdapter object for :postgresql" do
|
|
18
|
-
ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
19
|
-
|
|
20
|
+
allow(ThinkingSphinx::ActiveRecord::DatabaseAdapters).
|
|
21
|
+
to receive_messages(:adapter_type_for => :postgresql)
|
|
20
22
|
|
|
21
|
-
ThinkingSphinx::ActiveRecord::DatabaseAdapters.adapter_for(model).
|
|
22
|
-
|
|
23
|
+
expect(ThinkingSphinx::ActiveRecord::DatabaseAdapters.adapter_for(model)).
|
|
24
|
+
to be_a(
|
|
23
25
|
ThinkingSphinx::ActiveRecord::DatabaseAdapters::PostgreSQLAdapter
|
|
24
26
|
)
|
|
25
27
|
end
|
|
@@ -29,21 +31,21 @@ describe ThinkingSphinx::ActiveRecord::DatabaseAdapters do
|
|
|
29
31
|
adapter_instance = double('adapter instance')
|
|
30
32
|
|
|
31
33
|
ThinkingSphinx::ActiveRecord::DatabaseAdapters.default = adapter_class
|
|
32
|
-
adapter_class.
|
|
34
|
+
allow(adapter_class).to receive_messages(:new => adapter_instance)
|
|
33
35
|
|
|
34
|
-
ThinkingSphinx::ActiveRecord::DatabaseAdapters.adapter_for(model).
|
|
35
|
-
|
|
36
|
+
expect(ThinkingSphinx::ActiveRecord::DatabaseAdapters.adapter_for(model)).
|
|
37
|
+
to eq(adapter_instance)
|
|
36
38
|
|
|
37
39
|
ThinkingSphinx::ActiveRecord::DatabaseAdapters.default = nil
|
|
38
40
|
end
|
|
39
41
|
|
|
40
42
|
it "raises an exception for other responses" do
|
|
41
|
-
ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
42
|
-
|
|
43
|
+
allow(ThinkingSphinx::ActiveRecord::DatabaseAdapters).
|
|
44
|
+
to receive_messages(:adapter_type_for => :sqlite)
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
expect {
|
|
45
47
|
ThinkingSphinx::ActiveRecord::DatabaseAdapters.adapter_for(model)
|
|
46
|
-
}.
|
|
48
|
+
}.to raise_error(ThinkingSphinx::InvalidDatabaseAdapter)
|
|
47
49
|
end
|
|
48
50
|
end
|
|
49
51
|
|
|
@@ -53,74 +55,74 @@ describe ThinkingSphinx::ActiveRecord::DatabaseAdapters do
|
|
|
53
55
|
let(:model) { double('model', :connection => connection) }
|
|
54
56
|
|
|
55
57
|
it "translates a normal MySQL adapter" do
|
|
56
|
-
klass.
|
|
58
|
+
allow(klass).to receive_messages(:name => 'ActiveRecord::ConnectionAdapters::MysqlAdapter')
|
|
57
59
|
|
|
58
|
-
ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
59
|
-
adapter_type_for(model).
|
|
60
|
+
expect(ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
61
|
+
adapter_type_for(model)).to eq(:mysql)
|
|
60
62
|
end
|
|
61
63
|
|
|
62
64
|
it "translates a MySQL2 adapter" do
|
|
63
|
-
klass.
|
|
65
|
+
allow(klass).to receive_messages(:name => 'ActiveRecord::ConnectionAdapters::Mysql2Adapter')
|
|
64
66
|
|
|
65
|
-
ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
66
|
-
adapter_type_for(model).
|
|
67
|
+
expect(ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
68
|
+
adapter_type_for(model)).to eq(:mysql)
|
|
67
69
|
end
|
|
68
70
|
|
|
69
71
|
it "translates a normal PostgreSQL adapter" do
|
|
70
|
-
klass.
|
|
72
|
+
allow(klass).to receive_messages(:name => 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter')
|
|
71
73
|
|
|
72
|
-
ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
73
|
-
adapter_type_for(model).
|
|
74
|
+
expect(ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
75
|
+
adapter_type_for(model)).to eq(:postgresql)
|
|
74
76
|
end
|
|
75
77
|
|
|
76
78
|
it "translates a JDBC MySQL adapter to MySQL" do
|
|
77
|
-
klass.
|
|
78
|
-
connection.
|
|
79
|
+
allow(klass).to receive_messages(:name => 'ActiveRecord::ConnectionAdapters::JdbcAdapter')
|
|
80
|
+
allow(connection).to receive_messages(:config => {:adapter => 'jdbcmysql'})
|
|
79
81
|
|
|
80
|
-
ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
81
|
-
adapter_type_for(model).
|
|
82
|
+
expect(ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
83
|
+
adapter_type_for(model)).to eq(:mysql)
|
|
82
84
|
end
|
|
83
85
|
|
|
84
86
|
it "translates a JDBC PostgreSQL adapter to PostgreSQL" do
|
|
85
|
-
klass.
|
|
86
|
-
connection.
|
|
87
|
+
allow(klass).to receive_messages(:name => 'ActiveRecord::ConnectionAdapters::JdbcAdapter')
|
|
88
|
+
allow(connection).to receive_messages(:config => {:adapter => 'jdbcpostgresql'})
|
|
87
89
|
|
|
88
|
-
ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
89
|
-
adapter_type_for(model).
|
|
90
|
+
expect(ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
91
|
+
adapter_type_for(model)).to eq(:postgresql)
|
|
90
92
|
end
|
|
91
93
|
|
|
92
94
|
it "translates a JDBC adapter with MySQL connection string to MySQL" do
|
|
93
|
-
klass.
|
|
94
|
-
connection.
|
|
95
|
+
allow(klass).to receive_messages(:name => 'ActiveRecord::ConnectionAdapters::JdbcAdapter')
|
|
96
|
+
allow(connection).to receive_messages(:config => {:adapter => 'jdbc',
|
|
95
97
|
:url => 'jdbc:mysql://127.0.0.1:3306/sphinx'})
|
|
96
98
|
|
|
97
|
-
ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
98
|
-
adapter_type_for(model).
|
|
99
|
+
expect(ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
100
|
+
adapter_type_for(model)).to eq(:mysql)
|
|
99
101
|
end
|
|
100
102
|
|
|
101
103
|
it "translates a JDBC adapter with PostgresSQL connection string to PostgresSQL" do
|
|
102
|
-
klass.
|
|
103
|
-
connection.
|
|
104
|
+
allow(klass).to receive_messages(:name => 'ActiveRecord::ConnectionAdapters::JdbcAdapter')
|
|
105
|
+
allow(connection).to receive_messages(:config => {:adapter => 'jdbc',
|
|
104
106
|
:url => 'jdbc:postgresql://127.0.0.1:3306/sphinx'})
|
|
105
107
|
|
|
106
|
-
ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
107
|
-
adapter_type_for(model).
|
|
108
|
+
expect(ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
109
|
+
adapter_type_for(model)).to eq(:postgresql)
|
|
108
110
|
end
|
|
109
111
|
|
|
110
112
|
it "returns other JDBC adapters without translation" do
|
|
111
|
-
klass.
|
|
112
|
-
connection.
|
|
113
|
+
allow(klass).to receive_messages(:name => 'ActiveRecord::ConnectionAdapters::JdbcAdapter')
|
|
114
|
+
allow(connection).to receive_messages(:config => {:adapter => 'jdbcmssql'})
|
|
113
115
|
|
|
114
|
-
ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
115
|
-
adapter_type_for(model).
|
|
116
|
+
expect(ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
117
|
+
adapter_type_for(model)).to eq('jdbcmssql')
|
|
116
118
|
end
|
|
117
119
|
|
|
118
120
|
it "returns other unknown adapters without translation" do
|
|
119
|
-
klass.
|
|
121
|
+
allow(klass).to receive_messages(:name => 'ActiveRecord::ConnectionAdapters::FooAdapter')
|
|
120
122
|
|
|
121
|
-
ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
122
|
-
adapter_type_for(model).
|
|
123
|
-
|
|
123
|
+
expect(ThinkingSphinx::ActiveRecord::DatabaseAdapters.
|
|
124
|
+
adapter_type_for(model)).
|
|
125
|
+
to eq('ActiveRecord::ConnectionAdapters::FooAdapter')
|
|
124
126
|
end
|
|
125
127
|
end
|
|
126
128
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe ThinkingSphinx::ActiveRecord::Field do
|
|
@@ -7,16 +9,16 @@ describe ThinkingSphinx::ActiveRecord::Field do
|
|
|
7
9
|
let(:model) { double('model') }
|
|
8
10
|
|
|
9
11
|
before :each do
|
|
10
|
-
column.
|
|
12
|
+
allow(column).to receive_messages :to_a => [column]
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
describe '#columns' do
|
|
14
16
|
it 'returns the provided Column object' do
|
|
15
|
-
field.columns.
|
|
17
|
+
expect(field.columns).to eq([column])
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
it 'translates symbols to Column objects' do
|
|
19
|
-
ThinkingSphinx::ActiveRecord::Column.
|
|
21
|
+
expect(ThinkingSphinx::ActiveRecord::Column).to receive(:new).with(:title).
|
|
20
22
|
and_return(column)
|
|
21
23
|
|
|
22
24
|
ThinkingSphinx::ActiveRecord::Field.new model, :title
|
|
@@ -25,25 +27,25 @@ describe ThinkingSphinx::ActiveRecord::Field do
|
|
|
25
27
|
|
|
26
28
|
describe '#file?' do
|
|
27
29
|
it "defaults to false" do
|
|
28
|
-
field.
|
|
30
|
+
expect(field).not_to be_file
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
it "is true if file option is set" do
|
|
32
34
|
field = ThinkingSphinx::ActiveRecord::Field.new model, column,
|
|
33
35
|
:file => true
|
|
34
|
-
field.
|
|
36
|
+
expect(field).to be_file
|
|
35
37
|
end
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
describe '#with_attribute?' do
|
|
39
41
|
it "defaults to false" do
|
|
40
|
-
field.
|
|
42
|
+
expect(field).not_to be_with_attribute
|
|
41
43
|
end
|
|
42
44
|
|
|
43
45
|
it "is true if the field is sortable" do
|
|
44
46
|
field = ThinkingSphinx::ActiveRecord::Field.new model, column,
|
|
45
47
|
:sortable => true
|
|
46
|
-
field.
|
|
48
|
+
expect(field).to be_with_attribute
|
|
47
49
|
end
|
|
48
50
|
end
|
|
49
51
|
end
|
|
@@ -1,37 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe ThinkingSphinx::ActiveRecord::FilterReflection do
|
|
4
6
|
describe '.call' do
|
|
5
7
|
let(:reflection) { double('Reflection', :macro => :has_some,
|
|
6
8
|
:options => options, :active_record => double, :name => 'baz',
|
|
7
|
-
:foreign_type => :foo_type, :class =>
|
|
9
|
+
:foreign_type => :foo_type, :class => original_klass,
|
|
10
|
+
:build_join_constraint => nil) }
|
|
8
11
|
let(:options) { {:polymorphic => true} }
|
|
9
12
|
let(:filtered_reflection) { double 'filtered reflection' }
|
|
10
|
-
let(:
|
|
11
|
-
|
|
12
|
-
let(:initialize_method) { double :arity => 4 }
|
|
13
|
+
let(:original_klass) { double }
|
|
14
|
+
let(:subclass) { double :include => true }
|
|
13
15
|
|
|
14
16
|
before :each do
|
|
15
|
-
reflection.active_record.
|
|
17
|
+
allow(reflection.active_record).to receive_message_chain(:connection, :quote_column_name).
|
|
16
18
|
and_return('"foo_type"')
|
|
19
|
+
|
|
20
|
+
if ActiveRecord::VERSION::STRING.to_f < 5.2
|
|
21
|
+
allow(original_klass).to receive(:new).and_return(filtered_reflection)
|
|
22
|
+
else
|
|
23
|
+
allow(Class).to receive(:new).with(original_klass).and_return(subclass)
|
|
24
|
+
allow(subclass).to receive(:new).and_return(filtered_reflection)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class ArgumentsWrapper
|
|
29
|
+
attr_reader :macro, :name, :scope, :options, :parent
|
|
30
|
+
|
|
31
|
+
def initialize(*arguments)
|
|
32
|
+
if ActiveRecord::VERSION::STRING.to_f < 4.0
|
|
33
|
+
@macro, @name, @options, @parent = arguments
|
|
34
|
+
elsif ActiveRecord::VERSION::STRING.to_f < 4.2
|
|
35
|
+
@macro, @name, @scope, @options, @parent = arguments
|
|
36
|
+
else
|
|
37
|
+
@name, @scope, @options, @parent = arguments
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def reflection_klass
|
|
43
|
+
ActiveRecord::VERSION::STRING.to_f < 5.2 ? original_klass : subclass
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def expected_reflection_arguments
|
|
47
|
+
expect(reflection_klass).to receive(:new) do |*arguments|
|
|
48
|
+
yield ArgumentsWrapper.new(*arguments)
|
|
49
|
+
end
|
|
17
50
|
end
|
|
18
51
|
|
|
19
52
|
it "uses the existing reflection's macro" do
|
|
20
|
-
reflection_klass.
|
|
21
|
-
|
|
53
|
+
expect(reflection_klass).to receive(:new) do |macro, *args|
|
|
54
|
+
expect(macro).to eq(:has_some)
|
|
55
|
+
end
|
|
22
56
|
|
|
23
57
|
ThinkingSphinx::ActiveRecord::FilterReflection.call(
|
|
24
58
|
reflection, 'foo_bar', 'Bar'
|
|
25
59
|
)
|
|
26
|
-
end
|
|
60
|
+
end if ActiveRecord::VERSION::STRING.to_f < 4.2
|
|
27
61
|
|
|
28
62
|
it "uses the supplied name" do
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
with('foo_bar', anything, anything, anything)
|
|
32
|
-
else
|
|
33
|
-
reflection_klass.should_receive(:new).
|
|
34
|
-
with(anything, 'foo_bar', anything, anything)
|
|
63
|
+
expected_reflection_arguments do |wrapper|
|
|
64
|
+
expect(wrapper.name).to eq('foo_bar')
|
|
35
65
|
end
|
|
36
66
|
|
|
37
67
|
ThinkingSphinx::ActiveRecord::FilterReflection.call(
|
|
@@ -40,12 +70,8 @@ describe ThinkingSphinx::ActiveRecord::FilterReflection do
|
|
|
40
70
|
end
|
|
41
71
|
|
|
42
72
|
it "uses the existing reflection's parent" do
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
with(anything, anything, anything, reflection.active_record)
|
|
46
|
-
else
|
|
47
|
-
reflection_klass.should_receive(:new).
|
|
48
|
-
with(anything, anything, anything, reflection.active_record)
|
|
73
|
+
expected_reflection_arguments do |wrapper|
|
|
74
|
+
expect(wrapper.parent).to eq(reflection.active_record)
|
|
49
75
|
end
|
|
50
76
|
|
|
51
77
|
ThinkingSphinx::ActiveRecord::FilterReflection.call(
|
|
@@ -54,14 +80,8 @@ describe ThinkingSphinx::ActiveRecord::FilterReflection do
|
|
|
54
80
|
end
|
|
55
81
|
|
|
56
82
|
it "removes the polymorphic setting from the options" do
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
options[:polymorphic].should be_nil
|
|
60
|
-
end
|
|
61
|
-
else
|
|
62
|
-
reflection_klass.should_receive(:new) do |macro, name, options, parent|
|
|
63
|
-
options[:polymorphic].should be_nil
|
|
64
|
-
end
|
|
83
|
+
expected_reflection_arguments do |wrapper|
|
|
84
|
+
expect(wrapper.options[:polymorphic]).to be_nil
|
|
65
85
|
end
|
|
66
86
|
|
|
67
87
|
ThinkingSphinx::ActiveRecord::FilterReflection.call(
|
|
@@ -70,14 +90,8 @@ describe ThinkingSphinx::ActiveRecord::FilterReflection do
|
|
|
70
90
|
end
|
|
71
91
|
|
|
72
92
|
it "adds the class name option" do
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
options[:class_name].should == 'Bar'
|
|
76
|
-
end
|
|
77
|
-
else
|
|
78
|
-
reflection_klass.should_receive(:new) do |macro, name, options, parent|
|
|
79
|
-
options[:class_name].should == 'Bar'
|
|
80
|
-
end
|
|
93
|
+
expected_reflection_arguments do |wrapper|
|
|
94
|
+
expect(wrapper.options[:class_name]).to eq('Bar')
|
|
81
95
|
end
|
|
82
96
|
|
|
83
97
|
ThinkingSphinx::ActiveRecord::FilterReflection.call(
|
|
@@ -86,14 +100,8 @@ describe ThinkingSphinx::ActiveRecord::FilterReflection do
|
|
|
86
100
|
end
|
|
87
101
|
|
|
88
102
|
it "sets the foreign key if necessary" do
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
options[:foreign_key].should == 'baz_id'
|
|
92
|
-
end
|
|
93
|
-
else
|
|
94
|
-
reflection_klass.should_receive(:new) do |macro, name, options, parent|
|
|
95
|
-
options[:foreign_key].should == 'baz_id'
|
|
96
|
-
end
|
|
103
|
+
expected_reflection_arguments do |wrapper|
|
|
104
|
+
expect(wrapper.options[:foreign_key]).to eq('baz_id')
|
|
97
105
|
end
|
|
98
106
|
|
|
99
107
|
ThinkingSphinx::ActiveRecord::FilterReflection.call(
|
|
@@ -104,14 +112,8 @@ describe ThinkingSphinx::ActiveRecord::FilterReflection do
|
|
|
104
112
|
it "respects supplied foreign keys" do
|
|
105
113
|
options[:foreign_key] = 'qux_id'
|
|
106
114
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
options[:foreign_key].should == 'qux_id'
|
|
110
|
-
end
|
|
111
|
-
else
|
|
112
|
-
reflection_klass.should_receive(:new) do |macro, name, options, parent|
|
|
113
|
-
options[:foreign_key].should == 'qux_id'
|
|
114
|
-
end
|
|
115
|
+
expected_reflection_arguments do |wrapper|
|
|
116
|
+
expect(wrapper.options[:foreign_key]).to eq('qux_id')
|
|
115
117
|
end
|
|
116
118
|
|
|
117
119
|
ThinkingSphinx::ActiveRecord::FilterReflection.call(
|
|
@@ -119,56 +121,87 @@ describe ThinkingSphinx::ActiveRecord::FilterReflection do
|
|
|
119
121
|
)
|
|
120
122
|
end
|
|
121
123
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
if ActiveRecord::VERSION::STRING.to_f < 4.0
|
|
125
|
+
it "sets conditions if there are none" do
|
|
126
|
+
expect(reflection_klass).to receive(:new) do |macro, name, options, parent|
|
|
127
|
+
expect(options[:conditions]).to eq("::ts_join_alias::.\"foo_type\" = 'Bar'")
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
ThinkingSphinx::ActiveRecord::FilterReflection.call(
|
|
131
|
+
reflection, 'foo_bar', 'Bar'
|
|
132
|
+
)
|
|
125
133
|
end
|
|
126
134
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
)
|
|
130
|
-
end unless defined?(ActiveRecord::Reflection::MacroReflection)
|
|
135
|
+
it "appends to the conditions array" do
|
|
136
|
+
options[:conditions] = ['existing']
|
|
131
137
|
|
|
132
|
-
|
|
133
|
-
|
|
138
|
+
expect(reflection_klass).to receive(:new) do |macro, name, options, parent|
|
|
139
|
+
expect(options[:conditions]).to eq(['existing', "::ts_join_alias::.\"foo_type\" = 'Bar'"])
|
|
140
|
+
end
|
|
134
141
|
|
|
135
|
-
|
|
136
|
-
|
|
142
|
+
ThinkingSphinx::ActiveRecord::FilterReflection.call(
|
|
143
|
+
reflection, 'foo_bar', 'Bar'
|
|
144
|
+
)
|
|
137
145
|
end
|
|
138
146
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
)
|
|
142
|
-
end unless defined?(ActiveRecord::Reflection::MacroReflection)
|
|
147
|
+
it "extends the conditions hash" do
|
|
148
|
+
options[:conditions] = {:x => :y}
|
|
143
149
|
|
|
144
|
-
|
|
145
|
-
|
|
150
|
+
expect(reflection_klass).to receive(:new) do |macro, name, options, parent|
|
|
151
|
+
expect(options[:conditions]).to eq({:x => :y, :foo_type => 'Bar'})
|
|
152
|
+
end
|
|
146
153
|
|
|
147
|
-
|
|
148
|
-
|
|
154
|
+
ThinkingSphinx::ActiveRecord::FilterReflection.call(
|
|
155
|
+
reflection, 'foo_bar', 'Bar'
|
|
156
|
+
)
|
|
149
157
|
end
|
|
150
158
|
|
|
159
|
+
it "appends to the conditions string" do
|
|
160
|
+
options[:conditions] = 'existing'
|
|
161
|
+
|
|
162
|
+
expect(reflection_klass).to receive(:new) do |macro, name, options, parent|
|
|
163
|
+
expect(options[:conditions]).to eq("existing AND ::ts_join_alias::.\"foo_type\" = 'Bar'")
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
ThinkingSphinx::ActiveRecord::FilterReflection.call(
|
|
167
|
+
reflection, 'foo_bar', 'Bar'
|
|
168
|
+
)
|
|
169
|
+
end
|
|
170
|
+
else
|
|
171
|
+
it "does not add a conditions option" do
|
|
172
|
+
expected_reflection_arguments do |wrapper|
|
|
173
|
+
expect(wrapper.options.keys).not_to include(:conditions)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
ThinkingSphinx::ActiveRecord::FilterReflection.call(
|
|
177
|
+
reflection, 'foo_bar', 'Bar'
|
|
178
|
+
)
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
it "includes custom behaviour in the subclass" do
|
|
183
|
+
expect(subclass).to receive(:include).with(ThinkingSphinx::ActiveRecord::Depolymorph::OverriddenReflection::BuildJoinConstraint)
|
|
184
|
+
|
|
151
185
|
ThinkingSphinx::ActiveRecord::FilterReflection.call(
|
|
152
186
|
reflection, 'foo_bar', 'Bar'
|
|
153
187
|
)
|
|
154
|
-
end
|
|
188
|
+
end if ActiveRecord::VERSION::STRING.to_f > 5.1
|
|
155
189
|
|
|
156
|
-
it "
|
|
157
|
-
|
|
190
|
+
it "includes custom behaviour in the subclass" do
|
|
191
|
+
allow(reflection).to receive(:respond_to?).with(:build_join_constraint).
|
|
192
|
+
and_return(false)
|
|
158
193
|
|
|
159
|
-
|
|
160
|
-
options[:conditions].should == "existing AND ::ts_join_alias::.\"foo_type\" = 'Bar'"
|
|
161
|
-
end
|
|
194
|
+
expect(subclass).to receive(:include).with(ThinkingSphinx::ActiveRecord::Depolymorph::OverriddenReflection::JoinScope)
|
|
162
195
|
|
|
163
196
|
ThinkingSphinx::ActiveRecord::FilterReflection.call(
|
|
164
197
|
reflection, 'foo_bar', 'Bar'
|
|
165
198
|
)
|
|
166
|
-
end
|
|
199
|
+
end if ActiveRecord::VERSION::STRING.to_f >= 6.0
|
|
167
200
|
|
|
168
201
|
it "returns the new reflection" do
|
|
169
|
-
ThinkingSphinx::ActiveRecord::FilterReflection.call(
|
|
202
|
+
expect(ThinkingSphinx::ActiveRecord::FilterReflection.call(
|
|
170
203
|
reflection, 'foo_bar', 'Bar'
|
|
171
|
-
).
|
|
204
|
+
)).to eq(filtered_reflection)
|
|
172
205
|
end
|
|
173
206
|
end
|
|
174
207
|
end
|