govuk_navigation_helpers 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +9 -0
- data/Jenkinsfile +3 -1
- data/lib/govuk_navigation_helpers/content_item.rb +5 -3
- data/lib/govuk_navigation_helpers/version.rb +1 -1
- data/spec/taxon_breadcrumbs_spec.rb +19 -24
- metadata +3 -3
- data/jenkins.sh +0 -72
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80cac05a9d17cb8067c82327c9c24ea3f2d319b2
|
4
|
+
data.tar.gz: c9f0298eaad59f93128f8924f53cdc958a461bf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a6de31aa86ae19a3c0e64aa72bda842098f3ff4853f6b68a1a18773b6e56d60a528bbbbf561d2eaa90811ab767b749041ec0a97552b21358102347107fabb26
|
7
|
+
data.tar.gz: 81ac62a637462a5de3055ecd7c639f8c898edf64c62080214158499d227c27e7a5a8ee93a2df48cde78ad2af2db1bcb4688a692539e12089ad3d5290a4481bc9
|
data/.rubocop.yml
ADDED
data/CHANGELOG.md
CHANGED
data/Jenkinsfile
CHANGED
@@ -17,10 +17,12 @@ module GovukNavigationHelpers
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def parent_taxon
|
20
|
-
# TODO: Determine what to do when there are multiple parents. For now just display the first
|
20
|
+
# TODO: Determine what to do when there are multiple taxons/parents. For now just display the first of each.
|
21
|
+
taxon = content_store_response.dig("links", "taxons", 0)
|
22
|
+
return ContentItem.new(taxon) if taxon
|
23
|
+
|
21
24
|
parent_taxon = content_store_response.dig("links", "parent_taxons", 0)
|
22
|
-
return
|
23
|
-
ContentItem.new(parent_taxon)
|
25
|
+
return ContentItem.new(parent_taxon) if parent_taxon
|
24
26
|
end
|
25
27
|
|
26
28
|
def mainstream_browse_pages
|
@@ -8,7 +8,7 @@ RSpec.describe GovukNavigationHelpers::TaxonBreadcrumbs do
|
|
8
8
|
expect { GovukNavigationHelpers::TaxonBreadcrumbs.new(generator.payload).breadcrumbs }.to_not raise_error
|
9
9
|
end
|
10
10
|
|
11
|
-
it "returns the root when
|
11
|
+
it "returns the root when taxon is not specified" do
|
12
12
|
content_item = { "links" => {} }
|
13
13
|
breadcrumbs = breadcrumbs_for(content_item)
|
14
14
|
|
@@ -19,37 +19,19 @@ RSpec.describe GovukNavigationHelpers::TaxonBreadcrumbs do
|
|
19
19
|
)
|
20
20
|
end
|
21
21
|
|
22
|
-
it "
|
22
|
+
it "places parent under the root when there is a taxon" do
|
23
23
|
content_item = content_item_with_parents([])
|
24
24
|
breadcrumbs = breadcrumbs_for(content_item)
|
25
25
|
|
26
26
|
expect(breadcrumbs).to eq(
|
27
27
|
breadcrumbs: [
|
28
28
|
{ title: "Home", url: "/" },
|
29
|
+
{ title: "Taxon", url: "/a-taxon" }
|
29
30
|
]
|
30
31
|
)
|
31
32
|
end
|
32
33
|
|
33
|
-
it "
|
34
|
-
parent = {
|
35
|
-
"content_id" => "30c1b93d-2553-47c9-bc3c-fc5b513ecc32",
|
36
|
-
"locale" => "en",
|
37
|
-
"title" => "A-parent",
|
38
|
-
"base_path" => "/a-parent",
|
39
|
-
}
|
40
|
-
|
41
|
-
content_item = content_item_with_parents([parent])
|
42
|
-
breadcrumbs = breadcrumbs_for(content_item)
|
43
|
-
|
44
|
-
expect(breadcrumbs).to eq(
|
45
|
-
breadcrumbs: [
|
46
|
-
{ title: "Home", url: "/" },
|
47
|
-
{ title: "A-parent", url: "/a-parent" }
|
48
|
-
]
|
49
|
-
)
|
50
|
-
end
|
51
|
-
|
52
|
-
it "includes grandparent when available" do
|
34
|
+
it "includes parents and grandparents when available" do
|
53
35
|
grandparent = {
|
54
36
|
"title" => "Another-parent",
|
55
37
|
"base_path" => "/another-parent",
|
@@ -74,7 +56,8 @@ RSpec.describe GovukNavigationHelpers::TaxonBreadcrumbs do
|
|
74
56
|
breadcrumbs: [
|
75
57
|
{ title: "Home", url: "/" },
|
76
58
|
{ title: "Another-parent", url: "/another-parent" },
|
77
|
-
{ title: "A-parent", url: "/a-parent" }
|
59
|
+
{ title: "A-parent", url: "/a-parent" },
|
60
|
+
{ title: "Taxon", url: "/a-taxon" },
|
78
61
|
]
|
79
62
|
)
|
80
63
|
end
|
@@ -91,7 +74,19 @@ RSpec.describe GovukNavigationHelpers::TaxonBreadcrumbs do
|
|
91
74
|
|
92
75
|
def content_item_with_parents(parents)
|
93
76
|
{
|
94
|
-
|
77
|
+
"links" => {
|
78
|
+
"taxons" => [
|
79
|
+
{
|
80
|
+
"content_id" => "30c1b93d-2553-47c9-bc3c-fc5b513ecc32",
|
81
|
+
"locale" => "en",
|
82
|
+
"title" => "Taxon",
|
83
|
+
"base_path" => "/a-taxon",
|
84
|
+
"links" => {
|
85
|
+
"parent_taxons" => parents
|
86
|
+
},
|
87
|
+
},
|
88
|
+
],
|
89
|
+
},
|
95
90
|
}
|
96
91
|
end
|
97
92
|
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: 2.
|
4
|
+
version: 2.2.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-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -132,6 +132,7 @@ extra_rdoc_files: []
|
|
132
132
|
files:
|
133
133
|
- ".gitignore"
|
134
134
|
- ".rspec"
|
135
|
+
- ".rubocop.yml"
|
135
136
|
- ".ruby-version"
|
136
137
|
- CHANGELOG.md
|
137
138
|
- Gemfile
|
@@ -140,7 +141,6 @@ files:
|
|
140
141
|
- README.md
|
141
142
|
- Rakefile
|
142
143
|
- govuk_navigation_helpers.gemspec
|
143
|
-
- jenkins.sh
|
144
144
|
- lib/govuk_navigation_helpers.rb
|
145
145
|
- lib/govuk_navigation_helpers/breadcrumbs.rb
|
146
146
|
- lib/govuk_navigation_helpers/content_item.rb
|
data/jenkins.sh
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
REPO_NAME=${REPO_NAME:-"alphagov/govuk_navigation_helpers"}
|
4
|
-
CONTEXT_MESSAGE=${CONTEXT_MESSAGE:-"default"}
|
5
|
-
GH_STATUS_GIT_COMMIT=${SCHEMA_GIT_COMMIT:-${GIT_COMMIT}}
|
6
|
-
|
7
|
-
function github_status {
|
8
|
-
REPO_NAME="$1"
|
9
|
-
STATUS="$2"
|
10
|
-
MESSAGE="$3"
|
11
|
-
gh-status "$REPO_NAME" "$GH_STATUS_GIT_COMMIT" "$STATUS" -d "Build #${BUILD_NUMBER} ${MESSAGE}" -u "$BUILD_URL" -c "$CONTEXT_MESSAGE" >/dev/null
|
12
|
-
}
|
13
|
-
|
14
|
-
function error_handler {
|
15
|
-
trap - ERR # disable error trap to avoid recursion
|
16
|
-
local parent_lineno="$1"
|
17
|
-
local message="$2"
|
18
|
-
local code="${3:-1}"
|
19
|
-
if [[ -n "$message" ]] ; then
|
20
|
-
echo "Error on or near line ${parent_lineno}: ${message}; exiting with status ${code}"
|
21
|
-
else
|
22
|
-
echo "Error on or near line ${parent_lineno}; exiting with status ${code}"
|
23
|
-
fi
|
24
|
-
github_status "$REPO_NAME" error "errored on Jenkins"
|
25
|
-
exit "${code}"
|
26
|
-
}
|
27
|
-
|
28
|
-
trap 'error_handler ${LINENO}' ERR
|
29
|
-
github_status "$REPO_NAME" pending "is running on Jenkins"
|
30
|
-
|
31
|
-
# Cleanup anything left from previous test runs
|
32
|
-
git clean -fdx
|
33
|
-
|
34
|
-
# Try to merge master into the current branch, and abort if it doesn't exit
|
35
|
-
# cleanly (ie there are conflicts). This will be a noop if the current branch
|
36
|
-
# is master.
|
37
|
-
git merge --no-commit origin/master || git merge --abort
|
38
|
-
|
39
|
-
echo "Running ruby linter"
|
40
|
-
bundle install --path "${HOME}/bundles/${JOB_NAME}"
|
41
|
-
bundle exec govuk-lint-ruby \
|
42
|
-
--format html --out rubocop-${GIT_COMMIT}.html \
|
43
|
-
--format clang
|
44
|
-
|
45
|
-
# Clone govuk-content-schemas depedency for contract tests
|
46
|
-
rm -rf /tmp/govuk-content-schemas
|
47
|
-
git clone git@github.com:alphagov/govuk-content-schemas.git /tmp/govuk-content-schemas
|
48
|
-
(
|
49
|
-
cd /tmp/govuk-content-schemas
|
50
|
-
git checkout ${SCHEMA_GIT_COMMIT:-"master"}
|
51
|
-
)
|
52
|
-
export GOVUK_CONTENT_SCHEMAS_PATH=/tmp/govuk-content-schemas
|
53
|
-
|
54
|
-
# Bundle and run tests against multiple ruby versions
|
55
|
-
for version in 2.3.1; do
|
56
|
-
rm -f Gemfile.lock
|
57
|
-
export RBENV_VERSION=$version
|
58
|
-
echo "Running tests under ruby $version"
|
59
|
-
bundle install --path "${HOME}/bundles/${JOB_NAME}"
|
60
|
-
if ! bundle exec rake ${TEST_TASK:-"default"}; then
|
61
|
-
github_status "$REPO_NAME" failure "failed on Jenkins"
|
62
|
-
exit 1
|
63
|
-
fi
|
64
|
-
done
|
65
|
-
unset RBENV_VERSION
|
66
|
-
|
67
|
-
if [[ -n "$PUBLISH_GEM" ]]; then
|
68
|
-
bundle install --path "${HOME}/bundles/${JOB_NAME}"
|
69
|
-
bundle exec rake publish_gem --trace
|
70
|
-
fi
|
71
|
-
|
72
|
-
github_status "$REPO_NAME" success "succeeded on Jenkins"
|