ensure string is passed to truncate since errors with integers #3131
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relates to having tests pass with Blacklight 8 (specially 8.3).
For 8.3, the following test is failing:
rspec ./spec/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb_spec.rb:48 # spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb without a primary caption falls back to the regular document title for the caption
The reason appears to be when the truncate method is passed an integer, e.g. truncate(1, length:95), it throws an error. However, truncate("1", length:95) will work just fine. Adding a "to_s" ensures the caption text truncation does not throw an error.
This test should still pass in Blacklight 7.
How to test with Blacklight 8: Generate test app (.internal_test_app). Update the internal test app's Gemfile to use Blacklight 8.3. Run bundle install for the internal test app. Then run rspec ./spec/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb_spec.rb:48.
Relates to #3047 and this comment which includes a checklist of tests to fix: #3047 (comment)