diff --git a/app/views/govuk_component/analytics_meta_tags.raw.html.erb b/app/views/govuk_component/analytics_meta_tags.raw.html.erb index 07eb51490..784c726b5 100644 --- a/app/views/govuk_component/analytics_meta_tags.raw.html.erb +++ b/app/views/govuk_component/analytics_meta_tags.raw.html.erb @@ -81,3 +81,5 @@ <% meta_tags.each do |name, content| %> <% end %> + +<%= yield :analytics_meta_tags %> diff --git a/app/views/govuk_component/analytics_meta_tags_navigation.raw.html.erb b/app/views/govuk_component/analytics_meta_tags_navigation.raw.html.erb new file mode 100644 index 000000000..0579a8031 --- /dev/null +++ b/app/views/govuk_component/analytics_meta_tags_navigation.raw.html.erb @@ -0,0 +1,9 @@ +<% + number_of_sections ||= 0 + number_of_links ||= 0 +%> + +<% content_for :analytics_meta_tags do %> + + +<% end %> diff --git a/app/views/govuk_component/docs/analytics_meta_tags_navigation.yml b/app/views/govuk_component/docs/analytics_meta_tags_navigation.yml new file mode 100644 index 000000000..b4f884335 --- /dev/null +++ b/app/views/govuk_component/docs/analytics_meta_tags_navigation.yml @@ -0,0 +1,10 @@ +name: Analytics Meta Tags +description: Meta tags to provide analytics information about the current page +body: | + A component that appends counts for navigation elements to the analytics_meta_tags component. + + The code which reads the meta tags can be found in static-analytics.js. +fixtures: + default: + number_of_sections: 2 + number_of_links: 6 diff --git a/test/govuk_component/analytics_meta_tags_navigation_test.rb b/test/govuk_component/analytics_meta_tags_navigation_test.rb new file mode 100644 index 000000000..fb1c42189 --- /dev/null +++ b/test/govuk_component/analytics_meta_tags_navigation_test.rb @@ -0,0 +1,13 @@ +require 'govuk_component_test_helper' + +class AnalyticsMetaTagsNavigationTestCase < ComponentTestCase + def component_name + "analytics_meta_tags_navigation" + end + + test "no error if no parameters passed in" do + assert_nothing_raised do + render_component({}) + end + end +end diff --git a/test/govuk_component/analytics_meta_tags_test.rb b/test/govuk_component/analytics_meta_tags_test.rb index 6b5da7aa2..81be9bbe5 100644 --- a/test/govuk_component/analytics_meta_tags_test.rb +++ b/test/govuk_component/analytics_meta_tags_test.rb @@ -19,7 +19,7 @@ def example_document_for(format, example_name) end test "no meta tags are rendered when there's no trackable data" do - assert_empty render_component(content_item: {}) + assert_empty render_component(content_item: {}).strip end test "renders format in a meta tag" do @@ -85,8 +85,8 @@ def example_document_for(format, example_name) end test "does not render publishing government or political status when political or government is missing" do - assert_empty render_component(content_item: { details: { government: { current: true, slug: 'government' } } }) - assert_empty render_component(content_item: { details: { political: true } }) + assert_empty render_component(content_item: { details: { government: { current: true, slug: 'government' } } }).strip + assert_empty render_component(content_item: { details: { political: true } }).strip end test "renders user journey stage when user journey supertype is included" do