govuk_navigation_helpers 7.3.0 → 7.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module GovukNavigationHelpers
2
- VERSION = "7.3.0".freeze
2
+ VERSION = "7.4.0".freeze
3
3
  end
@@ -0,0 +1,269 @@
1
+ require 'spec_helper'
2
+
3
+ module GovukNavigationHelpers
4
+ RSpec.describe TasklistContent do
5
+ let(:path) { '/pass-plus' }
6
+ let(:tasklist_content) { described_class.new(file_name: "learn-to-drive-a-car", path: path) }
7
+
8
+ context '.current_tasklist' do
9
+ context 'based on the request' do
10
+ context 'when the path is /pass-plus' do
11
+ it 'returns "Learn to Drive" tasklist' do
12
+ current_tasklist = described_class.current_tasklist(path)
13
+
14
+ expect(
15
+ current_tasklist.title
16
+ ).to eql('Learn to drive a car: step by step')
17
+ end
18
+ end
19
+
20
+ context 'when the path is /divorce/respond-to-a-divorce-petition' do
21
+ let(:path) { '/divorce/respond-to-a-divorce-petition' }
22
+
23
+ it 'returns "Get Divorce" tasklist' do
24
+ current_tasklist = described_class.current_tasklist(path)
25
+
26
+ expect(
27
+ current_tasklist.title
28
+ ).to eql('Get a divorce: step by step')
29
+ end
30
+ end
31
+
32
+ context 'when the path is /end-civil-partnership' do
33
+ let(:path) { '/end-civil-partnership' }
34
+
35
+ it 'returns "End Civil Partnership" tasklist' do
36
+ current_tasklist = described_class.current_tasklist(path)
37
+
38
+ expect(
39
+ current_tasklist.title
40
+ ).to eql('End a civil partnership: step by step')
41
+ end
42
+ end
43
+
44
+ context 'when the path is in "Get Divorce" and "End Civil Partnership"' do
45
+ let(:path) { '/money-property-when-relationship-ends' }
46
+
47
+ it 'returns "Get Divorce" tasklist by default' do
48
+ current_tasklist = described_class.current_tasklist(path)
49
+
50
+ expect(
51
+ current_tasklist.title
52
+ ).to eql('Get a divorce: step by step')
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ context '#is_page_included_in_ab_test?' do
59
+ context 'when the requested path is part of the current tasklist' do
60
+ it 'returns true' do
61
+ expect(
62
+ tasklist_content.is_page_included_in_ab_test?
63
+ ).to be true
64
+ end
65
+ end
66
+
67
+ context 'when the requested path is not part of the current tasklist' do
68
+ let(:path) { '/pink-plus' }
69
+
70
+ it 'returns false' do
71
+ expect(
72
+ tasklist_content.is_page_included_in_ab_test?
73
+ ).to be false
74
+ end
75
+ end
76
+ end
77
+
78
+ context '#set_current_task' do
79
+ it 'sets /pass-plus as active' do
80
+ tasklist_content.set_current_task
81
+
82
+ expect(
83
+ tasklist_content.groups.last[0][:contents].last[:contents][0][:href]
84
+ ).to eql('/pass-plus')
85
+
86
+ expect(
87
+ tasklist_content.tasklist[:show_step]
88
+ ).to eql(7)
89
+
90
+ expect(
91
+ tasklist_content.groups.last[0][:contents].last[:contents][0][:active]
92
+ ).to be true
93
+ end
94
+ end
95
+
96
+ context "learning to drive a car tasklist content" do
97
+ it "has symbolized keys" do
98
+ tasklist_content.tasklist.keys.each do |key|
99
+ expect(key.is_a?(Symbol)).to be true
100
+ end
101
+ end
102
+
103
+ it "has a title" do
104
+ expect(tasklist_content.title).to eql("Learn to drive a car: step by step")
105
+ end
106
+
107
+ it "has a base_path" do
108
+ expect(tasklist_content.base_path).to eql("/learn-to-drive-a-car")
109
+ end
110
+
111
+ it "configures a sidebar" do
112
+ expect(tasklist_content.tasklist[:heading_level]).to eql(3)
113
+ expect(tasklist_content.tasklist[:small]).to be true
114
+ end
115
+
116
+ it "has a link in the correct structure" do
117
+ first_link = tasklist_content.tasklist[:groups][0][0][:contents][1][:contents][0]
118
+ expect(first_link[:href]).to eql("/vehicles-can-drive")
119
+ expect(first_link[:text]).to eql("Check what age you can drive")
120
+ end
121
+
122
+ it 'has all the primary paths' do
123
+ primary_paths = %w(
124
+ /apply-first-provisional-driving-licence
125
+ /book-driving-test
126
+ /book-theory-test
127
+ /cancel-driving-test
128
+ /cancel-theory-test
129
+ /change-driving-test
130
+ /change-theory-test
131
+ /check-driving-test
132
+ /check-theory-test
133
+ /driving-eyesight-rules
134
+ /driving-lessons-learning-to-drive
135
+ /driving-test/what-to-take
136
+ /find-driving-schools-and-lessons
137
+ /government/publications/car-show-me-tell-me-vehicle-safety-questions
138
+ /guidance/the-highway-code
139
+ /legal-obligations-drivers-riders
140
+ /pass-plus
141
+ /take-practice-theory-test
142
+ /theory-test/revision-and-practice
143
+ /theory-test/what-to-take
144
+ /vehicles-can-drive
145
+ ).sort
146
+
147
+ expect(
148
+ tasklist_content.primary_paths.sort
149
+ ).to match_array(primary_paths)
150
+ end
151
+
152
+ it 'has related paths' do
153
+ related_paths = %w(
154
+ /apply-for-your-full-driving-licence
155
+ /automatic-driving-licence-to-manual
156
+ /complain-about-a-driving-instructor
157
+ /driving-licence-fees
158
+ /driving-test-cost
159
+ /dvlaforms
160
+ /find-theory-test-pass-number
161
+ /government/publications/application-for-refunding-out-of-pocket-expenses
162
+ /government/publications/drivers-record-for-learner-drivers
163
+ /government/publications/driving-instructor-grades-explained
164
+ /government/publications/know-your-traffic-signs
165
+ /government/publications/l-plate-size-rules
166
+ /guidance/rules-for-observing-driving-tests
167
+ /report-an-illegal-driving-instructor
168
+ /report-driving-medical-condition
169
+ /report-driving-test-impersonation
170
+ /seat-belts-law
171
+ /speed-limits
172
+ /track-your-driving-licence-application
173
+ /vehicle-insurance
174
+ /driving-lessons-learning-to-drive/practising-with-family-or-friends
175
+ /driving-lessons-learning-to-drive/taking-driving-lessons
176
+ /driving-lessons-learning-to-drive/using-l-and-p-plates
177
+ /driving-test
178
+ /driving-test/changes-december-2017
179
+ /driving-test/disability-health-condition-or-learning-difficulty
180
+ /driving-test/driving-test-faults-result
181
+ /driving-test/test-cancelled-bad-weather
182
+ /driving-test/using-your-own-car
183
+ /driving-test/what-happens-during-test
184
+ /pass-plus/apply-for-a-pass-plus-certificate
185
+ /pass-plus/booking-pass-plus
186
+ /pass-plus/car-insurance-discounts
187
+ /pass-plus/local-councils-offering-discounts
188
+ /pass-plus/how-pass-plus-training-works
189
+ /theory-test
190
+ /theory-test/hazard-perception-test
191
+ /theory-test/if-you-have-safe-road-user-award
192
+ /theory-test/multiple-choice-questions
193
+ /theory-test/pass-mark-and-result
194
+ /theory-test/reading-difficulty-disability-or-health-condition
195
+ ).sort
196
+
197
+ expect(
198
+ tasklist_content.related_paths.sort
199
+ ).to match_array(related_paths)
200
+ end
201
+ end
202
+
203
+ context "get a divorce tasklist content" do
204
+ let(:tasklist_content) { described_class.new(file_name: "get-a-divorce", path: path) }
205
+
206
+ it "has symbolized keys" do
207
+ tasklist_content.tasklist.keys.each do |key|
208
+ expect(key.is_a?(Symbol)).to be true
209
+ end
210
+ end
211
+
212
+ it "has a title" do
213
+ expect(tasklist_content.title).to eql("Get a divorce: step by step")
214
+ end
215
+
216
+ it "has a base_path" do
217
+ expect(tasklist_content.base_path).to eql("/get-a-divorce")
218
+ end
219
+
220
+ it "configures a sidebar" do
221
+ expect(tasklist_content.tasklist[:heading_level]).to eql(3)
222
+ expect(tasklist_content.tasklist[:small]).to be true
223
+ end
224
+
225
+ it 'has all the primary paths' do
226
+ primary_paths = %w(
227
+ /divorce
228
+ /looking-after-children-divorce
229
+ /money-property-when-relationship-ends
230
+ /benefits-calculators
231
+ /report-benefits-change-circumstances
232
+ /contact-pension-service
233
+ /visas-when-you-separate-or-divorce
234
+ /stay-in-home-during-separation-or-divorce
235
+ /divorce/file-for-divorce
236
+ /divorce/grounds-for-divorce
237
+ /get-help-with-court-fees
238
+ /find-a-legal-adviser
239
+ /divorce-missing-husband-wife
240
+ /divorce/if-your-husband-or-wife-lacks-mental-capacity
241
+ /divorce/apply-for-decree-nisi
242
+ /divorce/apply-for-a-decree-absolute
243
+ ).sort
244
+
245
+ # there are two primary paths twice in the JSON structure
246
+ # that's legit.
247
+ expect(
248
+ tasklist_content.primary_paths.sort.uniq
249
+ ).to match_array(primary_paths)
250
+ end
251
+
252
+ it 'has related paths' do
253
+ related_paths = %w(
254
+ /divorce/respond-to-a-divorce-petition
255
+ ).sort
256
+
257
+ expect(
258
+ tasklist_content.related_paths.sort
259
+ ).to match_array(related_paths)
260
+ end
261
+
262
+ it "has a link in the correct structure" do
263
+ first_link = tasklist_content.tasklist[:groups][0][0][:contents][1][:contents][0]
264
+ expect(first_link[:href]).to eql("https://www.relate.org.uk/relationship-help/help-separation-and-divorce")
265
+ expect(first_link[:text]).to eql("Get advice from Relate")
266
+ end
267
+ end
268
+ end
269
+ 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.3.0
4
+ version: 7.4.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-14 00:00:00.000000000 Z
11
+ date: 2017-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gds-api-adapters
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '43.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: govuk_ab_testing
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.1'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: bundler
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -168,17 +196,22 @@ files:
168
196
  - LICENCE.txt
