* Update accept header for browser compatibility
Allows browser to display content as xml instead of plain text
Ref: https://stackoverflow.com/a/7001617/4397001
* Updated specs
Ruby 2.5 added the `Hash#slice` method which allowed Rails 5.2 [to not
apply][1] it's ActiveSupport core extension. Because the Ruby
implementation is done in C it [does not call the `[]` method][2] which
is overridden by [`Faraday::Utils::Headers`][3] to achieve case
insensitive header look ups.
By calling the `Faraday::Utils::Headers#[]` directly we keep the case
insensitive lookup.
[1]: a524c955bf
[2]: ae92a9e4ed/hash.c (L1357-L1375)
[3]: 4381c2d62d/lib/faraday/utils.rb (L51-L54)
The Agent did not use `interpolate_with` in it's `receive` method,
which lead to `interpolated[...]` calls in `send_message` and
`make_call` always returning empty strings.
The new `interpolate_with_each` helper iterates over an array of
objects and yields each object in a `interpolated_with(object)`
context.
Fixes#2186
Setting `array` to `true` for an extractor allows the extraction of list
elements into an array or when working with websites that have varying
amount of elements matching a specific selector:
Response A:
```html
<h1>header</h1>
<div id="content">
<div></div>
<div></div>
<div class="bogus"></div>
<div>
```
Response B:
```html
<h1>header</h1>
<div id="content">
<div></div>
<div></div>
<div class="bogus"></div>
<div></div>
<div>
```
The goal is to extract the header and all `div`s inside `#content` that
are not `.bogus` into one Event. Having the `array` option makes this
possible with `css: '#content div:not(.bogus) ', array: true` which
would otherwise fail with an uneven amount of matches exception.
Currently the work around would be the extract the header and `#content`
in one WebsiteAgent and extract the `div`s in a second Agent. This does
not work in my use case because the HTML inside `#content` is
malformatted and leads to Nokogiri paring errors.
Makes the Agent easier to use and to debug. It now verifies the API
token and auto completes the `chat_id`.
Log entries are only created on failure to avoid cluttering the Agent
log.
#2135
tl;dr: By using `e.currentTarget` instead of `e.target` we ensure to always
pass the `button` element to `Utils.handleDryRunButton`.
`target` refers to the actual element the user clicked on, we then
passed the glyphicon span to `Utils.handleDryRunButton` which requested
`window.location` via ajax because `$(button).data('action-url')` returned
`undefined`.
Evaluating the whole page then triggered
`Error: rails-ujs has already been loaded!`, as a result the user can not
interact with anything that requires `rails-ujs`, `jquery` or bootstrap
javascript.