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,22 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe ThinkingSphinx::Configuration do
|
|
4
6
|
let(:config) { ThinkingSphinx::Configuration.instance }
|
|
7
|
+
let(:use_load?) { ActiveRecord::VERSION::MAJOR > 5 }
|
|
8
|
+
let(:loading_object) { use_load? ? config : ActiveSupport::Dependencies }
|
|
9
|
+
let(:loading_method) { use_load? ? :load : :require_or_load }
|
|
5
10
|
|
|
6
11
|
after :each do
|
|
7
12
|
ThinkingSphinx::Configuration.reset
|
|
8
13
|
end
|
|
9
14
|
|
|
15
|
+
def expect_loading_of(file)
|
|
16
|
+
expect(loading_object).to receive(loading_method).with(file).once
|
|
17
|
+
end
|
|
18
|
+
|
|
10
19
|
describe '.instance' do
|
|
11
20
|
it "returns an instance of ThinkingSphinx::Configuration" do
|
|
12
|
-
ThinkingSphinx::Configuration.instance.
|
|
13
|
-
|
|
21
|
+
expect(ThinkingSphinx::Configuration.instance).
|
|
22
|
+
to be_a(ThinkingSphinx::Configuration)
|
|
14
23
|
end
|
|
15
24
|
|
|
16
25
|
it "memoizes the instance" do
|
|
17
26
|
config = double('configuration')
|
|
18
27
|
|
|
19
|
-
ThinkingSphinx::Configuration.
|
|
28
|
+
expect(ThinkingSphinx::Configuration).to receive(:new).once.and_return(config)
|
|
20
29
|
|
|
21
30
|
ThinkingSphinx::Configuration.instance
|
|
22
31
|
ThinkingSphinx::Configuration.instance
|
|
@@ -29,8 +38,13 @@ describe ThinkingSphinx::Configuration do
|
|
|
29
38
|
end
|
|
30
39
|
|
|
31
40
|
it 'does not cache settings after reset' do
|
|
32
|
-
File.
|
|
33
|
-
|
|
41
|
+
allow(File).to receive(:exist?).and_wrap_original do |original, path|
|
|
42
|
+
next true if path.to_s == File.absolute_path("config/thinking_sphinx.yml", Rails.root)
|
|
43
|
+
|
|
44
|
+
original.call(path)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
allow(File).to receive_messages :read => {
|
|
34
48
|
'test' => {'foo' => 'bugs'},
|
|
35
49
|
'production' => {'foo' => 'bar'}
|
|
36
50
|
}.to_yaml
|
|
@@ -38,33 +52,33 @@ describe ThinkingSphinx::Configuration do
|
|
|
38
52
|
ThinkingSphinx::Configuration.reset
|
|
39
53
|
# Grab a new copy of the instance.
|
|
40
54
|
config = ThinkingSphinx::Configuration.instance
|
|
41
|
-
config.settings['foo'].
|
|
55
|
+
expect(config.settings['foo']).to eq('bugs')
|
|
42
56
|
|
|
43
57
|
config.framework = double :environment => 'production', :root => Pathname.new(__FILE__).join('..', '..', 'internal')
|
|
44
|
-
config.settings['foo'].
|
|
58
|
+
expect(config.settings['foo']).to eq('bar')
|
|
45
59
|
end
|
|
46
60
|
end
|
|
47
61
|
|
|
48
62
|
describe '#configuration_file' do
|
|
49
63
|
it "uses the Rails environment in the configuration file name" do
|
|
50
|
-
config.configuration_file.
|
|
51
|
-
|
|
64
|
+
expect(config.configuration_file).
|
|
65
|
+
to eq(File.join(Rails.root, 'config', 'test.sphinx.conf'))
|
|
52
66
|
end
|
|
53
67
|
|
|
54
68
|
it "respects provided settings" do
|
|
55
69
|
write_configuration 'configuration_file' => '/path/to/foo.conf'
|
|
56
70
|
|
|
57
|
-
config.configuration_file.
|
|
71
|
+
expect(config.configuration_file).to eq('/path/to/foo.conf')
|
|
58
72
|
end
|
|
59
73
|
end
|
|
60
74
|
|
|
61
75
|
describe '#controller' do
|
|
62
76
|
it "returns an instance of Riddle::Controller" do
|
|
63
|
-
config.controller.
|
|
77
|
+
expect(config.controller).to be_a(Riddle::Controller)
|
|
64
78
|
end
|
|
65
79
|
|
|
66
80
|
it "memoizes the instance" do
|
|
67
|
-
Riddle::Controller.
|
|
81
|
+
expect(Riddle::Controller).to receive(:new).once.
|
|
68
82
|
and_return(double('controller'))
|
|
69
83
|
|
|
70
84
|
config.controller
|
|
@@ -74,19 +88,19 @@ describe ThinkingSphinx::Configuration do
|
|
|
74
88
|
it "sets the bin path from the thinking_sphinx.yml file" do
|
|
75
89
|
write_configuration('bin_path' => '/foo/bar/bin/')
|
|
76
90
|
|
|
77
|
-
config.controller.bin_path.
|
|
91
|
+
expect(config.controller.bin_path).to eq('/foo/bar/bin/')
|
|
78
92
|
end
|
|
79
93
|
|
|
80
94
|
it "appends a backslash to the bin_path if appropriate" do
|
|
81
95
|
write_configuration('bin_path' => '/foo/bar/bin')
|
|
82
96
|
|
|
83
|
-
config.controller.bin_path.
|
|
97
|
+
expect(config.controller.bin_path).to eq('/foo/bar/bin/')
|
|
84
98
|
end
|
|
85
99
|
end
|
|
86
100
|
|
|
87
101
|
describe '#index_paths' do
|
|
88
102
|
it "uses app/indices in the Rails app by default" do
|
|
89
|
-
config.index_paths.
|
|
103
|
+
expect(config.index_paths).to include(File.join(Rails.root, 'app', 'indices'))
|
|
90
104
|
end
|
|
91
105
|
|
|
92
106
|
it "uses app/indices in the Rails engines" do
|
|
@@ -95,22 +109,69 @@ describe ThinkingSphinx::Configuration do
|
|
|
95
109
|
} }
|
|
96
110
|
engine_class = double :instance => engine
|
|
97
111
|
|
|
98
|
-
Rails::Engine.
|
|
112
|
+
expect(Rails::Engine).to receive(:subclasses).and_return([ engine_class ])
|
|
99
113
|
|
|
100
|
-
config.index_paths.
|
|
114
|
+
expect(config.index_paths).to include('/engine/app/indices')
|
|
101
115
|
end
|
|
102
116
|
end
|
|
103
117
|
|
|
104
118
|
describe '#indices_location' do
|
|
105
119
|
it "stores index files in db/sphinx/ENVIRONMENT" do
|
|
106
|
-
config.indices_location.
|
|
107
|
-
|
|
120
|
+
expect(config.indices_location).
|
|
121
|
+
to eq(File.join(Rails.root, 'db', 'sphinx', 'test'))
|
|
108
122
|
end
|
|
109
123
|
|
|
110
124
|
it "respects provided settings" do
|
|
111
125
|
write_configuration 'indices_location' => '/my/index/files'
|
|
112
126
|
|
|
113
|
-
config.indices_location.
|
|
127
|
+
expect(config.indices_location).to eq('/my/index/files')
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it "respects relative paths" do
|
|
131
|
+
write_configuration 'indices_location' => 'my/index/files'
|
|
132
|
+
|
|
133
|
+
expect(config.indices_location).to eq('my/index/files')
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it "translates relative paths to absolute if config requests it" do
|
|
137
|
+
write_configuration(
|
|
138
|
+
'indices_location' => 'my/index/files',
|
|
139
|
+
'absolute_paths' => true
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
expect(config.indices_location).to eq(
|
|
143
|
+
File.join(config.framework.root, 'my/index/files')
|
|
144
|
+
)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it "respects paths that are already absolute" do
|
|
148
|
+
write_configuration(
|
|
149
|
+
'indices_location' => '/my/index/files',
|
|
150
|
+
'absolute_paths' => true
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
expect(config.indices_location).to eq('/my/index/files')
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
it "translates linked directories" do
|
|
157
|
+
write_configuration(
|
|
158
|
+
'indices_location' => 'mine/index/files',
|
|
159
|
+
'absolute_paths' => true
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
framework = ThinkingSphinx::Frameworks.current
|
|
163
|
+
local_path = File.join framework.root, "mine"
|
|
164
|
+
linked_path = File.join framework.root, "my"
|
|
165
|
+
|
|
166
|
+
FileUtils.mkdir_p linked_path
|
|
167
|
+
`ln -s #{linked_path} #{local_path}`
|
|
168
|
+
|
|
169
|
+
expect(config.indices_location).to eq(
|
|
170
|
+
File.join(config.framework.root, "my/index/files")
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
FileUtils.rm_rf local_path
|
|
174
|
+
FileUtils.rm_rf linked_path
|
|
114
175
|
end
|
|
115
176
|
end
|
|
116
177
|
|
|
@@ -120,30 +181,30 @@ describe ThinkingSphinx::Configuration do
|
|
|
120
181
|
end
|
|
121
182
|
|
|
122
183
|
it "sets the daemon pid file within log for the Rails app" do
|
|
123
|
-
config.searchd.pid_file.
|
|
124
|
-
|
|
184
|
+
expect(config.searchd.pid_file).
|
|
185
|
+
to eq(File.join(Rails.root, 'log', 'test.sphinx.pid'))
|
|
125
186
|
end
|
|
126
187
|
|
|
127
188
|
it "sets the daemon log within log for the Rails app" do
|
|
128
|
-
config.searchd.log.
|
|
129
|
-
|
|
189
|
+
expect(config.searchd.log).
|
|
190
|
+
to eq(File.join(Rails.root, 'log', 'test.searchd.log'))
|
|
130
191
|
end
|
|
131
192
|
|
|
132
193
|
it "sets the query log within log for the Rails app" do
|
|
133
|
-
config.searchd.query_log.
|
|
134
|
-
|
|
194
|
+
expect(config.searchd.query_log).
|
|
195
|
+
to eq(File.join(Rails.root, 'log', 'test.searchd.query.log'))
|
|
135
196
|
end
|
|
136
197
|
|
|
137
198
|
it "sets indexer settings if within thinking_sphinx.yml" do
|
|
138
199
|
write_configuration 'mem_limit' => '128M'
|
|
139
200
|
|
|
140
|
-
config.indexer.mem_limit.
|
|
201
|
+
expect(config.indexer.mem_limit).to eq('128M')
|
|
141
202
|
end
|
|
142
203
|
|
|
143
204
|
it "sets searchd settings if within thinking_sphinx.yml" do
|
|
144
205
|
write_configuration 'workers' => 'none'
|
|
145
206
|
|
|
146
|
-
config.searchd.workers.
|
|
207
|
+
expect(config.searchd.workers).to eq('none')
|
|
147
208
|
end
|
|
148
209
|
|
|
149
210
|
it 'adds settings to indexer without common section' do
|
|
@@ -164,18 +225,18 @@ describe ThinkingSphinx::Configuration do
|
|
|
164
225
|
let(:reference) { double('reference') }
|
|
165
226
|
|
|
166
227
|
it "starts at 0" do
|
|
167
|
-
config.next_offset(reference).
|
|
228
|
+
expect(config.next_offset(reference)).to eq(0)
|
|
168
229
|
end
|
|
169
230
|
|
|
170
231
|
it "increments for each new reference" do
|
|
171
|
-
config.next_offset(double('reference')).
|
|
172
|
-
config.next_offset(double('reference')).
|
|
173
|
-
config.next_offset(double('reference')).
|
|
232
|
+
expect(config.next_offset(double('reference'))).to eq(0)
|
|
233
|
+
expect(config.next_offset(double('reference'))).to eq(1)
|
|
234
|
+
expect(config.next_offset(double('reference'))).to eq(2)
|
|
174
235
|
end
|
|
175
236
|
|
|
176
237
|
it "doesn't increment for recorded references" do
|
|
177
|
-
config.next_offset(reference).
|
|
178
|
-
config.next_offset(reference).
|
|
238
|
+
expect(config.next_offset(reference)).to eq(0)
|
|
239
|
+
expect(config.next_offset(reference)).to eq(0)
|
|
179
240
|
end
|
|
180
241
|
end
|
|
181
242
|
|
|
@@ -190,9 +251,9 @@ describe ThinkingSphinx::Configuration do
|
|
|
190
251
|
it "searches each index path for ruby files" do
|
|
191
252
|
config.index_paths.replace ['/path/to/indices', '/path/to/other/indices']
|
|
192
253
|
|
|
193
|
-
Dir.
|
|
254
|
+
expect(Dir).to receive(:[]).with('/path/to/indices/**/*.rb').once.
|
|
194
255
|
and_return([])
|
|
195
|
-
Dir.
|
|
256
|
+
expect(Dir).to receive(:[]).with('/path/to/other/indices/**/*.rb').once.
|
|
196
257
|
and_return([])
|
|
197
258
|
|
|
198
259
|
config.preload_indices
|
|
@@ -200,37 +261,33 @@ describe ThinkingSphinx::Configuration do
|
|
|
200
261
|
|
|
201
262
|
it "loads each file returned" do
|
|
202
263
|
config.index_paths.replace ['/path/to/indices']
|
|
203
|
-
Dir.
|
|
264
|
+
allow(Dir).to receive_messages :[] => [
|
|
204
265
|
'/path/to/indices/foo_index.rb',
|
|
205
266
|
'/path/to/indices/bar_index.rb'
|
|
206
267
|
]
|
|
207
268
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
ActiveSupport::Dependencies.should_receive(:require_or_load).
|
|
211
|
-
with('/path/to/indices/bar_index.rb').once
|
|
269
|
+
expect_loading_of('/path/to/indices/foo_index.rb')
|
|
270
|
+
expect_loading_of('/path/to/indices/bar_index.rb')
|
|
212
271
|
|
|
213
272
|
config.preload_indices
|
|
214
273
|
end
|
|
215
274
|
|
|
216
275
|
it "does not double-load indices" do
|
|
217
276
|
config.index_paths.replace ['/path/to/indices']
|
|
218
|
-
Dir.
|
|
277
|
+
allow(Dir).to receive_messages :[] => [
|
|
219
278
|
'/path/to/indices/foo_index.rb',
|
|
220
279
|
'/path/to/indices/bar_index.rb'
|
|
221
280
|
]
|
|
222
281
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
ActiveSupport::Dependencies.should_receive(:require_or_load).
|
|
226
|
-
with('/path/to/indices/bar_index.rb').once
|
|
282
|
+
expect_loading_of('/path/to/indices/foo_index.rb')
|
|
283
|
+
expect_loading_of('/path/to/indices/bar_index.rb')
|
|
227
284
|
|
|
228
285
|
config.preload_indices
|
|
229
286
|
config.preload_indices
|
|
230
287
|
end
|
|
231
288
|
|
|
232
289
|
it 'adds distributed indices' do
|
|
233
|
-
distributor.
|
|
290
|
+
expect(distributor).to receive(:reconcile)
|
|
234
291
|
|
|
235
292
|
config.preload_indices
|
|
236
293
|
end
|
|
@@ -238,7 +295,7 @@ describe ThinkingSphinx::Configuration do
|
|
|
238
295
|
it 'does not add distributed indices if disabled' do
|
|
239
296
|
write_configuration('distributed_indices' => false)
|
|
240
297
|
|
|
241
|
-
distributor.
|
|
298
|
+
expect(distributor).not_to receive(:reconcile)
|
|
242
299
|
|
|
243
300
|
config.preload_indices
|
|
244
301
|
end
|
|
@@ -246,15 +303,15 @@ describe ThinkingSphinx::Configuration do
|
|
|
246
303
|
|
|
247
304
|
describe '#render' do
|
|
248
305
|
before :each do
|
|
249
|
-
config.searchd.
|
|
306
|
+
allow(config.searchd).to receive_messages :render => 'searchd { }'
|
|
250
307
|
end
|
|
251
308
|
|
|
252
309
|
it "searches each index path for ruby files" do
|
|
253
310
|
config.index_paths.replace ['/path/to/indices', '/path/to/other/indices']
|
|
254
311
|
|
|
255
|
-
Dir.
|
|
312
|
+
expect(Dir).to receive(:[]).with('/path/to/indices/**/*.rb').once.
|
|
256
313
|
and_return([])
|
|
257
|
-
Dir.
|
|
314
|
+
expect(Dir).to receive(:[]).with('/path/to/other/indices/**/*.rb').once.
|
|
258
315
|
and_return([])
|
|
259
316
|
|
|
260
317
|
config.render
|
|
@@ -262,30 +319,26 @@ describe ThinkingSphinx::Configuration do
|
|
|
262
319
|
|
|
263
320
|
it "loads each file returned" do
|
|
264
321
|
config.index_paths.replace ['/path/to/indices']
|
|
265
|
-
Dir.
|
|
322
|
+
allow(Dir).to receive_messages :[] => [
|
|
266
323
|
'/path/to/indices/foo_index.rb',
|
|
267
324
|
'/path/to/indices/bar_index.rb'
|
|
268
325
|
]
|
|
269
326
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
ActiveSupport::Dependencies.should_receive(:require_or_load).
|
|
273
|
-
with('/path/to/indices/bar_index.rb').once
|
|
327
|
+
expect_loading_of('/path/to/indices/foo_index.rb')
|
|
328
|
+
expect_loading_of('/path/to/indices/bar_index.rb')
|
|
274
329
|
|
|
275
330
|
config.render
|
|
276
331
|
end
|
|
277
332
|
|
|
278
333
|
it "does not double-load indices" do
|
|
279
334
|
config.index_paths.replace ['/path/to/indices']
|
|
280
|
-
Dir.
|
|
335
|
+
allow(Dir).to receive_messages :[] => [
|
|
281
336
|
'/path/to/indices/foo_index.rb',
|
|
282
337
|
'/path/to/indices/bar_index.rb'
|
|
283
338
|
]
|
|
284
339
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
ActiveSupport::Dependencies.should_receive(:require_or_load).
|
|
288
|
-
with('/path/to/indices/bar_index.rb').once
|
|
340
|
+
expect_loading_of('/path/to/indices/foo_index.rb')
|
|
341
|
+
expect_loading_of('/path/to/indices/bar_index.rb')
|
|
289
342
|
|
|
290
343
|
config.preload_indices
|
|
291
344
|
config.preload_indices
|
|
@@ -293,70 +346,162 @@ describe ThinkingSphinx::Configuration do
|
|
|
293
346
|
end
|
|
294
347
|
|
|
295
348
|
describe '#render_to_file' do
|
|
296
|
-
let(:file)
|
|
297
|
-
let(:output)
|
|
349
|
+
let(:file) { double('file') }
|
|
350
|
+
let(:output) { config.render }
|
|
351
|
+
let(:skip_directories) { false }
|
|
298
352
|
|
|
299
353
|
before :each do
|
|
300
|
-
|
|
354
|
+
write_configuration('skip_directory_creation' => skip_directories)
|
|
355
|
+
|
|
356
|
+
allow(config.searchd).to receive_messages :render => 'searchd { }'
|
|
301
357
|
end
|
|
302
358
|
|
|
303
359
|
it "writes the rendered configuration to the file" do
|
|
304
360
|
config.configuration_file = '/path/to/file.config'
|
|
305
361
|
|
|
306
|
-
config.
|
|
362
|
+
expect(config).to receive(:open).with('/path/to/file.config', 'w').
|
|
307
363
|
and_yield(file)
|
|
308
|
-
file.
|
|
364
|
+
expect(file).to receive(:write).with(output)
|
|
309
365
|
|
|
310
366
|
config.render_to_file
|
|
311
367
|
end
|
|
312
368
|
|
|
313
369
|
it "creates a directory at the binlog_path" do
|
|
314
|
-
FileUtils.
|
|
315
|
-
config.
|
|
370
|
+
allow(FileUtils).to receive_messages :mkdir_p => true
|
|
371
|
+
allow(config).to receive_messages :searchd => double(:binlog_path => '/path/to/binlog')
|
|
316
372
|
|
|
317
|
-
FileUtils.
|
|
373
|
+
expect(FileUtils).to receive(:mkdir_p).with('/path/to/binlog')
|
|
318
374
|
|
|
319
375
|
config.render_to_file
|
|
320
376
|
end
|
|
321
377
|
|
|
322
378
|
it "skips creating a directory when the binlog_path is blank" do
|
|
323
|
-
|
|
324
|
-
|
|
379
|
+
allow(loading_object).to receive(loading_method)
|
|
380
|
+
|
|
381
|
+
allow(FileUtils).to receive_messages :mkdir_p => true
|
|
382
|
+
allow(config).to receive_messages :searchd => double(:binlog_path => '')
|
|
325
383
|
|
|
326
|
-
FileUtils.
|
|
384
|
+
expect(FileUtils).not_to receive(:mkdir_p)
|
|
327
385
|
|
|
328
386
|
config.render_to_file
|
|
329
387
|
end
|
|
388
|
+
|
|
389
|
+
context 'skipping directory creation' do
|
|
390
|
+
let(:skip_directories) { true }
|
|
391
|
+
|
|
392
|
+
it "skips creating a directory when flag is set" do
|
|
393
|
+
expect(FileUtils).not_to receive(:mkdir_p)
|
|
394
|
+
|
|
395
|
+
config.render_to_file
|
|
396
|
+
end
|
|
397
|
+
end
|
|
330
398
|
end
|
|
331
399
|
|
|
332
400
|
describe '#searchd' do
|
|
333
401
|
describe '#address' do
|
|
334
402
|
it "defaults to 127.0.0.1" do
|
|
335
|
-
config.searchd.address.
|
|
403
|
+
expect(config.searchd.address).to eq('127.0.0.1')
|
|
336
404
|
end
|
|
337
405
|
|
|
338
406
|
it "respects the address setting" do
|
|
339
407
|
write_configuration('address' => '10.11.12.13')
|
|
340
408
|
|
|
341
|
-
config.searchd.address.
|
|
409
|
+
expect(config.searchd.address).to eq('10.11.12.13')
|
|
342
410
|
end
|
|
343
411
|
end
|
|
344
412
|
|
|
413
|
+
describe '#log' do
|
|
414
|
+
it "defaults to an environment-specific file" do
|
|
415
|
+
expect(config.searchd.log).to eq(
|
|
416
|
+
File.join(config.framework.root, "log/test.searchd.log")
|
|
417
|
+
)
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
it "translates linked directories" do
|
|
421
|
+
framework = ThinkingSphinx::Frameworks.current
|
|
422
|
+
log_path = File.join framework.root, "log"
|
|
423
|
+
linked_path = File.join framework.root, "logging"
|
|
424
|
+
log_exists = File.exist? log_path
|
|
425
|
+
|
|
426
|
+
FileUtils.mv log_path, "#{log_path}-tmp" if log_exists
|
|
427
|
+
FileUtils.mkdir_p linked_path
|
|
428
|
+
`ln -s #{linked_path} #{log_path}`
|
|
429
|
+
|
|
430
|
+
expect(config.searchd.log).to eq(
|
|
431
|
+
File.join(config.framework.root, "logging/test.searchd.log")
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
FileUtils.rm log_path
|
|
435
|
+
FileUtils.rmdir linked_path
|
|
436
|
+
FileUtils.mv "#{log_path}-tmp", log_path if log_exists
|
|
437
|
+
end unless RUBY_PLATFORM == "java"
|
|
438
|
+
end
|
|
439
|
+
|
|
345
440
|
describe '#mysql41' do
|
|
346
441
|
it "defaults to 9306" do
|
|
347
|
-
config.searchd.mysql41.
|
|
442
|
+
expect(config.searchd.mysql41).to eq(9306)
|
|
348
443
|
end
|
|
349
444
|
|
|
350
445
|
it "respects the port setting" do
|
|
351
446
|
write_configuration('port' => 9313)
|
|
352
447
|
|
|
353
|
-
config.searchd.mysql41.
|
|
448
|
+
expect(config.searchd.mysql41).to eq(9313)
|
|
354
449
|
end
|
|
355
450
|
|
|
356
451
|
it "respects the mysql41 setting" do
|
|
357
452
|
write_configuration('mysql41' => 9307)
|
|
358
453
|
|
|
359
|
-
config.searchd.mysql41.
|
|
454
|
+
expect(config.searchd.mysql41).to eq(9307)
|
|
455
|
+
end
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
describe "#socket" do
|
|
459
|
+
it "does not set anything by default" do
|
|
460
|
+
expect(config.searchd.socket).to be_nil
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
it "ignores unspecified address and port when socket is set" do
|
|
464
|
+
write_configuration("socket" => "/my/socket")
|
|
465
|
+
|
|
466
|
+
expect(config.searchd.socket).to eq("/my/socket:mysql41")
|
|
467
|
+
expect(config.searchd.address).to be_nil
|
|
468
|
+
expect(config.searchd.mysql41).to be_nil
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
it "allows address and socket settings" do
|
|
472
|
+
write_configuration("socket" => "/my/socket", "address" => "1.1.1.1")
|
|
473
|
+
|
|
474
|
+
expect(config.searchd.socket).to eq("/my/socket:mysql41")
|
|
475
|
+
expect(config.searchd.address).to eq("1.1.1.1")
|
|
476
|
+
expect(config.searchd.mysql41).to eq(9306)
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
it "allows mysql41 and socket settings" do
|
|
480
|
+
write_configuration("socket" => "/my/socket", "mysql41" => 9307)
|
|
481
|
+
|
|
482
|
+
expect(config.searchd.socket).to eq("/my/socket:mysql41")
|
|
483
|
+
expect(config.searchd.address).to eq("127.0.0.1")
|
|
484
|
+
expect(config.searchd.mysql41).to eq(9307)
|
|
485
|
+
end
|
|
486
|
+
|
|
487
|
+
it "allows port and socket settings" do
|
|
488
|
+
write_configuration("socket" => "/my/socket", "port" => 9307)
|
|
489
|
+
|
|
490
|
+
expect(config.searchd.socket).to eq("/my/socket:mysql41")
|
|
491
|
+
expect(config.searchd.address).to eq("127.0.0.1")
|
|
492
|
+
expect(config.searchd.mysql41).to eq(9307)
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
it "allows address, mysql41 and socket settings" do
|
|
496
|
+
write_configuration(
|
|
497
|
+
"socket" => "/my/socket",
|
|
498
|
+
"address" => "1.2.3.4",
|
|
499
|
+
"mysql41" => 9307
|
|
500
|
+
)
|
|
501
|
+
|
|
502
|
+
expect(config.searchd.socket).to eq("/my/socket:mysql41")
|
|
503
|
+
expect(config.searchd.address).to eq("1.2.3.4")
|
|
504
|
+
expect(config.searchd.mysql41).to eq(9307)
|
|
360
505
|
end
|
|
361
506
|
end
|
|
362
507
|
end
|
|
@@ -364,66 +509,74 @@ describe ThinkingSphinx::Configuration do
|
|
|
364
509
|
describe '#settings' do
|
|
365
510
|
context 'YAML file exists' do
|
|
366
511
|
before :each do
|
|
367
|
-
File.
|
|
512
|
+
allow(File).to receive(:exist?).and_wrap_original do |original, path|
|
|
513
|
+
next true if path.to_s == File.absolute_path("config/thinking_sphinx.yml", Rails.root)
|
|
514
|
+
|
|
515
|
+
original.call(path)
|
|
516
|
+
end
|
|
368
517
|
end
|
|
369
518
|
|
|
370
519
|
it "reads from the YAML file" do
|
|
371
|
-
File.
|
|
520
|
+
expect(File).to receive(:read).and_return('')
|
|
372
521
|
|
|
373
522
|
config.settings
|
|
374
523
|
end
|
|
375
524
|
|
|
376
525
|
it "uses the settings for the given environment" do
|
|
377
|
-
File.
|
|
526
|
+
allow(File).to receive_messages :read => {
|
|
378
527
|
'test' => {'foo' => 'bar'},
|
|
379
528
|
'staging' => {'baz' => 'qux'}
|
|
380
529
|
}.to_yaml
|
|
381
|
-
Rails.
|
|
530
|
+
allow(Rails).to receive_messages :env => 'staging'
|
|
382
531
|
|
|
383
|
-
config.settings['baz'].
|
|
532
|
+
expect(config.settings['baz']).to eq('qux')
|
|
384
533
|
end
|
|
385
534
|
|
|
386
535
|
it "remembers the file contents" do
|
|
387
|
-
File.
|
|
536
|
+
expect(File).to receive(:read).and_return('')
|
|
388
537
|
|
|
389
538
|
config.settings
|
|
390
539
|
config.settings
|
|
391
540
|
end
|
|
392
541
|
|
|
393
|
-
it "returns
|
|
394
|
-
File.
|
|
395
|
-
Rails.
|
|
542
|
+
it "returns the default hash when no settings for the environment exist" do
|
|
543
|
+
allow(File).to receive_messages :read => {'test' => {'foo' => 'bar'}}.to_yaml
|
|
544
|
+
allow(Rails).to receive_messages :env => 'staging'
|
|
396
545
|
|
|
397
|
-
config.settings.
|
|
546
|
+
expect(config.settings.class).to eq(Hash)
|
|
398
547
|
end
|
|
399
548
|
end
|
|
400
549
|
|
|
401
550
|
context 'YAML file does not exist' do
|
|
402
551
|
before :each do
|
|
403
|
-
File.
|
|
552
|
+
allow(File).to receive(:exist?).and_wrap_original do |original, path|
|
|
553
|
+
next false if path.to_s == File.absolute_path("config/thinking_sphinx.yml", Rails.root)
|
|
554
|
+
|
|
555
|
+
original.call(path)
|
|
556
|
+
end
|
|
404
557
|
end
|
|
405
558
|
|
|
406
559
|
it "does not read the file" do
|
|
407
|
-
File.
|
|
560
|
+
expect(File).not_to receive(:read)
|
|
408
561
|
|
|
409
562
|
config.settings
|
|
410
563
|
end
|
|
411
564
|
|
|
412
|
-
it "returns
|
|
413
|
-
config.settings.
|
|
565
|
+
it "returns a hash" do
|
|
566
|
+
expect(config.settings.class).to eq(Hash)
|
|
414
567
|
end
|
|
415
568
|
end
|
|
416
569
|
end
|
|
417
570
|
|
|
418
571
|
describe '#version' do
|
|
419
|
-
it "defaults to 2.
|
|
420
|
-
config.version.
|
|
572
|
+
it "defaults to 2.2.11" do
|
|
573
|
+
expect(config.version).to eq('2.2.11')
|
|
421
574
|
end
|
|
422
575
|
|
|
423
576
|
it "respects supplied YAML versions" do
|
|
424
577
|
write_configuration 'version' => '2.0.4'
|
|
425
578
|
|
|
426
|
-
config.version.
|
|
579
|
+
expect(config.version).to eq('2.0.4')
|
|
427
580
|
end
|
|
428
581
|
end
|
|
429
582
|
end
|