169
197
  - README.md
170
198
  - Rakefile
199
+ - config/tasklists/end-a-civil-partnership.json
200
+ - config/tasklists/get-a-divorce.json
201
+ - config/tasklists/learn-to-drive-a-car.json
171
202
  - govuk_navigation_helpers.gemspec
172
203
  - lib/govuk_navigation_helpers.rb
173
204
  - lib/govuk_navigation_helpers/breadcrumbs.rb
174
205
  - lib/govuk_navigation_helpers/configuration.rb
175
206
  - lib/govuk_navigation_helpers/content_item.rb
176
207
  - lib/govuk_navigation_helpers/curated_taxonomy_sidebar_links.rb
208
+ - lib/govuk_navigation_helpers/current_tasklist_ab_test.rb
177
209
  - lib/govuk_navigation_helpers/grouped_related_links.rb
178
210
  - lib/govuk_navigation_helpers/related_items.rb
179
211
  - lib/govuk_navigation_helpers/related_navigation_sidebar.rb
180
212
  - lib/govuk_navigation_helpers/rummager_taxonomy_sidebar_links.rb
181
213
  - lib/govuk_navigation_helpers/services.rb
214
+ - lib/govuk_navigation_helpers/tasklist_content.rb
182
215
  - lib/govuk_navigation_helpers/taxon_breadcrumbs.rb
183
216
  - lib/govuk_navigation_helpers/taxonomy_sidebar.rb
184
217
  - lib/govuk_navigation_helpers/version.rb
@@ -187,6 +220,7 @@ files:
187
220
  - spec/related_items_spec.rb
188
221
  - spec/related_navigation_sidebar_spec.rb
189
222
  - spec/spec_helper.rb
223
+ - spec/tasklist_content_spec.rb
190
224
  - spec/taxon_breadcrumbs_spec.rb
191
225
  - spec/taxonomy_sidebar_spec.rb
192
226
  homepage: https://github.com/alphagov/govuk_navigation_helpers
@@ -219,5 +253,6 @@ test_files:
219
253
  - spec/related_items_spec.rb
220
254
  - spec/related_navigation_sidebar_spec.rb
221
255
  - spec/spec_helper.rb
256
+ - spec/tasklist_content_spec.rb
222
257
  - spec/taxon_breadcrumbs_spec.rb
223
258
  - spec/taxonomy_sidebar_spec.rb