govuk_navigation_helpers 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/govuk_navigation_helpers/taxon_breadcrumbs.rb +4 -1
- data/lib/govuk_navigation_helpers/version.rb +1 -1
- data/spec/taxon_breadcrumbs_spec.rb +84 -35
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b95f1233b8c92f48aa8322db214c9063c198087
|
4
|
+
data.tar.gz: 39c48d33844ad4f5e4f50e4a1cd8523e6aa82725
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b34e178430bb1c7cd8d8ce57653f5374c1cdefcc3d4f246be721e550fdd999fe7f10e2944ae70fe4f143a933cbdb79c60b2fcc30e2757d8274d9f7f0e69a67e6
|
7
|
+
data.tar.gz: 5231d56178f8bb94d3732548b8f35c200587059d7722930f3e199502b8eabb206b3e6077dd38877e7b485f0e9b38b9fc4f99adf9615130fe6b1b16f6004d388a
|
data/CHANGELOG.md
CHANGED
@@ -11,8 +11,11 @@ module GovukNavigationHelpers
|
|
11
11
|
|
12
12
|
ordered_parents << { title: "Home", url: "/" }
|
13
13
|
|
14
|
+
ordered_breadcrumbs = ordered_parents.reverse
|
15
|
+
ordered_breadcrumbs << { title: content_item.title, is_current_page: true }
|
16
|
+
|
14
17
|
{
|
15
|
-
|
18
|
+
breadcrumbs: ordered_breadcrumbs
|
16
19
|
}
|
17
20
|
end
|
18
21
|
|
@@ -3,63 +3,100 @@ require 'spec_helper'
|
|
3
3
|
RSpec.describe GovukNavigationHelpers::TaxonBreadcrumbs do
|
4
4
|
describe "Taxon breadcrumbs" do
|
5
5
|
it "can handle any valid content item" do
|
6
|
-
generator = GovukSchemas::RandomExample.for_schema(
|
6
|
+
generator = GovukSchemas::RandomExample.for_schema(
|
7
|
+
"taxon",
|
8
|
+
schema_type: "frontend"
|
9
|
+
)
|
7
10
|
|
8
|
-
expect {
|
11
|
+
expect {
|
12
|
+
GovukNavigationHelpers::TaxonBreadcrumbs.new(
|
13
|
+
generator.payload
|
14
|
+
).breadcrumbs
|
15
|
+
}.to_not raise_error
|
9
16
|
end
|
10
17
|
|
11
18
|
it "returns the root when taxon is not specified" do
|
12
|
-
content_item = { "links" => {} }
|
19
|
+
content_item = { "title" => "Some Content", "links" => {} }
|
13
20
|
breadcrumbs = breadcrumbs_for(content_item)
|
14
21
|
|
15
22
|
expect(breadcrumbs).to eq(
|
16
23
|
breadcrumbs: [
|
17
24
|
{ title: "Home", url: "/" },
|
25
|
+
{ title: "Some Content", is_current_page: true }
|
18
26
|
]
|
19
27
|
)
|
20
28
|
end
|
21
29
|
|
22
30
|
it "places parent under the root when there is a taxon" do
|
23
|
-
content_item =
|
31
|
+
content_item = content_item_tagged_to_taxon([])
|
24
32
|
breadcrumbs = breadcrumbs_for(content_item)
|
25
33
|
|
26
34
|
expect(breadcrumbs).to eq(
|
27
35
|
breadcrumbs: [
|
28
36
|
{ title: "Home", url: "/" },
|
29
|
-
{ title: "Taxon", url: "/
|
37
|
+
{ title: "Taxon", url: "/taxon" },
|
38
|
+
{ title: "Some Content", is_current_page: true },
|
30
39
|
]
|
31
40
|
)
|
32
41
|
end
|
33
42
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
parent = {
|
43
|
-
"content_id" => "30c1b93d-2553-47c9-bc3c-fc5b513ecc32",
|
44
|
-
"locale" => "en",
|
45
|
-
"title" => "A-parent",
|
46
|
-
"base_path" => "/a-parent",
|
47
|
-
"links" => {
|
48
|
-
"parent_taxons" => [grandparent]
|
49
|
-
}
|
50
|
-
}
|
51
|
-
|
52
|
-
content_item = content_item_with_parents([parent])
|
53
|
-
breadcrumbs = breadcrumbs_for(content_item)
|
43
|
+
context 'with a taxon content item with taxon parents' do
|
44
|
+
it "includes parents and grandparents when available" do
|
45
|
+
grandparent = {
|
46
|
+
"title" => "Another-parent",
|
47
|
+
"base_path" => "/another-parent",
|
48
|
+
"content_id" => "30c1b93d-2553-47c9-bc3c-fc5b513ecc32",
|
49
|
+
"locale" => "en",
|
50
|
+
}
|
54
51
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
52
|
+
parent = {
|
53
|
+
"content_id" => "30c1b93d-2553-47c9-bc3c-fc5b513ecc32",
|
54
|
+
"locale" => "en",
|
55
|
+
"title" => "A-parent",
|
56
|
+
"base_path" => "/a-parent",
|
57
|
+
"links" => {
|
58
|
+
"parent_taxons" => [grandparent]
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
content_item = content_item_tagged_to_taxon([parent])
|
63
|
+
breadcrumbs = breadcrumbs_for(content_item)
|
64
|
+
|
65
|
+
expect(breadcrumbs).to eq(
|
66
|
+
breadcrumbs: [
|
67
|
+
{ title: "Home", url: "/" },
|
68
|
+
{ title: "Another-parent", url: "/another-parent" },
|
69
|
+
{ title: "A-parent", url: "/a-parent" },
|
70
|
+
{ title: "Taxon", url: "/taxon" },
|
71
|
+
{ title: "Some Content", is_current_page: true },
|
72
|
+
]
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'with a taxon with parent taxons' do
|
78
|
+
it "includes parents and grandparents when available" do
|
79
|
+
parent = {
|
80
|
+
"content_id" => "30c1b93d-2553-47c9-bc3c-fc5b513ecc32",
|
81
|
+
"locale" => "en",
|
82
|
+
"title" => "A-parent",
|
83
|
+
"base_path" => "/a-parent",
|
84
|
+
"links" => {
|
85
|
+
"parent_taxons" => []
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
content_item = taxon_with_parent_taxons([parent])
|
90
|
+
breadcrumbs = breadcrumbs_for(content_item)
|
91
|
+
|
92
|
+
expect(breadcrumbs).to eq(
|
93
|
+
breadcrumbs: [
|
94
|
+
{ title: "Home", url: "/" },
|
95
|
+
{ title: "A-parent", url: "/a-parent" },
|
96
|
+
{ title: "Taxon", is_current_page: true },
|
97
|
+
]
|
98
|
+
)
|
99
|
+
end
|
63
100
|
end
|
64
101
|
end
|
65
102
|
|
@@ -72,15 +109,27 @@ RSpec.describe GovukNavigationHelpers::TaxonBreadcrumbs do
|
|
72
109
|
GovukNavigationHelpers::NavigationHelper.new(fully_valid_content_item).taxon_breadcrumbs
|
73
110
|
end
|
74
111
|
|
75
|
-
def
|
112
|
+
def taxon_with_parent_taxons(parents)
|
113
|
+
{
|
114
|
+
"title" => "Taxon",
|
115
|
+
"document_type" => "taxon",
|
116
|
+
"links" => {
|
117
|
+
"parent_taxons" => parents,
|
118
|
+
},
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
122
|
+
def content_item_tagged_to_taxon(parents)
|
76
123
|
{
|
124
|
+
"title" => "Some Content",
|
125
|
+
"document_type" => "guidance",
|
77
126
|
"links" => {
|
78
127
|
"taxons" => [
|
79
128
|
{
|
80
129
|
"content_id" => "30c1b93d-2553-47c9-bc3c-fc5b513ecc32",
|
81
130
|
"locale" => "en",
|
82
131
|
"title" => "Taxon",
|
83
|
-
"base_path" => "/
|
132
|
+
"base_path" => "/taxon",
|
84
133
|
"links" => {
|
85
134
|
"parent_taxons" => parents
|
86
135
|
},
|
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: 2.
|
4
|
+
version: 2.3.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-02-
|
11
|
+
date: 2017-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|