-
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.
Return response headers for Explore AB test
At present we're only returning Vary response headers when we get a B variant. We want to do this all the time or it's confusing for Fastly to know how to cache. I've added a test that ensures (using the `with_variant` helper) that the header is being set correctly, and also checks for analytics set up. It's trickier to assert things about the template because slimmer's testing is harder to figure out right now, but it'd be useful to add these at some point too. :-)
- Loading branch information
Showing
4 changed files
with
54 additions
and
5 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
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,49 @@ | ||
require "test_helper" | ||
|
||
class ContentItemsControllerTest < ActionController::TestCase | ||
include GovukAbTesting::MinitestHelpers | ||
|
||
test "shows new header for variant B" do | ||
for_each_schema do |schema| | ||
with_variant ExploreMenuAbTestable: "B" do | ||
set_up_and_visit_content_item_for_schema(schema) | ||
|
||
assert_page_tracked_in_ab_test("ExploreMenuAbTestable", "B", 47) | ||
end | ||
end | ||
end | ||
|
||
test "doesn't show new header for variant A" do | ||
for_each_schema do |schema| | ||
with_variant ExploreMenuAbTestable: "A" do | ||
set_up_and_visit_content_item_for_schema(schema) | ||
|
||
assert_page_tracked_in_ab_test("ExploreMenuAbTestable", "A", 47) | ||
end | ||
end | ||
end | ||
|
||
test "doesn't show new header for variant Z" do | ||
for_each_schema do |schema| | ||
with_variant ExploreMenuAbTestable: "Z" do | ||
set_up_and_visit_content_item_for_schema(schema) | ||
|
||
assert_page_tracked_in_ab_test("ExploreMenuAbTestable", "Z", 47) | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_up_and_visit_content_item_for_schema(schema) | ||
content_item = content_store_has_schema_example(schema, schema) | ||
stub_content_store_has_item(content_item["base_path"], content_item) | ||
path = content_item["base_path"][1..] | ||
|
||
get :show, params: { path: path } | ||
end | ||
|
||
def for_each_schema(&block) | ||
%w[guide answer document_collection].each(&block) | ||
end | ||
end |