diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 008bd8e7..d29b7bc5 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,6 +1,6 @@ class HomeController < ApplicationController # This controller renders the home page serializer. It does not currently query the data base. def index - render_page(PageSerializer::HomePageSerializer.new) + render_page(PageSerializer::HomePageSerializer.new(request_id: app_insights_request_id, request_original_url: request.original_url)) end end diff --git a/app/serializers/page_serializer/groups_show_page_serializer.rb b/app/serializers/page_serializer/groups_show_page_serializer.rb index cdc1714f..bafe9c0d 100644 --- a/app/serializers/page_serializer/groups_show_page_serializer.rb +++ b/app/serializers/page_serializer/groups_show_page_serializer.rb @@ -15,7 +15,7 @@ def initialize(group: nil, request_id: nil, data_alternates: nil, request_origin private def meta - { title: title } + super(title: title) end def title diff --git a/app/serializers/page_serializer/home_page_serializer.rb b/app/serializers/page_serializer/home_page_serializer.rb index 00615d6a..a6025116 100644 --- a/app/serializers/page_serializer/home_page_serializer.rb +++ b/app/serializers/page_serializer/home_page_serializer.rb @@ -4,8 +4,10 @@ class HomePageSerializer < PageSerializer::BasePageSerializer # Initialise a Home index page serializer. # # @param [String] opensearch_description_url a description url for the search. - def initialize(opensearch_description_url: nil) + def initialize(opensearch_description_url: nil, request_id: nil, request_original_url: nil) @opensearch_description_url = opensearch_description_url + + super(request_id: request_id, request_original_url: request_original_url) end private @@ -13,7 +15,7 @@ def initialize(opensearch_description_url: nil) attr_reader :opensearch_description_url def meta - { title: 'beta.parliament.uk' } + super(title: 'beta.parliament.uk') end def content diff --git a/app/serializers/page_serializer/list_page_serializer.rb b/app/serializers/page_serializer/list_page_serializer.rb index f96bd781..0e25dc48 100644 --- a/app/serializers/page_serializer/list_page_serializer.rb +++ b/app/serializers/page_serializer/list_page_serializer.rb @@ -18,7 +18,7 @@ def initialize(page_title: nil, list_components: nil, request_id: nil, data_alte private def meta - { title: @page_title } + super(title: @page_title) end def content diff --git a/spec/fixtures/controllers/groups_controller/index/fixture.yml b/spec/fixtures/controllers/groups_controller/index/fixture.yml index e5384dbb..00d41afe 100644 --- a/spec/fixtures/controllers/groups_controller/index/fixture.yml +++ b/spec/fixtures/controllers/groups_controller/index/fixture.yml @@ -3,6 +3,29 @@ layout: template: layout meta: title: groups.index.title + request-id: 123456 + data-alternates: + - type: application/n-triples + href: http://localhost:3030/group_index.nt + - type: text/turtle + href: http://localhost:3030/group_index.ttl + - type: text/tab-separated-values + href: http://localhost:3030/group_index.tsv + - type: text/csv + href: http://localhost:3030/group_index.csv + - type: application/json+rdf + href: http://localhost:3030/group_index.rj + - type: application/json+ld + href: http://localhost:3030/group_index.json + - type: application/rdf+xml + href: http://localhost:3030/group_index.xml + open-graph: + title: groups.index.title + original-url: http://www.example.com/groups + image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png + image-width: '1200' + image-height: '630' + twitter-card: summary_large_image header-components: - name: link data: diff --git a/spec/fixtures/controllers/groups_controller/show/fixture.yml b/spec/fixtures/controllers/groups_controller/show/fixture.yml index 35ce400f..c1d4368a 100644 --- a/spec/fixtures/controllers/groups_controller/show/fixture.yml +++ b/spec/fixtures/controllers/groups_controller/show/fixture.yml @@ -3,6 +3,29 @@ layout: template: layout meta: title: groupName - 1 + request-id: 123456 + data-alternates: + - type: application/n-triples + href: http://localhost:3030/group_by_id.nt?group_id=0RNgrC4q + - type: text/turtle + href: http://localhost:3030/group_by_id.ttl?group_id=0RNgrC4q + - type: text/tab-separated-values + href: http://localhost:3030/group_by_id.tsv?group_id=0RNgrC4q + - type: text/csv + href: http://localhost:3030/group_by_id.csv?group_id=0RNgrC4q + - type: application/json+rdf + href: http://localhost:3030/group_by_id.rj?group_id=0RNgrC4q + - type: application/json+ld + href: http://localhost:3030/group_by_id.json?group_id=0RNgrC4q + - type: application/rdf+xml + href: http://localhost:3030/group_by_id.xml?group_id=0RNgrC4q + open-graph: + title: groupName - 1 + original-url: http://www.example.com/groups/0RNgrC4q + image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png + image-width: '1200' + image-height: '630' + twitter-card: summary_large_image header-components: - name: link data: diff --git a/spec/fixtures/controllers/home_controller/index/fixture.yml b/spec/fixtures/controllers/home_controller/index/fixture.yml index 74223441..1098503c 100644 --- a/spec/fixtures/controllers/home_controller/index/fixture.yml +++ b/spec/fixtures/controllers/home_controller/index/fixture.yml @@ -3,6 +3,15 @@ layout: template: layout meta: title: beta.parliament.uk + request-id: 123456 + data-alternates: + open-graph: + title: beta.parliament.uk + original-url: http://www.example.com/ + image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png + image-width: '1200' + image-height: '630' + twitter-card: summary_large_image header-components: - name: link data: diff --git a/spec/fixtures/controllers/proposed_negative_statutory_instruments_controller/index/fixture.yml b/spec/fixtures/controllers/proposed_negative_statutory_instruments_controller/index/fixture.yml index ee4aee36..93ca33dc 100644 --- a/spec/fixtures/controllers/proposed_negative_statutory_instruments_controller/index/fixture.yml +++ b/spec/fixtures/controllers/proposed_negative_statutory_instruments_controller/index/fixture.yml @@ -3,6 +3,29 @@ layout: template: layout meta: title: proposed-negative-statutory-instruments.index.title + request-id: 123456 + data-alternates: + - type: application/n-triples + href: http://localhost:3030/proposed_negative_statutory_instrument_index.nt + - type: text/turtle + href: http://localhost:3030/proposed_negative_statutory_instrument_index.ttl + - type: text/tab-separated-values + href: http://localhost:3030/proposed_negative_statutory_instrument_index.tsv + - type: text/csv + href: http://localhost:3030/proposed_negative_statutory_instrument_index.csv + - type: application/json+rdf + href: http://localhost:3030/proposed_negative_statutory_instrument_index.rj + - type: application/json+ld + href: http://localhost:3030/proposed_negative_statutory_instrument_index.json + - type: application/rdf+xml + href: http://localhost:3030/proposed_negative_statutory_instrument_index.xml + open-graph: + title: proposed-negative-statutory-instruments.index.title + original-url: http://www.example.com/proposed-negative-statutory-instruments + image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png + image-width: '1200' + image-height: '630' + twitter-card: summary_large_image header-components: - name: link data: diff --git a/spec/fixtures/controllers/statutory_instruments_controller/index/fixture.yml b/spec/fixtures/controllers/statutory_instruments_controller/index/fixture.yml index 00eaf4b5..e6da0ec7 100644 --- a/spec/fixtures/controllers/statutory_instruments_controller/index/fixture.yml +++ b/spec/fixtures/controllers/statutory_instruments_controller/index/fixture.yml @@ -3,6 +3,29 @@ layout: template: layout meta: title: statutory-instruments.index.title + request-id: 123456 + data-alternates: + - type: application/n-triples + href: http://localhost:3030/statutory_instrument_index.nt + - type: text/turtle + href: http://localhost:3030/statutory_instrument_index.ttl + - type: text/tab-separated-values + href: http://localhost:3030/statutory_instrument_index.tsv + - type: text/csv + href: http://localhost:3030/statutory_instrument_index.csv + - type: application/json+rdf + href: http://localhost:3030/statutory_instrument_index.rj + - type: application/json+ld + href: http://localhost:3030/statutory_instrument_index.json + - type: application/rdf+xml + href: http://localhost:3030/statutory_instrument_index.xml + open-graph: + title: statutory-instruments.index.title + original-url: http://www.example.com/statutory-instruments + image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png + image-width: '1200' + image-height: '630' + twitter-card: summary_large_image header-components: - name: link data: diff --git a/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/fixture.yml b/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/fixture.yml index 6c54dc38..6dacd06a 100644 --- a/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/fixture.yml +++ b/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/fixture.yml @@ -3,6 +3,14 @@ layout: template: layout meta: title: Group Test + data-alternates: + open-graph: + title: Group Test + original-url: + image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png + image-width: '1200' + image-height: '630' + twitter-card: summary_large_image header-components: - name: link data: diff --git a/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_missing_data.yml b/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_missing_data.yml index 29b88128..49b67a44 100644 --- a/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_missing_data.yml +++ b/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_missing_data.yml @@ -3,6 +3,14 @@ layout: template: layout meta: title: Group Test + data-alternates: + open-graph: + title: Group Test + original-url: + image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png + image-width: '1200' + image-height: '630' + twitter-card: summary_large_image header-components: - name: link data: diff --git a/spec/fixtures/serializers/page_serializer/home_page_serializer/fixture.yml b/spec/fixtures/serializers/page_serializer/home_page_serializer/fixture.yml index 74223441..1dfc940a 100644 --- a/spec/fixtures/serializers/page_serializer/home_page_serializer/fixture.yml +++ b/spec/fixtures/serializers/page_serializer/home_page_serializer/fixture.yml @@ -3,6 +3,14 @@ layout: template: layout meta: title: beta.parliament.uk + data-alternates: + open-graph: + title: beta.parliament.uk + original-url: + image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png + image-width: '1200' + image-height: '630' + twitter-card: summary_large_image header-components: - name: link data: diff --git a/spec/fixtures/serializers/page_serializer/list_page_serializer/fixture.yml b/spec/fixtures/serializers/page_serializer/list_page_serializer/fixture.yml index cf1dc00e..c583725d 100644 --- a/spec/fixtures/serializers/page_serializer/list_page_serializer/fixture.yml +++ b/spec/fixtures/serializers/page_serializer/list_page_serializer/fixture.yml @@ -3,6 +3,14 @@ layout: template: layout meta: title: Test page + data-alternates: + open-graph: + title: Test page + original-url: + image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png + image-width: '1200' + image-height: '630' + twitter-card: summary_large_image header-components: - name: link data: diff --git a/spec/integration/controllers/groups_controller_spec.rb b/spec/integration/controllers/groups_controller_spec.rb index 9d128098..3d334be8 100644 --- a/spec/integration/controllers/groups_controller_spec.rb +++ b/spec/integration/controllers/groups_controller_spec.rb @@ -9,10 +9,11 @@ context 'navigating to the index page' do it 'renders expected JSON output' do get '/groups' + filtered_response_body = filter_sensitive_data(response.body) expected_json = get_fixture('index', 'fixture') - expect(JSON.parse(response.body).to_yaml).to eq(expected_json) + expect(JSON.parse(filtered_response_body).to_yaml).to eq(expected_json) end end end @@ -25,6 +26,7 @@ context 'navigating to the show page' do it 'renders expected JSON output' do get '/groups/0RNgrC4q' + filtered_response_body = filter_sensitive_data(response.body) expected_json = get_fixture('show', 'fixture') diff --git a/spec/serializers/page_serializer/home_page_serializer_spec.rb b/spec/serializers/page_serializer/home_page_serializer_spec.rb index f69eaa38..82739848 100644 --- a/spec/serializers/page_serializer/home_page_serializer_spec.rb +++ b/spec/serializers/page_serializer/home_page_serializer_spec.rb @@ -4,6 +4,7 @@ context '#to_h' do it 'produces a JSON hash' do + expected = get_fixture('fixture') expect(subject.to_yaml).to eq expected