Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test the adding of custom fields via LogStasher
The way LogStasher hooks into Rails makes it difficult to test that configured custom fields actually get added. It was tricky to find an approach to worked, wasn't too awkward and wasn't too tightly coupled to LogStasher. _Notes on some of the esoteric details of these new tests_ `append_info_to_payload`: This is a Rails instrumentation hook (intended for use by third parties). It's run during request handling and LogStasher uses it to "append" its default fields and any custom fields defined by our app. The visible effect in the context of this method and its caller is that those LogStasher fields are set on the `payload` hash that was supplied to the method. So, invoking this method is enough to simulate a controller action running for LogStasher's purposes. And, if the payload hash contains our custom field key (and value, when there is one), we've defined it successfully. `logstasher_add_custom_fields_to_payload`: If a Rails app has defined custom LogStasher fields (with `LogStasher.add_custom_fields`), LogStasher registers a listener with Rails that fires whenever a controller is loaded and that listener adds this method to the loaded controller. Therefore, if a newly-loaded controller has this method, one or more LogStasher custom fields have been defined successfully.
- Loading branch information