Skip to content

Commit 84d355b

Browse files
committed
Merge test refactoring into main
New test has been added while PR #350 was being finished.
1 parent 121b989 commit 84d355b

File tree

11 files changed

+63
-39
lines changed

11 files changed

+63
-39
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ jobs:
3636
run: bundle exec rspec
3737
- name: Upload coverage reports to Codecov
3838
uses: codecov/codecov-action@v4
39-
env:
40-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
39+
if: matrix.ruby-version == '3.1' && matrix.rails-version == '7.0'
40+
with:
41+
token: ${{ secrets.CODECOV_TOKEN }}
4142

4243
linter_check:
4344
name: linter-check

.rubocop_todo.yml

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2024-01-10 10:49:28 UTC using RuboCop version 1.27.0.
3+
# on 2024-04-08 13:44:25 UTC using RuboCop version 1.27.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -67,7 +67,7 @@ Lint/UnusedMethodArgument:
6767
Exclude:
6868
- 'lib/meilisearch-rails.rb'
6969

70-
# Offense count: 11
70+
# Offense count: 12
7171
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
7272
Metrics/AbcSize:
7373
Max: 104
@@ -81,14 +81,14 @@ Metrics/BlockLength:
8181
# Offense count: 1
8282
# Configuration parameters: CountComments, CountAsOne.
8383
Metrics/ClassLength:
84-
Max: 156
84+
Max: 157
8585

8686
# Offense count: 8
8787
# Configuration parameters: IgnoredMethods.
8888
Metrics/CyclomaticComplexity:
8989
Max: 27
9090

91-
# Offense count: 16
91+
# Offense count: 18
9292
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
9393
Metrics/MethodLength:
9494
Max: 103
@@ -128,13 +128,7 @@ RSpec/BeforeAfterAll:
128128
Exclude:
129129
- 'spec/integration_spec.rb'
130130

131-
# Offense count: 7
132-
# Configuration parameters: IgnoredMetadata.
133-
RSpec/DescribeClass:
134-
Exclude:
135-
- 'spec/integration_spec.rb'
136-
137-
# Offense count: 46
131+
# Offense count: 56
138132
# Configuration parameters: CountAsOne.
139133
RSpec/ExampleLength:
140134
Max: 19
@@ -154,24 +148,11 @@ RSpec/InstanceVariable:
154148
Exclude:
155149
- 'spec/integration_spec.rb'
156150

157-
# Offense count: 1
158-
# Configuration parameters: EnforcedStyle.
159-
# SupportedStyles: have_received, receive
160-
RSpec/MessageSpies:
161-
Exclude:
162-
- 'spec/integration_spec.rb'
163-
164151
# Offense count: 1
165152
RSpec/MultipleDescribes:
166153
Exclude:
167154
- 'spec/integration_spec.rb'
168155

169-
# Offense count: 1
170-
# This cop supports safe auto-correction (--auto-correct).
171-
RSpec/MultipleSubjects:
172-
Exclude:
173-
- 'spec/ms_clean_up_job_spec.rb'
174-
175156
# Offense count: 1
176157
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
177158
RSpec/VerifiedDoubles:
@@ -231,7 +212,7 @@ Style/OptionalBooleanParameter:
231212
Exclude:
232213
- 'lib/meilisearch-rails.rb'
233214

234-
# Offense count: 13
215+
# Offense count: 11
235216
# This cop supports safe auto-correction (--auto-correct).
236217
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
237218
# SupportedStyles: single_quotes, double_quotes
@@ -248,7 +229,7 @@ Style/TrailingCommaInArguments:
248229
Exclude:
249230
- 'spec/integration_spec.rb'
250231

251-
# Offense count: 19
232+
# Offense count: 20
252233
# This cop supports safe auto-correction (--auto-correct).
253234
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
254235
# URISchemes: http, https

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ group :test do
3131
gem 'jdbc-sqlite3', platform: :jruby
3232
gem 'rspec', '~> 3.0'
3333
gem 'simplecov', require: 'false'
34-
gem 'codecov', require: 'false'
34+
gem 'simplecov-cobertura', require: 'false'
3535
gem 'threads'
3636

