govuk_navigation_helpers 7.4.0 → 7.5.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6342b8057599155775feea0d29e377fafae68f9d
|
4
|
+
data.tar.gz: 5f95e172f522d070d14bb76a6555326202c5d0bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79180366cbb2fc58cbbc16032823e329fbb151e732ef6ed3932f273550307552f4fb1418816e9eafa0428fe2a64ba728e7dcf4e23033d94935317ebbaebfa24b
|
7
|
+
data.tar.gz: 1004a1758e916b0b1e7818067ff9e0002c69718afe27bd99435b3a6531ee9caf4656584074eeed715658b797ca79f38b8ac0a0d9a08a7be7cc93c2410550570e
|
data/CHANGELOG.md
CHANGED
@@ -39,16 +39,20 @@ module GovukNavigationHelpers
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def show_tasklist_sidebar?
|
42
|
-
sidebar_variant.variant?('B')
|
42
|
+
sidebar_variant.variant?('B') && is_tested_page?
|
43
43
|
end
|
44
44
|
|
45
45
|
def show_tasklist_header?
|
46
|
-
header_variant.variant?('B')
|
46
|
+
header_variant.variant?('B') && is_tested_page?
|
47
|
+
end
|
48
|
+
|
49
|
+
def is_tested_page?
|
50
|
+
return current_tasklist.is_page_included_in_ab_test? if current_tasklist
|
47
51
|
end
|
48
52
|
|
49
53
|
def set_response_header(response)
|
50
|
-
sidebar_variant.configure_response(response) if
|
51
|
-
header_variant.configure_response(response) if
|
54
|
+
sidebar_variant.configure_response(response) if is_tested_page?
|
55
|
+
header_variant.configure_response(response) if is_tested_page?
|
52
56
|
end
|
53
57
|
|
54
58
|
def publication_with_sidebar?
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module GovukNavigationHelpers
|
4
|
+
RSpec.describe CurrentTasklistAbTest do
|
5
|
+
let(:tasklist) { TasklistContent.current_tasklist('/vehicles-can-drive') }
|
6
|
+
|
7
|
+
it "indicates when to show the task list components" do
|
8
|
+
request = double('request', headers: {
|
9
|
+
'HTTP_GOVUK_ABTEST_TASKLISTSIDEBAR' => 'B',
|
10
|
+
'HTTP_GOVUK_ABTEST_TASKLISTHEADER' => 'B'
|
11
|
+
})
|
12
|
+
ab_test = described_class.new(current_tasklist: tasklist, request: request)
|
13
|
+
expect(ab_test.show_tasklist_sidebar?).to be true
|
14
|
+
expect(ab_test.show_tasklist_header?).to be true
|
15
|
+
end
|
16
|
+
|
17
|
+
it "indicates when to not show the task list components" do
|
18
|
+
request = double('request', headers: {
|
19
|
+
'HTTP_GOVUK_ABTEST_TASKLISTSIDEBAR' => 'A',
|
20
|
+
'HTTP_GOVUK_ABTEST_TASKLISTHEADER' => 'A'
|
21
|
+
})
|
22
|
+
ab_test = described_class.new(current_tasklist: tasklist, request: request)
|
23
|
+
expect(ab_test.show_tasklist_sidebar?).to be false
|
24
|
+
expect(ab_test.show_tasklist_header?).to be false
|
25
|
+
end
|
26
|
+
|
27
|
+
it "copes with a mixture when to not show the task list components" do
|
28
|
+
request = double('request', headers: {
|
29
|
+
'HTTP_GOVUK_ABTEST_TASKLISTSIDEBAR' => 'B',
|
30
|
+
'HTTP_GOVUK_ABTEST_TASKLISTHEADER' => 'A'
|
31
|
+
})
|
32
|
+
ab_test = described_class.new(current_tasklist: tasklist, request: request)
|
33
|
+
expect(ab_test.show_tasklist_sidebar?).to be true
|
34
|
+
expect(ab_test.show_tasklist_header?).to be false
|
35
|
+
end
|
36
|
+
|
37
|
+
it "configures the response vary header correctly " do
|
38
|
+
request = double('request', headers: {
|
39
|
+
'HTTP_GOVUK_ABTEST_TASKLISTSIDEBAR' => 'A',
|
40
|
+
'HTTP_GOVUK_ABTEST_TASKLISTHEADER' => 'B'
|
41
|
+
})
|
42
|
+
response = double('response', headers: {})
|
43
|
+
ab_test = described_class.new(current_tasklist: tasklist, request: request)
|
44
|
+
|
45
|
+
ab_test.set_response_header(response)
|
46
|
+
|
47
|
+
expect(response.headers["Vary"]).to eq("GOVUK-ABTest-TaskListSidebar, GOVUK-ABTest-TaskListHeader")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "configures the response vary header correctly when the page is not under test" do
|
51
|
+
request = double('request', headers: {
|
52
|
+
'HTTP_GOVUK_ABTEST_TASKLISTSIDEBAR' => 'A',
|
53
|
+
'HTTP_GOVUK_ABTEST_TASKLISTHEADER' => 'B'
|
54
|
+
})
|
55
|
+
response = double('response', headers: {})
|
56
|
+
tasklist = TasklistContent.current_tasklist("/not_under_test")
|
57
|
+
ab_test = described_class.new(current_tasklist: tasklist, request: request)
|
58
|
+
|
59
|
+
ab_test.set_response_header(response)
|
60
|
+
|
61
|
+
expect(response.headers["Vary"]).to be nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_navigation_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gds-api-adapters
|
@@ -217,6 +217,7 @@ files:
|
|
217
217
|
- lib/govuk_navigation_helpers/version.rb
|
218
218
|
- spec/breadcrumbs_spec.rb
|
219
219
|
- spec/content_item_spec.rb
|
220
|
+
- spec/current_tasklist_ab_test_spec.rb
|
220
221
|
- spec/related_items_spec.rb
|
221
222
|
- spec/related_navigation_sidebar_spec.rb
|
222
223
|
- spec/spec_helper.rb
|
@@ -250,6 +251,7 @@ summary: Gem to transform items from the content-store into payloads for GOV.UK
|
|
250
251
|
test_files:
|
251
252
|
- spec/breadcrumbs_spec.rb
|
252
253
|
- spec/content_item_spec.rb
|
254
|
+
- spec/current_tasklist_ab_test_spec.rb
|
253
255
|
- spec/related_items_spec.rb
|
254
256
|
- spec/related_navigation_sidebar_spec.rb
|
255
257
|
- spec/spec_helper.rb
|