govuk_navigation_helpers 8.2.0 → 8.2.1
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: 0aa11979bbf940f76afd57f51b64ae5a2d9764bf
|
4
|
+
data.tar.gz: 7be108482916def775713be20fee96d836a38a33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c36483f76f1239ffd68bf146af95e71df9f678713537b8e1e3cbf5a07a880ecdf79f4bb40b5e74c3569d1daab8d4a0d0f598daee8e115049ec3fffc239a11d56
|
7
|
+
data.tar.gz: 6ada73a40b0a8d621f2fce2f8f46fff09c113e42b920c95de0f8a456ab8f069ffa35e6d35b88a31144c54ab04519aa2eff187ee74f36feab751d37cba45b0600
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 8.2.1
|
2
|
+
* Update related navigation sidebar helper to deduplicate mainstream topics with the same title as whithall topics.
|
3
|
+
Mainstream topics are preferred in the case of duplicates.
|
4
|
+
* Update Yard dependency to 0.9.12
|
5
|
+
|
1
6
|
## 8.2.0
|
2
7
|
* Update related navigation sidebar helper to return mainstream topics alongside whitehall topics
|
3
8
|
* Update content in the /end-a-civil-partnership, /get-a-divorce tasklists
|
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency "gem_publisher", "~> 1.5.0"
|
29
29
|
spec.add_development_dependency "govuk-lint", "~> 1.2.1"
|
30
30
|
spec.add_development_dependency "pry-byebug", "~> 3.4"
|
31
|
-
spec.add_development_dependency "yard", "~> 0.
|
31
|
+
spec.add_development_dependency "yard", "~> 0.9.12"
|
32
32
|
spec.add_development_dependency "govuk_schemas", "~> 1.0"
|
33
33
|
spec.add_development_dependency "webmock", "~> 2.3"
|
34
34
|
|
@@ -72,7 +72,7 @@ module GovukNavigationHelpers
|
|
72
72
|
def related_topics
|
73
73
|
topics = build_links_for_sidebar(@content_item.related_topics)
|
74
74
|
topics << related_mainstream_topic << related_mainstream_parent_topic
|
75
|
-
topics.compact
|
75
|
+
deduplicate_topics_by_title(topics.compact)
|
76
76
|
end
|
77
77
|
|
78
78
|
def related_topical_events
|
@@ -105,6 +105,22 @@ module GovukNavigationHelpers
|
|
105
105
|
{ text: @content_item.parent.parent.title, path: @content_item.parent.parent.base_path }
|
106
106
|
end
|
107
107
|
|
108
|
+
# This method post-processes the topics collated by the helper.
|
109
|
+
# We add mainstream browse page links if they are present, however
|
110
|
+
# if these have the same title as an existing topic we should prefer
|
111
|
+
# the mainstream version and remove the existing topic.
|
112
|
+
# @see spec/related_navigation_sidebar_spec.rb:260 for test coverage.
|
113
|
+
def deduplicate_topics_by_title(topics)
|
114
|
+
is_dupe = lambda { |a, b| a && a != b && a[:text] == b[:text] }
|
115
|
+
|
116
|
+
topics.delete_if do |t|
|
117
|
+
is_dupe.call(related_mainstream_topic, t) ||
|
118
|
+
is_dupe.call(related_mainstream_parent_topic, t)
|
119
|
+
end
|
120
|
+
|
121
|
+
topics
|
122
|
+
end
|
123
|
+
|
108
124
|
def parameterise(str, sep = "-")
|
109
125
|
parameterised_str = str.gsub(/[^\w\-]+/, sep)
|
110
126
|
unless sep.nil? || sep.empty?
|
@@ -256,5 +256,57 @@ RSpec.describe GovukNavigationHelpers::RelatedNavigationSidebar do
|
|
256
256
|
|
257
257
|
expect(payload[:other]).to eql(expected)
|
258
258
|
end
|
259
|
+
|
260
|
+
it "deduplicates topics for mainstream content" do
|
261
|
+
mainstream_browse_link = {
|
262
|
+
"content_id" => "fecdc8c8-4006-4f8e-95d5-fe40ca49c7a8",
|
263
|
+
"locale" => "en",
|
264
|
+
"title" => "Self Assessment",
|
265
|
+
"base_path" => "/browse/tax/self-assessment",
|
266
|
+
"document_type" => "mainstream_browse_page",
|
267
|
+
}
|
268
|
+
payload = payload_for("answer",
|
269
|
+
"details" => {
|
270
|
+
"external_related_links" => []
|
271
|
+
},
|
272
|
+
"links" => {
|
273
|
+
"mainstream_browse_pages" => [mainstream_browse_link],
|
274
|
+
"ordered_related_items" => [
|
275
|
+
{
|
276
|
+
"content_id" => "f29ca4a8-8ed9-4b0f-bb6a-11e373095dee",
|
277
|
+
"locale" => "en",
|
278
|
+
"title" => "Self Assessment tax returns",
|
279
|
+
"base_path" => "/self-assessment-tax-returns",
|
280
|
+
"document_type" => "guide",
|
281
|
+
"links" => { "mainstream_browse_pages" => [mainstream_browse_link] },
|
282
|
+
}
|
283
|
+
],
|
284
|
+
"parent" => [mainstream_browse_link],
|
285
|
+
"topics" => [
|
286
|
+
{
|
287
|
+
"content_id" => "7beb97b6-75c9-4aa7-86be-a733ab3a21aa",
|
288
|
+
"locale" => "en",
|
289
|
+
"base_path" => "/topic/personal-tax/self-assessment",
|
290
|
+
"title" => "Self Assessment",
|
291
|
+
"document_type" => "topic",
|
292
|
+
}
|
293
|
+
],
|
294
|
+
}
|
295
|
+
)
|
296
|
+
expected = {
|
297
|
+
related_items: [{ text: "Self Assessment tax returns", path: "/self-assessment-tax-returns" }],
|
298
|
+
collections: [],
|
299
|
+
statistical_data_sets: [],
|
300
|
+
topics: [{ text: "Self Assessment", path: "/browse/tax/self-assessment" }],
|
301
|
+
topical_events: [],
|
302
|
+
policies: [],
|
303
|
+
publishers: [],
|
304
|
+
world_locations: [],
|
305
|
+
worldwide_organisations: [],
|
306
|
+
other: [[], []]
|
307
|
+
}
|
308
|
+
|
309
|
+
expect(payload).to eql(expected)
|
310
|
+
end
|
259
311
|
end
|
260
312
|
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: 8.2.
|
4
|
+
version: 8.2.1
|
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: 2018-01-
|
11
|
+
date: 2018-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gds-api-adapters
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
145
|
+
version: 0.9.12
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
152
|
+
version: 0.9.12
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: govuk_schemas
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|