Skip to content

Conversation

@pfeiffer
Copy link
Contributor

This PR fixes the context in which the ignore_filter is called. This is needed when using the helper methods in a context of an eg. Rails helper.

To illustrate the difference:

Split.configure do |config|
  config.ignore_filter = ->(request) { puts "{request.class.to_s}" }
end

When calling ab_test in a controller, the output is:

<ActionDispatch::Request ...>

But when using ab_test in a helper, the output is:

<Class...>

This is especially funky due to Rails' delegation of eg. #headers, meaning that calling request.headers in the ignore_filter would have two different meanings - in helpers, it would call headers on the response, while in controllers it would call headers on the request (as intended)

This PR fixes the issue and should preserve backwards-compatibility (for methods with request as argument in the proc).

@andrew andrew merged commit 98ce553 into splitrb:master Aug 13, 2018
@andrew
Copy link
Member

andrew commented Aug 13, 2018

Thanks!

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.

2 participants