-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add related links A/A test to all routes
This commit adds a new concern `AATestable`, which will be used to run an A/A test to determine variance in our metrics and help guide metrics to use for upcoming A/B tests on related links. Solo: @karlbaker02
- Loading branch information
Karl Baker
committed
Jan 17, 2019
1 parent
0c98ecc
commit dba19d4
Showing
5 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module AATestable | ||
RELATED_LINKS_DIMENSION = 65 | ||
|
||
def self.included(base) | ||
base.helper_method( | ||
:related_links_variant | ||
) | ||
base.after_action :set_test_response_header | ||
end | ||
|
||
def related_links_variant | ||
@related_links_variant ||= related_links_test.requested_variant(request.headers) | ||
end | ||
|
||
private | ||
|
||
def related_links_test | ||
@related_links_test ||= GovukAbTesting::AbTest.new( | ||
"RelatedLinksAATest", | ||
dimension: RELATED_LINKS_DIMENSION, | ||
allowed_variants: %w(A B), | ||
control_variant: "A" | ||
) | ||
end | ||
|
||
def set_test_response_header | ||
related_links_variant.configure_response(response) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'test_helper' | ||
|
||
class DevelopmentControllerTest < ActionController::TestCase | ||
include GovukAbTesting::MinitestHelpers | ||
|
||
%w(A B).each do |test_variant| | ||
test "RelatedLinksAATest works correctly for each variant (variant: #{test_variant})" do | ||
with_variant RelatedLinksAATest: test_variant do | ||
get :index | ||
|
||
ab_test = @controller.send(:related_links_test) | ||
requested = ab_test.requested_variant(request.headers) | ||
assert requested.variant?(test_variant) | ||
end | ||
end | ||
end | ||
end |