Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure string is passed to truncate since errors with integers #3131

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

hudajkhan
Copy link
Contributor

@hudajkhan hudajkhan commented Sep 18, 2024

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)

@hudajkhan hudajkhan mentioned this pull request Sep 18, 2024
8 tasks
@jcoyne
Copy link
Member

jcoyne commented Sep 19, 2024

What causes the caption text to be an integer in the first place?

@cbeer
Copy link
Member

cbeer commented Sep 20, 2024

This might be an artifact of the test setup (falling back on an integer id field), but it's plausible (if not likely) that this could happen in reality.

@cbeer cbeer merged commit a372e01 into main Sep 20, 2024
7 checks passed
@cbeer cbeer deleted the bl8truncate branch September 20, 2024 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Blacklight 8
3 participants