3737
gem 'byebug'

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ class Book < ApplicationRecord
207207
crop_length 10
208208
faceting max_values_per_facet: 2000
209209
pagination max_total_hits: 1000
210+
proximity_precision 'byWord'
210211
end
211212
end
212213
```
@@ -230,7 +231,7 @@ harry_book.formatted # => {"id"=>"1", "name"=>"<em>Harry</em> Potter", "descript
230231
👉 Don't forget that `attributes_to_highlight`, `attributes_to_crop`, and
231232
`crop_length` can be set up in the `meilisearch` block of your model.
232233

233-
## 🔍 Sorted search
234+
### 🔍 Sorted search
234235

235236
As an example of how to use the sort option, here is how you could achieve
236237
returning all books sorted by title in ascending order:

docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: "3.7"
2-
31
volumes:
42
bundle:
53
play_bundle:

lib/meilisearch-rails.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class IndexSettings
6767
pagination
6868
faceting
6969
typo_tolerance
70+
proximity_precision
7071
].freeze
7172

7273
CAMELIZE_OPTIONS = %i[pagination faceting typo_tolerance].freeze
@@ -588,7 +589,7 @@ def ms_entries_for(document:, synchronous:)
588589
ms_configurations.filter_map do |options, settings|
589590
{
590591
synchronous: synchronous || options[:synchronous],
591-
index_uid: options[:index_uid],
592+
index_uid: ms_index_uid(options),
592593
primary_key: primary_key
593594
}.with_indifferent_access unless ms_indexing_disabled?(options)
594595
end

lib/meilisearch/rails/multi_search/result.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def each_hit(&block)
3030
end
3131
alias each each_hit
3232

33-
def each_result
34-
@results.each
33+
def each_result(&block)
34+
@results.each(&block)
3535
end
3636

3737
def to_a

lib/meilisearch/rails/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module MeiliSearch
44
module Rails
5-
VERSION = '0.12.0'
5+
VERSION = '0.13.0'
66

77
def self.qualified_version
88
"Meilisearch Rails (v#{VERSION})"

spec/integration_spec.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,42 @@
2020
end
2121
end
2222

23+
describe 'proximity_precision' do
24+
before do
25+
stub_const(
26+
'OtherColor',
27+
Class.new do
28+
include ActiveModel::Model
29+
include MeiliSearch::Rails
30+
end
31+
)
32+
end
33+
34+
context 'when the value is byWord' do
35+
before do
36+
OtherColor.meilisearch synchronize: true, index_uid: safe_index_uid('OtherColors') do
37+
proximity_precision 'byWord'
38+
end
39+
end
40+
41+
it 'sets the value byWord to proximity precision' do
42+
AsyncHelper.await_last_task
43+
expect(OtherColor.index.get_settings['proximityPrecision']).to eq('byWord')
44+
end
45+
end
46+
47+
context 'when the value is byAttribute' do
48+
before do
49+
OtherColor.meilisearch synchronize: true, index_uid: safe_index_uid('OtherColors') do
50+
proximity_precision 'byAttribute'
51+
end
52+
end
53+
54+
it 'sets the value byAttribute to proximity precision' do
55+
OtherColor.index.get_settings # induce update_settings
56+
AsyncHelper.await_last_task
57+
expect(OtherColor.index.get_settings['proximityPrecision']).to eq('byAttribute')
58+
end
59+
end
60+
end
61+

spec/ms_clean_up_job_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def create_indexed_record
2323
end
2424

2525
let(:record_entries) do
26-
record.ms_entries(true).each { |h| h[:index_uid] += '_test' }
26+
record.ms_entries(true)
2727
end
2828

2929
let(:indexes) do

0 commit comments

Comments
 (0)