diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8560fb10..e3a5568c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-01-10 10:49:28 UTC using RuboCop version 1.27.0. +# on 2024-04-08 13:44:25 UTC using RuboCop version 1.27.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -67,7 +67,7 @@ Lint/UnusedMethodArgument: Exclude: - 'lib/meilisearch-rails.rb' -# Offense count: 11 +# Offense count: 12 # Configuration parameters: IgnoredMethods, CountRepeatedAttributes. Metrics/AbcSize: Max: 104 @@ -81,14 +81,14 @@ Metrics/BlockLength: # Offense count: 1 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 156 + Max: 157 # Offense count: 8 # Configuration parameters: IgnoredMethods. Metrics/CyclomaticComplexity: Max: 27 -# Offense count: 16 +# Offense count: 18 # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. Metrics/MethodLength: Max: 103 @@ -128,13 +128,7 @@ RSpec/BeforeAfterAll: Exclude: - 'spec/integration_spec.rb' -# Offense count: 7 -# Configuration parameters: IgnoredMetadata. -RSpec/DescribeClass: - Exclude: - - 'spec/integration_spec.rb' - -# Offense count: 46 +# Offense count: 56 # Configuration parameters: CountAsOne. RSpec/ExampleLength: Max: 19 @@ -154,24 +148,11 @@ RSpec/InstanceVariable: Exclude: - 'spec/integration_spec.rb' -# Offense count: 1 -# Configuration parameters: EnforcedStyle. -# SupportedStyles: have_received, receive -RSpec/MessageSpies: - Exclude: - - 'spec/integration_spec.rb' - # Offense count: 1 RSpec/MultipleDescribes: Exclude: - 'spec/integration_spec.rb' -# Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). -RSpec/MultipleSubjects: - Exclude: - - 'spec/ms_clean_up_job_spec.rb' - # Offense count: 1 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: @@ -231,7 +212,7 @@ Style/OptionalBooleanParameter: Exclude: - 'lib/meilisearch-rails.rb' -# Offense count: 13 +# Offense count: 11 # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes @@ -248,7 +229,7 @@ Style/TrailingCommaInArguments: Exclude: - 'spec/integration_spec.rb' -# Offense count: 19 +# Offense count: 20 # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https diff --git a/README.md b/README.md index a58b750c..f0a38b67 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,7 @@ class Book < ApplicationRecord crop_length 10 faceting max_values_per_facet: 2000 pagination max_total_hits: 1000 + proximity_precision 'byWord' end end ``` diff --git a/lib/meilisearch-rails.rb b/lib/meilisearch-rails.rb index 151bbc1e..622843d0 100644 --- a/lib/meilisearch-rails.rb +++ b/lib/meilisearch-rails.rb @@ -67,6 +67,7 @@ class IndexSettings pagination faceting typo_tolerance + proximity_precision ].freeze CAMELIZE_OPTIONS = %i[pagination faceting typo_tolerance].freeze diff --git a/spec/integration_spec.rb b/spec/integration_spec.rb index f14aa418..0cfa8af9 100644 --- a/spec/integration_spec.rb +++ b/spec/integration_spec.rb @@ -1235,3 +1235,39 @@ def self.name end end end + +describe 'proximity_precision' do + before do + stub_const( + 'OtherColor', + Class.new do + include ActiveModel::Model + include MeiliSearch::Rails + end + ) + end + + context 'when the value is byWord' do + before do + OtherColor.meilisearch synchronize: true, index_uid: safe_index_uid('OtherColors') do + proximity_precision 'byWord' + end + end + + it 'sets the value byWord to proximity precision' do + expect(OtherColor.index.get_settings['proximityPrecision']).to eq('byWord') + end + end + + context 'when the value is byAttribute' do + before do + OtherColor.meilisearch synchronize: true, index_uid: safe_index_uid('OtherColors') do + proximity_precision 'byAttribute' + end + end + + it 'sets the value byAttribute to proximity precision' do + expect(OtherColor.index.get_settings['proximityPrecision']).to eq('byAttribute') + end + end +end