-
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.
- Loading branch information
Showing
72 changed files
with
3,108 additions
and
1 deletion.
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,53 @@ | ||
module PopularTasksAbTestable | ||
extend ActiveSupport::Concern | ||
|
||
ALLOWED_VARIANTS = %w[A B C Z].freeze | ||
|
||
included do | ||
helper_method( | ||
:popular_tasks_variant, | ||
:popular_tasks_page_under_test?, | ||
:popular_tasks_variant_a_page?, | ||
:popular_tasks_variant_b_page?, | ||
:popular_tasks_variant_c_page?, | ||
:popular_tasks_variant_z_page?, | ||
) | ||
after_action :set_popular_tasks_ab_test_response_header | ||
end | ||
|
||
def popular_tasks_ab_test | ||
@popular_tasks_ab_test ||= GovukAbTesting::AbTest.new( | ||
"PopularTasks", | ||
allowed_variants: ALLOWED_VARIANTS, | ||
control_variant: "C", | ||
) | ||
end | ||
|
||
def popular_tasks_variant | ||
@popular_tasks_variant ||= popular_tasks_ab_test.requested_variant(request.headers) | ||
end | ||
|
||
def popular_tasks_page_under_test? | ||
request.path.starts_with?(%r{/browse/business|/browse/benefits}) | ||
end | ||
|
||
def set_popular_tasks_ab_test_response_header | ||
popular_tasks_variant.configure_response(response) if popular_tasks_page_under_test? | ||
end | ||
|
||
def popular_tasks_variant_a_page? | ||
popular_tasks_page_under_test? && popular_tasks_variant.variant?("A") | ||
end | ||
|
||
def popular_tasks_variant_b_page? | ||
popular_tasks_page_under_test? && popular_tasks_variant.variant?("B") | ||
end | ||
|
||
def popular_tasks_variant_c_page? | ||
popular_tasks_page_under_test? && popular_tasks_variant.variant?("C") | ||
end | ||
|
||
def popular_tasks_variant_z_page? | ||
popular_tasks_page_under_test? && popular_tasks_variant.variant?("Z") | ||
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
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
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
Oops, something went wrong.