Skip to content

Commit d272c76

Browse files
committed
Move temporary AB test code to private method
1 parent f922de9 commit d272c76

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

app/controllers/content_items_controller.rb

+28-25
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,7 @@ class ContentItemsController < ApplicationController
2424
def show
2525
load_content_item
2626

27-
# TEMPORARY (author: richard.towers, expected end date: November 30 2023)
28-
# Content specific AB test for the Find your UTR number page
29-
placeholder = "{{ab_test_find_utr_number_video_links}}"
30-
if @content_item.base_path == "/find-utr-number" && @content_item.body.include?(placeholder)
31-
ab_test = GovukAbTesting::AbTest.new(
32-
"find_utr_number_video_links",
33-
dimension: 61, # https://docs.google.com/spreadsheets/d/1h4vGXzIbhOWwUzourPLIc8WM-iU1b6WYOVDOZxmU1Uo/edit#gid=254065189&range=69:69
34-
allowed_variants: %w[A B Z],
35-
control_variant: "Z",
36-
)
37-
@requested_variant = ab_test.requested_variant(request.headers)
38-
@requested_variant.configure_response(response)
39-
40-
replacement = case @requested_variant.variant_name
41-
when "A"
42-
I18n.t("ab_tests.find_utr_number_video_links.A")
43-
when "B"
44-
I18n.t("ab_tests.find_utr_number_video_links.B")
45-
else
46-
I18n.t("ab_tests.find_utr_number_video_links.Z")
47-
end
48-
@content_item.body.sub!(placeholder, replacement)
49-
end
50-
# /TEMPORARY
51-
27+
temporary_ab_test_find_utr_page
5228
set_expiry
5329

5430
if is_service_manual?
@@ -291,4 +267,31 @@ def csp_connect_src
291267

292268
@content_item.csp_connect_src
293269
end
270+
271+
# TEMPORARY (author: richard.towers, expected end date: February 2024)
272+
# Content specific AB test for the Find your UTR number page
273+
def temporary_ab_test_find_utr_page
274+
placeholder = "{{ab_test_find_utr_number_video_links}}"
275+
if @content_item.base_path == "/find-utr-number" && @content_item.body.include?(placeholder)
276+
ab_test = GovukAbTesting::AbTest.new(
277+
"find_utr_number_video_links",
278+
dimension: 61, # https://docs.google.com/spreadsheets/d/1h4vGXzIbhOWwUzourPLIc8WM-iU1b6WYOVDOZxmU1Uo/edit#gid=254065189&range=69:69
279+
allowed_variants: %w[A B Z],
280+
control_variant: "Z",
281+
)
282+
@requested_variant = ab_test.requested_variant(request.headers)
283+
@requested_variant.configure_response(response)
284+
285+
replacement = case @requested_variant.variant_name
286+
when "A"
287+
I18n.t("ab_tests.find_utr_number_video_links.A")
288+
when "B"
289+
I18n.t("ab_tests.find_utr_number_video_links.B")
290+
else
291+
I18n.t("ab_tests.find_utr_number_video_links.Z")
292+
end
293+
@content_item.body.sub!(placeholder, replacement)
294+
end
295+
end
296+
# /TEMPORARY
294297
end

0 commit comments

Comments
 (0)