Skip to content

Commit d844281

Browse files
committed
test(fix): Fix failing tests and watch script
1 parent 0e5e36e commit d844281

File tree

7 files changed

+15
-12
lines changed

7 files changed

+15
-12
lines changed

Guardfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ guard :rspec, cmd: 'bundle exec rspec --color --format progress' do
66
watch(%r{^lib/(.+)\.rb$}) do |match|
77
"spec/#{match[1]}_spec.rb"
88
end
9-
watch(%r{^lib/jekyll/algolia/overwrites/(.+)\.rb$}) do
9+
watch(%r{^lib/jekyll/algolia/overwrites/jekyll-algolia-site\.rb$}) do
1010
'spec/jekyll-algolia_spec.rb'
1111
end
1212
watch('spec/spec_helper.rb') { 'spec' }

lib/errors/settings_manually_edited.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ W:algolia:
1313
W:  settings:
1414
{settings}
1515
I:
16-
I:If you'd like to revert to the default settings, the easiest way delete the indices and run `jekyll algolia` again.
16+
I:If you'd like to revert to the default settings, the easiest way is to delete the {index_name} index from your dashboard and run `jekyll algolia` again.
1717
I:

lib/jekyll/algolia/indexer.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ def self.warn_of_manual_dashboard_editing(changed_keys)
360360
end
361361
Logger.known_message(
362362
'settings_manually_edited',
363-
settings: yaml_lines.join("\n")
363+
settings: yaml_lines.join("\n"),
364+
index_name: Configurator.index_name
364365
)
365366
end
366367

lib/jekyll/algolia/overwrites/jekyll-algolia-site.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ def push
132132

133133
# Shrinking records to make them fit under 10Kb
134134
# We take into account the objectID that will be added in the form of:
135-
# "objectID": "i16cd998991cc40d92402b0b4e6c55e8a"
136-
object_id_attribute_length = 47
135+
# "objectID": "16cd998991cc40d92402b0b4e6c55e8a"
136+
object_id_attribute_length = 46
137137
max_file_size = 10_000 - object_id_attribute_length
138138
records.map! do |record|
139139
Shrinker.fit_to_size(record, max_file_size)

scripts/git_hooks/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ if ! git status --short | grep -q '\.rb$'; then
66
exit 0
77
fi
88

9-
# Match style guide
9+
rake test
1010
rake lint

spec/jekyll-algolia_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,24 +414,24 @@
414414
end
415415
end
416416

417-
describe 'shrink records to fit under 10Kb' do
417+
describe 'shrink records to fit under 10Kb, including room for objectID' do
418418
before do
419419
site.push
420420
end
421421

422422
it do
423423
expect(shrinker)
424424
.to have_received(:fit_to_size)
425-
.with({ name: 'foo1' }, 10_000)
425+
.with({ name: 'foo1' }, 9954)
426426
expect(shrinker)
427427
.to have_received(:fit_to_size)
428-
.with({ name: 'foo2' }, 10_000)
428+
.with({ name: 'foo2' }, 9954)
429429
expect(shrinker)
430430
.to have_received(:fit_to_size)
431-
.with({ name: 'bar1' }, 10_000)
431+
.with({ name: 'bar1' }, 9954)
432432
expect(shrinker)
433433
.to have_received(:fit_to_size)
434-
.with({ name: 'bar2' }, 10_000)
434+
.with({ name: 'bar2' }, 9954)
435435
end
436436
end
437437

spec/jekyll/algolia/indexer_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,7 @@
845845

846846
before do
847847
allow(logger).to receive(:known_message)
848+
allow(configurator).to receive(:index_name).and_return('my_index')
848849
current.warn_of_manual_dashboard_editing(changed_keys)
849850
end
850851

@@ -858,7 +859,8 @@
858859
"W:    customRanking:\n"\
859860
"W:      - foo\n"\
860861
"W:      - bar\n"\
861-
'W:      - baz'\
862+
'W:      - baz',
863+
index_name: 'my_index'
862864
)
863865
end
864866
end

0 commit comments

Comments
 (0)