diff --git a/Guardfile b/Guardfile index e0bf3a8..d5ba0be 100644 --- a/Guardfile +++ b/Guardfile @@ -6,7 +6,7 @@ guard :rspec, cmd: 'bundle exec rspec --color --format progress' do watch(%r{^lib/(.+)\.rb$}) do |match| "spec/#{match[1]}_spec.rb" end - watch(%r{^lib/jekyll/algolia/overwrites/(.+)\.rb$}) do + watch(%r{^lib/jekyll/algolia/overwrites/jekyll-algolia-site\.rb$}) do 'spec/jekyll-algolia_spec.rb' end watch('spec/spec_helper.rb') { 'spec' } diff --git a/lib/errors/settings_manually_edited.txt b/lib/errors/settings_manually_edited.txt index db7f983..5ed809f 100644 --- a/lib/errors/settings_manually_edited.txt +++ b/lib/errors/settings_manually_edited.txt @@ -13,5 +13,5 @@ W:algolia: W:  settings: {settings} I: -I:If you'd like to revert to the default settings, the easiest way delete the indices and run `jekyll algolia` again. +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. I: diff --git a/lib/jekyll/algolia/indexer.rb b/lib/jekyll/algolia/indexer.rb index 8bb731f..099e5bd 100644 --- a/lib/jekyll/algolia/indexer.rb +++ b/lib/jekyll/algolia/indexer.rb @@ -360,7 +360,8 @@ module Jekyll end Logger.known_message( 'settings_manually_edited', - settings: yaml_lines.join("\n") + settings: yaml_lines.join("\n"), + index_name: Configurator.index_name ) end diff --git a/lib/jekyll/algolia/overwrites/jekyll-algolia-site.rb b/lib/jekyll/algolia/overwrites/jekyll-algolia-site.rb index fdc62bd..b34ed2c 100644 --- a/lib/jekyll/algolia/overwrites/jekyll-algolia-site.rb +++ b/lib/jekyll/algolia/overwrites/jekyll-algolia-site.rb @@ -132,8 +132,8 @@ module Jekyll # Shrinking records to make them fit under 10Kb # We take into account the objectID that will be added in the form of: - # "objectID": "i16cd998991cc40d92402b0b4e6c55e8a" - object_id_attribute_length = 47 + # "objectID": "16cd998991cc40d92402b0b4e6c55e8a" + object_id_attribute_length = 46 max_file_size = 10_000 - object_id_attribute_length records.map! do |record| Shrinker.fit_to_size(record, max_file_size) diff --git a/scripts/git_hooks/pre-commit b/scripts/git_hooks/pre-commit index 35f4a8e..9c893ac 100755 --- a/scripts/git_hooks/pre-commit +++ b/scripts/git_hooks/pre-commit @@ -6,5 +6,5 @@ if ! git status --short | grep -q '\.rb$'; then exit 0 fi -# Match style guide +rake test rake lint diff --git a/spec/jekyll-algolia_spec.rb b/spec/jekyll-algolia_spec.rb index fff0c4a..9b02113 100644 --- a/spec/jekyll-algolia_spec.rb +++ b/spec/jekyll-algolia_spec.rb @@ -414,7 +414,7 @@ describe(Jekyll::Algolia) do end end - describe 'shrink records to fit under 10Kb' do + describe 'shrink records to fit under 10Kb, including room for objectID' do before do site.push end @@ -422,16 +422,16 @@ describe(Jekyll::Algolia) do it do expect(shrinker) .to have_received(:fit_to_size) - .with({ name: 'foo1' }, 10_000) + .with({ name: 'foo1' }, 9954) expect(shrinker) .to have_received(:fit_to_size) - .with({ name: 'foo2' }, 10_000) + .with({ name: 'foo2' }, 9954) expect(shrinker) .to have_received(:fit_to_size) - .with({ name: 'bar1' }, 10_000) + .with({ name: 'bar1' }, 9954) expect(shrinker) .to have_received(:fit_to_size) - .with({ name: 'bar2' }, 10_000) + .with({ name: 'bar2' }, 9954) end end diff --git a/spec/jekyll/algolia/indexer_spec.rb b/spec/jekyll/algolia/indexer_spec.rb index 0cb412b..aba257c 100644 --- a/spec/jekyll/algolia/indexer_spec.rb +++ b/spec/jekyll/algolia/indexer_spec.rb @@ -845,6 +845,7 @@ describe(Jekyll::Algolia::Indexer) do before do allow(logger).to receive(:known_message) + allow(configurator).to receive(:index_name).and_return('my_index') current.warn_of_manual_dashboard_editing(changed_keys) end @@ -858,7 +859,8 @@ describe(Jekyll::Algolia::Indexer) do "W:    customRanking:\n"\ "W:      - foo\n"\ "W:      - bar\n"\ - 'W:      - baz'\ + 'W:      - baz', + index_name: 'my_index' ) end end