Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Admin-only Search Fields #128
The Blacklight "SearchBuilder" is the object that creates the Solr query.
We want it to include certain Solr fields as search targets only if there is a logged in user, to make sure non-staff isn't searching over staff-only fields.
To do this, we needed features missing from BL 7, but added in BL 7.1.0.alpha, which we now use (hopefully 7.1.0 final soon).
We tell Blacklight that
And we give the SearchBuilder a very simple extension to, based on presence of current_user, add in search fields.
Tests: We test with system tests (end-to-end browser tests). While these are slow... it's difficult to set up Blacklight-related tests otherwise, especially with confidence they are really doing what's expected and not false positives due to wrong assumptions in test setup (or assumptions that become wrong). This is the easiest way to write tests that reliably let us know it's doing what's intended -- making sure only admins can search admin-protected fields.