diff --git a/.gitignore b/.gitignore index e1ca220d..2b85245d 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ /doc /.yardoc +.DS_Store diff --git a/Gemfile.lock b/Gemfile.lock index 8a4f1758..83aba0ed 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -125,7 +125,7 @@ GEM parliament-grom-decorators (0.31.1) parliament-ntriple (0.4.0) grom (~> 1.0) - parliament-opensearch (0.6.0) + parliament-opensearch (0.7.0) activesupport (>= 5.0.0.1) feedjira (~> 2.1, >= 2.1.2) parliament-routes (0.6.13) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7798f7a3..b0fb58e0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -9,7 +9,7 @@ class ApplicationController < ActionController::API attr_reader :app_insights_request_id - before_action :populate_request_id, :reset_alternates + before_action :reset_alternates # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. @@ -35,7 +35,7 @@ def render_page(serializer, response_parameter = response) render json: serializer.to_h end - def populate_request_id - @app_insights_request_id = request.env['ApplicationInsights.request.id'] + def default_url_options + { port: nil, protocol: 'https' } end end diff --git a/app/controllers/concerns/application_helper.rb b/app/controllers/concerns/application_helper.rb index 5b20a4ce..f81b019f 100644 --- a/app/controllers/concerns/application_helper.rb +++ b/app/controllers/concerns/application_helper.rb @@ -78,11 +78,11 @@ def data_url self.class::ROUTE_MAP[params[:action].to_sym] || raise(StandardError, "You must provide a ROUTE_MAP proc for #{params[:controller]}##{params[:action]}") end - # Populates @request with a data url which can be used within controllers. + # Populates @api_request with a data url which can be used within controllers. def build_request - @request = data_url.call(params) + @api_request = data_url.call(params) - populate_alternates(@request.query_url) + populate_alternates(@api_request.query_url) end # Populates @alternates with a list of data formats and corresponding urls diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index bde48961..bb245d7e 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -8,7 +8,7 @@ class GroupsController < ApplicationController }.freeze def index - @groups = FilterHelper.filter(@request, 'Group') + @groups = FilterHelper.filter(@api_request, 'Group') list_components = @groups.map do |group| paragraph_content = [].tap do |content| @@ -22,16 +22,16 @@ def index ).build_card end - serializer = PageSerializer::ListPageSerializer.new(page_title: 'groups.index.title', list_components: list_components, request_id: app_insights_request_id, data_alternates: @alternates, request_original_url: request.original_url) + serializer = PageSerializer::ListPageSerializer.new(request: request, page_title: 'groups.index.title', list_components: list_components, data_alternates: @alternates) render_page(serializer) end def show - @group = FilterHelper.filter(@request, 'Group') + @group = FilterHelper.filter(@api_request, 'Group') @group = @group.first - serializer = PageSerializer::GroupsShowPageSerializer.new(group: @group, request_id: app_insights_request_id, data_alternates: @alternates, request_original_url: request.original_url) + serializer = PageSerializer::GroupsShowPageSerializer.new(request: request, group: @group, data_alternates: @alternates) render_page(serializer) end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index d29b7bc5..37cd019a 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(request_id: app_insights_request_id, request_original_url: request.original_url)) + render_page(PageSerializer::HomePageSerializer.new(request: request)) end end diff --git a/app/controllers/proposed_negative_statutory_instruments_controller.rb b/app/controllers/proposed_negative_statutory_instruments_controller.rb index 6ff51f6e..74c1e689 100644 --- a/app/controllers/proposed_negative_statutory_instruments_controller.rb +++ b/app/controllers/proposed_negative_statutory_instruments_controller.rb @@ -8,7 +8,7 @@ class ProposedNegativeStatutoryInstrumentsController < ApplicationController }.freeze def index - @proposed_negative_statutory_instruments = FilterHelper.filter(@request, 'ProposedNegativeStatutoryInstrumentPaper') + @proposed_negative_statutory_instruments = FilterHelper.filter(@api_request, 'ProposedNegativeStatutoryInstrumentPaper') list_components = @proposed_negative_statutory_instruments.map do |proposed_negative_statutory_instrument| CardFactory.new( @@ -17,16 +17,16 @@ def index ).build_card end - serializer = PageSerializer::ListPageSerializer.new(page_title: 'proposed-negative-statutory-instruments.index.title', list_components: list_components, request_id: app_insights_request_id, data_alternates: @alternates, request_original_url: request.original_url) + serializer = PageSerializer::ListPageSerializer.new(request: request, page_title: 'proposed-negative-statutory-instruments.index.title', list_components: list_components, data_alternates: @alternates) render_page(serializer) end def show - @proposed_negative_statutory_instrument = FilterHelper.filter(@request, 'ProposedNegativeStatutoryInstrumentPaper') + @proposed_negative_statutory_instrument = FilterHelper.filter(@api_request, 'ProposedNegativeStatutoryInstrumentPaper') @proposed_negative_statutory_instrument = @proposed_negative_statutory_instrument.first - serializer = PageSerializer::ProposedNegativeStatutoryInstrumentsShowPageSerializer.new(proposed_negative_statutory_instrument: @proposed_negative_statutory_instrument, request_id: app_insights_request_id, data_alternates: @alternates, request_original_url: request.original_url) + serializer = PageSerializer::ProposedNegativeStatutoryInstrumentsShowPageSerializer.new(request: request, proposed_negative_statutory_instrument: @proposed_negative_statutory_instrument, data_alternates: @alternates) render_page(serializer) end diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 80759066..ac460fe3 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,17 +1,17 @@ class SearchController < ApplicationController def index # Show the index page if there is no query or an empty string is passed - return render_page(PageSerializer::SearchPage::LandingPageSerializer.new(opensearch_description_url: opensearch_description_url, flash_message: search_service.flash_message, request_id: app_insights_request_id, request_original_url: request.original_url)) unless search_service.sanitised_query.present? + return render_page(PageSerializer::SearchPage::LandingPageSerializer.new(request: request, flash_message: search_service.flash_message)) unless search_service.sanitised_query.present? search_service.fetch_description begin - serialiser = PageSerializer::SearchPage::ResultsPageSerializer.new(opensearch_description_url: opensearch_description_url, query: search_service.sanitised_query, results: search_service.results, pagination_hash: search_service.pagination_hash, request_id: app_insights_request_id, request_original_url: request.original_url) + serialiser = PageSerializer::SearchPage::ResultsPageSerializer.new(request: request, query: search_service.sanitised_query, results: search_service.results, pagination_hash: search_service.pagination_hash) return render_page(serialiser) rescue Parliament::ServerError => e logger.warn "Server error caught from search request: #{e.message}" - serialiser = PageSerializer::SearchPage::ResultsPageSerializer.new(opensearch_description_url: opensearch_description_url, query: search_service.sanitised_query, request_id: app_insights_request_id, request_original_url: request.original_url) + serialiser = PageSerializer::SearchPage::ResultsPageSerializer.new(request: request, query: search_service.sanitised_query) return render_page(serialiser) end @@ -34,6 +34,6 @@ def opensearch private def search_service - @search_service ||= SearchService.new(app_insights_request_id, search_path, params) + @search_service ||= SearchService.new(request.env['ApplicationInsights.request.id'], search_path, params) end end diff --git a/app/controllers/statutory_instruments_controller.rb b/app/controllers/statutory_instruments_controller.rb index e6cca83d..5df1ee42 100644 --- a/app/controllers/statutory_instruments_controller.rb +++ b/app/controllers/statutory_instruments_controller.rb @@ -8,7 +8,7 @@ class StatutoryInstrumentsController < ApplicationController }.freeze def index - @statutory_instruments = FilterHelper.filter(@request, 'StatutoryInstrumentPaper') + @statutory_instruments = FilterHelper.filter(@api_request, 'StatutoryInstrumentPaper') list_components = @statutory_instruments.map do |statutory_instrument| CardFactory.new( @@ -17,16 +17,16 @@ def index ).build_card end - serializer = PageSerializer::ListPageSerializer.new(page_title: 'statutory-instruments.index.title', list_components: list_components, request_id: app_insights_request_id, data_alternates: @alternates, request_original_url: request.original_url) + serializer = PageSerializer::ListPageSerializer.new(request: request, page_title: 'statutory-instruments.index.title', list_components: list_components, data_alternates: @alternates) render_page(serializer) end def show - @statutory_instrument = FilterHelper.filter(@request, 'StatutoryInstrumentPaper') + @statutory_instrument = FilterHelper.filter(@api_request, 'StatutoryInstrumentPaper') @statutory_instrument = @statutory_instrument.first - serializer = PageSerializer::StatutoryInstrumentsShowPageSerializer.new(statutory_instrument: @statutory_instrument, request_id: app_insights_request_id, data_alternates: @alternates, request_original_url: request.original_url) + serializer = PageSerializer::StatutoryInstrumentsShowPageSerializer.new(request: request, statutory_instrument: @statutory_instrument, data_alternates: @alternates) render_page(serializer) end diff --git a/app/serializers/page_serializer/base_page_serializer.rb b/app/serializers/page_serializer/base_page_serializer.rb index a289170d..310c92e1 100644 --- a/app/serializers/page_serializer/base_page_serializer.rb +++ b/app/serializers/page_serializer/base_page_serializer.rb @@ -1,12 +1,16 @@ module PageSerializer class BasePageSerializer < BaseSerializer include OpenGraphHelper - attr_reader :request_id, :data_alternates + attr_reader :request, :request_id, :data_alternates, :request_original_url + include ActionDispatch::Routing::UrlFor - def initialize(request_id: nil, data_alternates: nil, request_original_url: nil) - @request_id = request_id if request_id + # @param [ActionDispatch::Request] request the current request object. + # @param [Array] data_alternates array containing the href and type of the alternative data urls. + def initialize(request: nil, data_alternates: nil) + @request = request + @request_id = request.try(:env)&.fetch('ApplicationInsights.request.id', nil) if request @data_alternates = data_alternates - @request_original_url = request_original_url + @request_original_url = generate_original_url end # Creates a hash of the serializer's content @@ -54,19 +58,31 @@ def footer_section(hash) end end - def opensearch_description_url - raise 'You must implement #opensearch_description_url' - end - def meta(title: nil, image_id: nil) {}.tap do |meta| meta[:title] = title - meta[:request_id] = @request_id if @request_id - meta[:data_alternates] = @data_alternates - meta[:open_graph] = OpenGraphHelper.information(page_title: title, request_original_url: @request_original_url, image_id: image_id) + meta[:request_id] = request_id if request_id + meta[:data_alternates] = data_alternates if data_alternates + + meta[:open_graph] = OpenGraphHelper.information(page_title: title, request_original_url: request_original_url, image_id: image_id) + + meta[:opensearch_description_url] = url_for(host: request.try(:host), protocol: 'https', port: nil, controller: 'search', action: 'opensearch') if request.try(:host) end end + def generate_original_url + begin + uri_object = URI.parse(request.try(:original_url)) + rescue URI::InvalidURIError + return nil + end + + uri_object.port = nil + uri_object.scheme = 'https' + + uri_object.to_s + end + # Sets the default for including global search in the header to true. def include_global_search true diff --git a/app/serializers/page_serializer/groups_show_page_serializer.rb b/app/serializers/page_serializer/groups_show_page_serializer.rb index bafe9c0d..6227d83a 100644 --- a/app/serializers/page_serializer/groups_show_page_serializer.rb +++ b/app/serializers/page_serializer/groups_show_page_serializer.rb @@ -2,14 +2,13 @@ module PageSerializer class GroupsShowPageSerializer < PageSerializer::BasePageSerializer # Initialise a Groups show page serializer. # + # @param [ActionDispatch::Request] request the current request object. # @param [] group a Grom::Node object of type StatutoryInstrumentPaper. - # @param [String] request_id AppInsights request id - # @param [Array] data_alternates array containing the href and type of the alternative data urls - # @param [String] request_original_url original url of the request - def initialize(group: nil, request_id: nil, data_alternates: nil, request_original_url: nil) + # @param [Array] data_alternates array containing the href and type of the alternative data urls. + def initialize(request: nil, group: nil, data_alternates: nil) @group = group - super(request_id: request_id, data_alternates: data_alternates, request_original_url: request_original_url) + super(request: request, data_alternates: data_alternates) end private diff --git a/app/serializers/page_serializer/home_page_serializer.rb b/app/serializers/page_serializer/home_page_serializer.rb index a6025116..9603ae51 100644 --- a/app/serializers/page_serializer/home_page_serializer.rb +++ b/app/serializers/page_serializer/home_page_serializer.rb @@ -1,19 +1,7 @@ module PageSerializer class HomePageSerializer < PageSerializer::BasePageSerializer - # This serializer includes HousesHelper - # Initialise a Home index page serializer. - # - # @param [String] opensearch_description_url a description url for the search. - 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 - attr_reader :opensearch_description_url - def meta super(title: 'beta.parliament.uk') end diff --git a/app/serializers/page_serializer/laid_thing_show_page_serializer.rb b/app/serializers/page_serializer/laid_thing_show_page_serializer.rb index 1a0c16bf..33136804 100644 --- a/app/serializers/page_serializer/laid_thing_show_page_serializer.rb +++ b/app/serializers/page_serializer/laid_thing_show_page_serializer.rb @@ -2,18 +2,17 @@ module PageSerializer class LaidThingShowPageSerializer < PageSerializer::BasePageSerializer # Initialise a Laid Thing show page serializer. # + # @param [ActionDispatch::Request] request the current request object. # @param [] laid_thing a Grom::Node object of type LaidThing. - # @param [String] request_id AppInsights request id - # @param [Array] data_alternates array containing the href and type of the alternative data urls - # @param [String] request_original_url original url of the request - def initialize(laid_thing:, request_id: nil, data_alternates: nil, request_original_url: nil) + # @param [Array] data_alternates array containing the href and type of the alternative data urls. + def initialize(request: nil, laid_thing:, data_alternates: nil) @laid_thing = laid_thing @work_package = @laid_thing.work_package @laying_body = @laid_thing&.laying&.body @laying_person = @laid_thing&.laying&.person @procedure = @work_package&.procedure - super(request_id: request_id, data_alternates: data_alternates, request_original_url: request_original_url) + super(request: request, data_alternates: data_alternates) end private diff --git a/app/serializers/page_serializer/list_page_serializer.rb b/app/serializers/page_serializer/list_page_serializer.rb index 0e25dc48..6087da00 100644 --- a/app/serializers/page_serializer/list_page_serializer.rb +++ b/app/serializers/page_serializer/list_page_serializer.rb @@ -2,17 +2,16 @@ module PageSerializer class ListPageSerializer < PageSerializer::BasePageSerializer # Initialise a list page serializer. # + # @param [ActionDispatch::Request] request the current request object # @param [String] page_title title of the page # @param [Array] list_components an array of components to be passed into the list - # @param [String] request_id AppInsights request id - # @param [Array] data_alternates array containing the href and type of the alternative data urls - # @param [String] request_original_url original url of the request - def initialize(page_title: nil, list_components: nil, request_id: nil, data_alternates: nil, request_original_url: nil) + # @param [Array] data_alternates array containing the href and type of the alternative data url + def initialize(request: nil, page_title: nil, list_components: nil, data_alternates: nil) @page_title = page_title @list_components = list_components @data_alternates = data_alternates - super(request_id: request_id, data_alternates: data_alternates, request_original_url: request_original_url) + super(request: request, data_alternates: data_alternates) end private diff --git a/app/serializers/page_serializer/proposed_negative_statutory_instruments_show_page_serializer.rb b/app/serializers/page_serializer/proposed_negative_statutory_instruments_show_page_serializer.rb index f2d216e4..f11874fc 100644 --- a/app/serializers/page_serializer/proposed_negative_statutory_instruments_show_page_serializer.rb +++ b/app/serializers/page_serializer/proposed_negative_statutory_instruments_show_page_serializer.rb @@ -2,15 +2,14 @@ module PageSerializer class ProposedNegativeStatutoryInstrumentsShowPageSerializer < LaidThingShowPageSerializer # Initialise a Proposed Negative Statutory Instruments show page serializer. # + # @param [ActionDispatch::Request] request the current request object. # @param [] proposed_negative_statutory_instrument a Grom::Node object of type ProposedNegativeStatutoryInstrumentPaper. - # @param [String] request_id AppInsights request id # @param [Array] data_alternates array containing the href and type of the alternative data urls - # @param [String] request_original_url original url of the request - def initialize(proposed_negative_statutory_instrument:, request_id: nil, data_alternates: nil, request_original_url: nil) + def initialize(request: nil, proposed_negative_statutory_instrument:, data_alternates: nil) @proposed_negative_statutory_instrument = proposed_negative_statutory_instrument @following_statutory_instruments = @proposed_negative_statutory_instrument.statutory_instrument_papers - super(laid_thing: @proposed_negative_statutory_instrument, request_id: request_id, data_alternates: data_alternates, request_original_url: request_original_url) + super(request: request, laid_thing: @proposed_negative_statutory_instrument, data_alternates: data_alternates) end private diff --git a/app/serializers/page_serializer/search_page.rb b/app/serializers/page_serializer/search_page.rb index 8740a1c3..bf859b0c 100644 --- a/app/serializers/page_serializer/search_page.rb +++ b/app/serializers/page_serializer/search_page.rb @@ -2,21 +2,20 @@ module PageSerializer class SearchPage < PageSerializer::BasePageSerializer # Initialise a Search index page serializer. # + # @param [ActionDispatch::Request] request the current request object. # @param [String] opensearch_description_url a description url for the search. # @param [String] query a query string used for the search. # @param [Array] results an array of objects used for displaying results. # @param [Hash] pagination_hash a hash containing data used for pagination. # @param [String] flash_message a translation block that is evaluated into a flash message. - # @param [String] request_id AppInsights request id - # @param [String] request_original_url original url of the request - def initialize(opensearch_description_url: nil, query: nil, results: nil, pagination_hash: nil, flash_message: nil, request_id: nil, request_original_url: nil) + def initialize(request: nil, opensearch_description_url: nil, query: nil, results: nil, pagination_hash: nil, flash_message: nil) @opensearch_description_url = opensearch_description_url @query = query @results = results @pagination_helper = PaginationHelper.new(pagination_hash) if pagination_hash @flash_message = flash_message - super(request_id: request_id, data_alternates: nil, request_original_url: request_original_url) + super(request: request, data_alternates: nil) end private diff --git a/app/serializers/page_serializer/search_page/landing_page_serializer.rb b/app/serializers/page_serializer/search_page/landing_page_serializer.rb index 5c23e78a..cdb68940 100644 --- a/app/serializers/page_serializer/search_page/landing_page_serializer.rb +++ b/app/serializers/page_serializer/search_page/landing_page_serializer.rb @@ -6,9 +6,7 @@ class LandingPageSerializer < PageSerializer::SearchPage private def meta - super(title: title).tap do |meta| - meta[:opensearch_description_url] = opensearch_description_url if opensearch_description_url - end + super(title: title) end def title diff --git a/app/serializers/page_serializer/statutory_instruments_show_page_serializer.rb b/app/serializers/page_serializer/statutory_instruments_show_page_serializer.rb index 11e285a8..a8fdc746 100644 --- a/app/serializers/page_serializer/statutory_instruments_show_page_serializer.rb +++ b/app/serializers/page_serializer/statutory_instruments_show_page_serializer.rb @@ -2,15 +2,14 @@ module PageSerializer class StatutoryInstrumentsShowPageSerializer < LaidThingShowPageSerializer # Initialise a Statutory Instruments show page serializer. # + # @param [ActionDispatch::Request] request the current request object. # @param [] statutory_instrument a Grom::Node object of type StatutoryInstrumentPaper. - # @param [String] request_id AppInsights request id - # @param [Array] data_alternates array containing the href and type of the alternative data urls - # @param [String] request_original_url original url of the request - def initialize(statutory_instrument:, request_id: nil, data_alternates: nil, request_original_url: nil) + # @param [Array] data_alternates array containing the href and type of the alternative data urls. + def initialize(request: nil, statutory_instrument:, data_alternates: nil) @statutory_instrument = statutory_instrument @preceding_proposed_negative_statutory_instruments = @statutory_instrument.proposed_negative_statutory_instrument_papers - super(laid_thing: @statutory_instrument, request_id: request_id, data_alternates: data_alternates, request_original_url: request_original_url) + super(request: request, laid_thing: @statutory_instrument, data_alternates: data_alternates) end private diff --git a/app/services/search_service.rb b/app/services/search_service.rb index e73fe2fb..29714381 100644 --- a/app/services/search_service.rb +++ b/app/services/search_service.rb @@ -51,8 +51,6 @@ def pagination_hash def build_request headers = {}.tap do |hash| - hash['Accept'] = 'application/atom+xml' - hash['Ocp-Apim-Subscription-Key'] = ENV['OPENSEARCH_AUTH_TOKEN'] hash['Request-Id'] = "#{app_insights_request_id}1" if app_insights_request_id end diff --git a/config/initializers/timeout.rb b/config/initializers/timeout.rb index f7cb2603..26f55845 100644 --- a/config/initializers/timeout.rb +++ b/config/initializers/timeout.rb @@ -1,4 +1,4 @@ -if ENV['DISABLE_TIMEOUT'] +if ENV['DISABLE_TIMEOUT'] || Rails.env.test? Rails.application.config.middleware.delete Rack::Timeout else Rails.application.config.middleware.insert_before Rack::Runtime, Rack::Timeout, service_timeout: 5 diff --git a/spec/controllers/group_controller_spec.rb b/spec/controllers/group_controller_spec.rb index f6348d6a..071bc2d5 100644 --- a/spec/controllers/group_controller_spec.rb +++ b/spec/controllers/group_controller_spec.rb @@ -40,7 +40,7 @@ it 'calls the serializer correctly' do list_components = [{"data"=> {"heading"=> {"data"=> {"content"=>"groupName - 1", "link"=>"/groups/tz34m7Vt", "size"=>2}, "name"=>"heading"}, "paragraph"=> {"data"=> [{"content"=>"28 July 1997 to 12 September 2017"}],"name"=>"paragraph"}}, "name"=>"card__generic"}] - expect(PageSerializer::ListPageSerializer).to have_received(:new).with(page_title: "groups.index.title", list_components: list_components, request_id: '|1234abcd.', data_alternates: data_alternates, request_original_url: request.original_url) + expect(PageSerializer::ListPageSerializer).to have_received(:new).with(request: request, page_title: "groups.index.title", list_components: list_components, data_alternates: data_alternates) end end @@ -82,7 +82,7 @@ it 'calls the serializer correctly' do group = assigns(:group) - expect(PageSerializer::GroupsShowPageSerializer).to have_received(:new).with(group: group, request_id: '|1234abcd.', data_alternates: data_alternates, request_original_url: request.original_url) + expect(PageSerializer::GroupsShowPageSerializer).to have_received(:new).with(request: request, group: group, data_alternates: data_alternates) end end end diff --git a/spec/controllers/proposed_negative_statutory_instruments_controller_spec.rb b/spec/controllers/proposed_negative_statutory_instruments_controller_spec.rb index 112046bf..1191ac32 100644 --- a/spec/controllers/proposed_negative_statutory_instruments_controller_spec.rb +++ b/spec/controllers/proposed_negative_statutory_instruments_controller_spec.rb @@ -41,7 +41,7 @@ it 'calls the serializer correctly' do list_components = [{"data"=> {"heading"=> {"data"=> {"content"=>"proposedNegativeStatutoryInstrumentPaperName - 1", "link"=>"/proposed-negative-statutory-instruments/Tn1xqHc0", "size"=>2}, "name"=>"heading"}}, "name"=>"card__generic"}] - expect(PageSerializer::ListPageSerializer).to have_received(:new).with(page_title: "proposed-negative-statutory-instruments.index.title", list_components: list_components, request_id: '|1234abcd.', data_alternates: data_alternates, request_original_url: request.original_url) + expect(PageSerializer::ListPageSerializer).to have_received(:new).with(request: request, page_title: "proposed-negative-statutory-instruments.index.title", list_components: list_components, data_alternates: data_alternates) end end @@ -83,7 +83,7 @@ it 'calls the serializer correctly' do statutory_instrument = assigns(:proposed_negative_statutory_instrument) - expect(PageSerializer::ProposedNegativeStatutoryInstrumentsShowPageSerializer).to have_received(:new).with(proposed_negative_statutory_instrument: statutory_instrument, request_id: '|1234abcd.', data_alternates: data_alternates, request_original_url: request.original_url) + expect(PageSerializer::ProposedNegativeStatutoryInstrumentsShowPageSerializer).to have_received(:new).with(request: request, proposed_negative_statutory_instrument: statutory_instrument, data_alternates: data_alternates) end end end diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb index cdec7470..8da0cb60 100644 --- a/spec/controllers/search_controller_spec.rb +++ b/spec/controllers/search_controller_spec.rb @@ -22,12 +22,10 @@ context 'with a query' do context 'with a valid search' do before(:each) do - allow(controller.request).to receive(:env).and_return({'ApplicationInsights.request.id' => '|1234abcd.'}) + allow_any_instance_of(ActionController::TestRequest).to receive(:env).and_return({'ApplicationInsights.request.id' => '|1234abcd.'}) allow(PageSerializer::SearchPage::ResultsPageSerializer).to receive(:new) - end - before(:each) do search_service_instance = double( 'search_service_instance', query_nil_or_empty?: false, @@ -55,7 +53,7 @@ end it 'calls the serializer with the correct arguments' do - expect(PageSerializer::SearchPage::ResultsPageSerializer).to have_received(:new).with(opensearch_description_url: 'http://:/search/opensearch', query: 'banana', results: [1, 2, 3], pagination_hash: 'pagination_hash', request_id: '|1234abcd.', request_original_url: request.original_url) + expect(PageSerializer::SearchPage::ResultsPageSerializer).to have_received(:new).with(request: request, query: 'banana', results: [1, 2, 3], pagination_hash: 'pagination_hash') end end @@ -81,7 +79,7 @@ query: 'fdsfsd' } - expect(PageSerializer::SearchPage::ResultsPageSerializer).to have_received(:new).with(opensearch_description_url: 'http://test.host/search/opensearch', query: 'fdsfsd', results: an_instance_of(Feedjira::Parser::Atom), pagination_hash: pagination_hash, request_id: '|1234abcd.', request_original_url: request.original_url) + expect(PageSerializer::SearchPage::ResultsPageSerializer).to have_received(:new).with(request: request, query: 'fdsfsd', results: an_instance_of(Feedjira::Parser::Atom), pagination_hash: pagination_hash) end end @@ -98,7 +96,7 @@ end it 'calls the serializer with the correct arguments' do - expect(PageSerializer::SearchPage::LandingPageSerializer).to have_received(:new).with(opensearch_description_url: 'http://test.host/search/opensearch', flash_message: I18n.t('search_controller.index.flash'), request_id: '|1234abcd.', request_original_url: request.original_url) + expect(PageSerializer::SearchPage::LandingPageSerializer).to have_received(:new).with(request: request, flash_message: I18n.t('search_controller.index.flash')) end end @@ -161,7 +159,7 @@ get :index, params: { q: 'Allan Wazacz' } - expect(PageSerializer::SearchPage::ResultsPageSerializer).to have_received(:new).with(opensearch_description_url: 'http://test.host/search/opensearch', query: 'Allan Wazacz', request_id: '|1234abcd.', request_original_url: request.original_url) + expect(PageSerializer::SearchPage::ResultsPageSerializer).to have_received(:new).with(request: request, query: 'Allan Wazacz') end end end @@ -182,8 +180,8 @@ UK Parliament Search UK Parliament online content - http://test.host/favicon.ico - + https://test.host/favicon.ico + XML diff --git a/spec/controllers/statutory_instruments_controller_spec.rb b/spec/controllers/statutory_instruments_controller_spec.rb index 6660c8ad..a9d170f7 100644 --- a/spec/controllers/statutory_instruments_controller_spec.rb +++ b/spec/controllers/statutory_instruments_controller_spec.rb @@ -41,7 +41,7 @@ it 'calls the serializer correctly' do list_components = [{"data"=> {"heading"=> {"data"=> {"content"=>"statutoryInstrumentPaperName - 1", "link"=>"/statutory-instruments/5trFJNih", "size"=>2}, "name"=>"heading"}}, "name"=>"card__generic"}] - expect(PageSerializer::ListPageSerializer).to have_received(:new).with(page_title: "statutory-instruments.index.title", list_components: list_components, request_id: '|1234abcd.', data_alternates: data_alternates, request_original_url: request.original_url) + expect(PageSerializer::ListPageSerializer).to have_received(:new).with(request: request, page_title: "statutory-instruments.index.title", list_components: list_components, data_alternates: data_alternates) end end @@ -83,7 +83,7 @@ it 'calls the serializer correctly' do statutory_instrument = assigns(:statutory_instrument) - expect(PageSerializer::StatutoryInstrumentsShowPageSerializer).to have_received(:new).with(statutory_instrument: statutory_instrument, request_id: '|1234abcd.', data_alternates: data_alternates, request_original_url: request.original_url) + expect(PageSerializer::StatutoryInstrumentsShowPageSerializer).to have_received(:new).with(request: request, statutory_instrument: statutory_instrument, data_alternates: data_alternates) end end end diff --git a/spec/fixtures/controllers/groups_controller/index/fixture.yml b/spec/fixtures/controllers/groups_controller/index/fixture.yml index 00d41afe..2c6773be 100644 --- a/spec/fixtures/controllers/groups_controller/index/fixture.yml +++ b/spec/fixtures/controllers/groups_controller/index/fixture.yml @@ -21,11 +21,12 @@ meta: href: http://localhost:3030/group_index.xml open-graph: title: groups.index.title - original-url: http://www.example.com/groups + original-url: https://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 + opensearch-description-url: https://www.example.com/search/opensearch 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 c1d4368a..d36eac13 100644 --- a/spec/fixtures/controllers/groups_controller/show/fixture.yml +++ b/spec/fixtures/controllers/groups_controller/show/fixture.yml @@ -21,11 +21,12 @@ meta: href: http://localhost:3030/group_by_id.xml?group_id=0RNgrC4q open-graph: title: groupName - 1 - original-url: http://www.example.com/groups/0RNgrC4q + original-url: https://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 + opensearch-description-url: https://www.example.com/search/opensearch 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 1098503c..1379d2f8 100644 --- a/spec/fixtures/controllers/home_controller/index/fixture.yml +++ b/spec/fixtures/controllers/home_controller/index/fixture.yml @@ -4,14 +4,14 @@ layout: meta: title: beta.parliament.uk request-id: 123456 - data-alternates: open-graph: title: beta.parliament.uk - original-url: http://www.example.com/ + original-url: https://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 + opensearch-description-url: https://www.example.com/search/opensearch 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 93ca33dc..08e8ccaf 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 @@ -21,11 +21,12 @@ meta: 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 + original-url: https://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 + opensearch-description-url: https://www.example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/controllers/proposed_negative_statutory_instruments_controller/show/fixture.yml b/spec/fixtures/controllers/proposed_negative_statutory_instruments_controller/show/fixture.yml index bbb79d12..2310b873 100644 --- a/spec/fixtures/controllers/proposed_negative_statutory_instruments_controller/show/fixture.yml +++ b/spec/fixtures/controllers/proposed_negative_statutory_instruments_controller/show/fixture.yml @@ -21,11 +21,12 @@ meta: href: http://localhost:3030/proposed_negative_statutory_instrument_by_id.xml?proposed_negative_statutory_instrument_id=12345678 open-graph: title: proposedNegativeStatutoryInstrumentPaperName - 1 - original-url: http://www.example.com/proposed-negative-statutory-instruments/12345678 + original-url: https://www.example.com/proposed-negative-statutory-instruments/12345678 image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://www.example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/controllers/search_controller/index/edgecase.yml b/spec/fixtures/controllers/search_controller/index/edgecase.yml index 74c3cfbf..6e8cb246 100644 --- a/spec/fixtures/controllers/search_controller/index/edgecase.yml +++ b/spec/fixtures/controllers/search_controller/index/edgecase.yml @@ -4,17 +4,16 @@ layout: meta: title: test - Search - UK Parliament request-id: 123456 - data-alternates: open-graph: title: test - Search - UK Parliament - original-url: http://www.example.com/search?count=100&q=test&start_index=70100 + original-url: https://www.example.com/search?count=100&q=test&start_index=70100 image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://www.example.com/search/opensearch components: - name: head__search-result-tracking - opensearch-description-url: http://www.example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/controllers/search_controller/index/empty_query.yml b/spec/fixtures/controllers/search_controller/index/empty_query.yml index 506b0391..8ed34c72 100644 --- a/spec/fixtures/controllers/search_controller/index/empty_query.yml +++ b/spec/fixtures/controllers/search_controller/index/empty_query.yml @@ -4,15 +4,14 @@ layout: meta: title: No Results - Search - UK Parliament request-id: 123456 - data-alternates: open-graph: title: No Results - Search - UK Parliament - original-url: http://www.example.com/search?q= + original-url: https://www.example.com/search?q= image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image - opensearch-description-url: http://www.example.com/search/opensearch + opensearch-description-url: https://www.example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/controllers/search_controller/index/last_page.yml b/spec/fixtures/controllers/search_controller/index/last_page.yml index c7ff5fcd..27b46181 100644 --- a/spec/fixtures/controllers/search_controller/index/last_page.yml +++ b/spec/fixtures/controllers/search_controller/index/last_page.yml @@ -4,17 +4,16 @@ layout: meta: title: diane abbott - Search - UK Parliament request-id: 123456 - data-alternates: open-graph: title: diane abbott - Search - UK Parliament - original-url: http://www.example.com/search?count=10&q=diane+abbott&start_index=7471 + original-url: https://www.example.com/search?count=10&q=diane+abbott&start_index=7471 image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://www.example.com/search/opensearch components: - name: head__search-result-tracking - opensearch-description-url: http://www.example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/controllers/search_controller/index/linux_first_page.yml b/spec/fixtures/controllers/search_controller/index/linux_first_page.yml index 7801eb9a..9d7a0be5 100644 --- a/spec/fixtures/controllers/search_controller/index/linux_first_page.yml +++ b/spec/fixtures/controllers/search_controller/index/linux_first_page.yml @@ -4,17 +4,16 @@ layout: meta: title: linux - Search - UK Parliament request-id: 123456 - data-alternates: open-graph: title: linux - Search - UK Parliament - original-url: http://www.example.com/search?q=linux + original-url: https://www.example.com/search?q=linux image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://www.example.com/search/opensearch components: - name: head__search-result-tracking - opensearch-description-url: http://www.example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/controllers/search_controller/index/linux_last_page.yml b/spec/fixtures/controllers/search_controller/index/linux_last_page.yml index 7d8fd275..149dab61 100644 --- a/spec/fixtures/controllers/search_controller/index/linux_last_page.yml +++ b/spec/fixtures/controllers/search_controller/index/linux_last_page.yml @@ -4,17 +4,16 @@ layout: meta: title: linux - Search - UK Parliament request-id: 123456 - data-alternates: open-graph: title: linux - Search - UK Parliament - original-url: http://www.example.com/search?count=10&q=linux&start_index=31 + original-url: https://www.example.com/search?count=10&q=linux&start_index=31 image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://www.example.com/search/opensearch components: - name: head__search-result-tracking - opensearch-description-url: http://www.example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/controllers/search_controller/index/no_results.yml b/spec/fixtures/controllers/search_controller/index/no_results.yml index 9ecb411d..7ee996c7 100644 --- a/spec/fixtures/controllers/search_controller/index/no_results.yml +++ b/spec/fixtures/controllers/search_controller/index/no_results.yml @@ -4,15 +4,14 @@ layout: meta: title: dfgdfh89rhosiubreoweh - Search - UK Parliament request-id: 123456 - data-alternates: open-graph: title: dfgdfh89rhosiubreoweh - Search - UK Parliament - original-url: http://www.example.com/search?q=dfgdfh89rhosiubreoweh + original-url: https://www.example.com/search?q=dfgdfh89rhosiubreoweh image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image - opensearch-description-url: http://www.example.com/search/opensearch + opensearch-description-url: https://www.example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/controllers/search_controller/index/search.yml b/spec/fixtures/controllers/search_controller/index/search.yml index 46221dce..191213ac 100644 --- a/spec/fixtures/controllers/search_controller/index/search.yml +++ b/spec/fixtures/controllers/search_controller/index/search.yml @@ -4,15 +4,14 @@ layout: meta: title: Search - UK Parliament request-id: 123456 - data-alternates: open-graph: title: Search - UK Parliament - original-url: http://www.example.com/search + original-url: https://www.example.com/search image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image - opensearch-description-url: http://www.example.com/search/opensearch + opensearch-description-url: https://www.example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/controllers/search_controller/index/second_page.yml b/spec/fixtures/controllers/search_controller/index/second_page.yml index 98d769eb..25665ef5 100644 --- a/spec/fixtures/controllers/search_controller/index/second_page.yml +++ b/spec/fixtures/controllers/search_controller/index/second_page.yml @@ -4,17 +4,16 @@ layout: meta: title: diane abbott - Search - UK Parliament request-id: 123456 - data-alternates: open-graph: title: diane abbott - Search - UK Parliament - original-url: http://www.example.com/search?count=10&q=diane+abbott&start_index=11 + original-url: https://www.example.com/search?count=10&q=diane+abbott&start_index=11 image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://www.example.com/search/opensearch components: - name: head__search-result-tracking - opensearch-description-url: http://www.example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/controllers/search_controller/index/with_a_query.yml b/spec/fixtures/controllers/search_controller/index/with_a_query.yml index 2e32ebc5..547562b7 100644 --- a/spec/fixtures/controllers/search_controller/index/with_a_query.yml +++ b/spec/fixtures/controllers/search_controller/index/with_a_query.yml @@ -4,17 +4,16 @@ layout: meta: title: hello - Search - UK Parliament request-id: 123456 - data-alternates: open-graph: title: hello - Search - UK Parliament - original-url: http://www.example.com/search?q=hello + original-url: https://www.example.com/search?q=hello image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://www.example.com/search/opensearch components: - name: head__search-result-tracking - opensearch-description-url: http://www.example.com/search/opensearch 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 e6da0ec7..0bf01eaf 100644 --- a/spec/fixtures/controllers/statutory_instruments_controller/index/fixture.yml +++ b/spec/fixtures/controllers/statutory_instruments_controller/index/fixture.yml @@ -21,11 +21,12 @@ meta: href: http://localhost:3030/statutory_instrument_index.xml open-graph: title: statutory-instruments.index.title - original-url: http://www.example.com/statutory-instruments + original-url: https://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 + opensearch-description-url: https://www.example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/controllers/statutory_instruments_controller/show/fixture.yml b/spec/fixtures/controllers/statutory_instruments_controller/show/fixture.yml index f107aa7d..3b0f29ff 100644 --- a/spec/fixtures/controllers/statutory_instruments_controller/show/fixture.yml +++ b/spec/fixtures/controllers/statutory_instruments_controller/show/fixture.yml @@ -21,11 +21,12 @@ meta: href: http://localhost:3030/statutory_instrument_by_id.xml?statutory_instrument_id=1234567 open-graph: title: statutoryInstrumentPaperName - 1 - original-url: http://www.example.com/statutory-instruments/1234567 + original-url: https://www.example.com/statutory-instruments/1234567 image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://www.example.com/search/opensearch 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 6dacd06a..882ae500 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,14 +3,15 @@ layout: template: layout meta: title: Group Test - data-alternates: + request-id: 123456 open-graph: title: Group Test - original-url: + original-url: https://example.com/ image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://example.com/search/opensearch 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 49b67a44..4ecc19ce 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,14 +3,15 @@ layout: template: layout meta: title: Group Test - data-alternates: + request-id: 123456 open-graph: title: Group Test - original-url: + original-url: https://example.com/ image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://example.com/search/opensearch 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 1dfc940a..7c5a5afb 100644 --- a/spec/fixtures/serializers/page_serializer/home_page_serializer/fixture.yml +++ b/spec/fixtures/serializers/page_serializer/home_page_serializer/fixture.yml @@ -3,14 +3,15 @@ layout: template: layout meta: title: beta.parliament.uk - data-alternates: + request-id: 123456 open-graph: title: beta.parliament.uk - original-url: + original-url: https://example.com/ image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/serializers/page_serializer/laid_thing_show_page_serializer/fixture.yml b/spec/fixtures/serializers/page_serializer/laid_thing_show_page_serializer/fixture.yml index 02a9a81d..a77d03f9 100644 --- a/spec/fixtures/serializers/page_serializer/laid_thing_show_page_serializer/fixture.yml +++ b/spec/fixtures/serializers/page_serializer/laid_thing_show_page_serializer/fixture.yml @@ -3,14 +3,15 @@ layout: template: layout meta: title: - data-alternates: + request-id: 123456 open-graph: title: - original-url: + original-url: https://example.com/ image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/serializers/page_serializer/laid_thing_show_page_serializer/laid_thing_missing_data.yml b/spec/fixtures/serializers/page_serializer/laid_thing_show_page_serializer/laid_thing_missing_data.yml index 02a9a81d..a77d03f9 100644 --- a/spec/fixtures/serializers/page_serializer/laid_thing_show_page_serializer/laid_thing_missing_data.yml +++ b/spec/fixtures/serializers/page_serializer/laid_thing_show_page_serializer/laid_thing_missing_data.yml @@ -3,14 +3,15 @@ layout: template: layout meta: title: - data-alternates: + request-id: 123456 open-graph: title: - original-url: + original-url: https://example.com/ image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://example.com/search/opensearch 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 c583725d..9156c77c 100644 --- a/spec/fixtures/serializers/page_serializer/list_page_serializer/fixture.yml +++ b/spec/fixtures/serializers/page_serializer/list_page_serializer/fixture.yml @@ -3,14 +3,15 @@ layout: template: layout meta: title: Test page - data-alternates: + request-id: 123456 open-graph: title: Test page - original-url: + original-url: https://example.com/ image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/serializers/page_serializer/proposed_negative_statutory_instruments_show_page_serializer/fixture.yml b/spec/fixtures/serializers/page_serializer/proposed_negative_statutory_instruments_show_page_serializer/fixture.yml index c90fa363..1b433ab5 100644 --- a/spec/fixtures/serializers/page_serializer/proposed_negative_statutory_instruments_show_page_serializer/fixture.yml +++ b/spec/fixtures/serializers/page_serializer/proposed_negative_statutory_instruments_show_page_serializer/fixture.yml @@ -3,14 +3,15 @@ layout: template: layout meta: title: Proposed Negative SI Paper Test - data-alternates: + request-id: 123456 open-graph: title: Proposed Negative SI Paper Test - original-url: + original-url: https://example.com/ image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/serializers/page_serializer/proposed_negative_statutory_instruments_show_page_serializer/si_missing_data.yml b/spec/fixtures/serializers/page_serializer/proposed_negative_statutory_instruments_show_page_serializer/si_missing_data.yml index dcee11af..3e299f06 100644 --- a/spec/fixtures/serializers/page_serializer/proposed_negative_statutory_instruments_show_page_serializer/si_missing_data.yml +++ b/spec/fixtures/serializers/page_serializer/proposed_negative_statutory_instruments_show_page_serializer/si_missing_data.yml @@ -3,14 +3,15 @@ layout: template: layout meta: title: SI Paper Test - data-alternates: + request-id: 123456 open-graph: title: SI Paper Test - original-url: + original-url: https://example.com/ image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/serializers/page_serializer/search_page/landing_page_serializer/with_flash_message.yml b/spec/fixtures/serializers/page_serializer/search_page/landing_page_serializer/with_flash_message.yml index 1719f62a..1b2e1201 100644 --- a/spec/fixtures/serializers/page_serializer/search_page/landing_page_serializer/with_flash_message.yml +++ b/spec/fixtures/serializers/page_serializer/search_page/landing_page_serializer/with_flash_message.yml @@ -3,14 +3,15 @@ layout: template: layout meta: title: No Results - Search - UK Parliament - data-alternates: + request-id: 123456 open-graph: title: No Results - Search - UK Parliament - original-url: + original-url: https://example.com/ image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/serializers/page_serializer/search_page/landing_page_serializer/without_query.yml b/spec/fixtures/serializers/page_serializer/search_page/landing_page_serializer/without_query.yml index de5cc215..5b0d9e33 100644 --- a/spec/fixtures/serializers/page_serializer/search_page/landing_page_serializer/without_query.yml +++ b/spec/fixtures/serializers/page_serializer/search_page/landing_page_serializer/without_query.yml @@ -3,14 +3,15 @@ layout: template: layout meta: title: Search - UK Parliament - data-alternates: + request-id: 123456 open-graph: title: Search - UK Parliament - original-url: + original-url: https://example.com/ image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/serializers/page_serializer/search_page/results_page_serializer/no_results.yml b/spec/fixtures/serializers/page_serializer/search_page/results_page_serializer/no_results.yml index 83a1cc9c..ac718b62 100644 --- a/spec/fixtures/serializers/page_serializer/search_page/results_page_serializer/no_results.yml +++ b/spec/fixtures/serializers/page_serializer/search_page/results_page_serializer/no_results.yml @@ -3,14 +3,15 @@ layout: template: layout meta: title: hello - Search - UK Parliament - data-alternates: + request-id: 123456 open-graph: title: hello - Search - UK Parliament - original-url: + original-url: https://example.com/ image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/serializers/page_serializer/search_page/results_page_serializer/with_a_query.yml b/spec/fixtures/serializers/page_serializer/search_page/results_page_serializer/with_a_query.yml index e31403ee..0d44ebf5 100644 --- a/spec/fixtures/serializers/page_serializer/search_page/results_page_serializer/with_a_query.yml +++ b/spec/fixtures/serializers/page_serializer/search_page/results_page_serializer/with_a_query.yml @@ -3,14 +3,15 @@ layout: template: layout meta: title: hello - Search - UK Parliament - data-alternates: + request-id: 123456 open-graph: title: hello - Search - UK Parliament - original-url: + original-url: https://example.com/ image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://example.com/search/opensearch components: - name: head__search-result-tracking header-components: diff --git a/spec/fixtures/serializers/page_serializer/statutory_instruments_show_page_serializer/fixture.yml b/spec/fixtures/serializers/page_serializer/statutory_instruments_show_page_serializer/fixture.yml index e143e544..18b9d3e2 100644 --- a/spec/fixtures/serializers/page_serializer/statutory_instruments_show_page_serializer/fixture.yml +++ b/spec/fixtures/serializers/page_serializer/statutory_instruments_show_page_serializer/fixture.yml @@ -3,14 +3,15 @@ layout: template: layout meta: title: SI Paper Test - data-alternates: + request-id: 123456 open-graph: title: SI Paper Test - original-url: + original-url: https://example.com/ image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://example.com/search/opensearch header-components: - name: link data: diff --git a/spec/fixtures/serializers/page_serializer/statutory_instruments_show_page_serializer/si_missing_data.yml b/spec/fixtures/serializers/page_serializer/statutory_instruments_show_page_serializer/si_missing_data.yml index 412577ce..154f6b4e 100644 --- a/spec/fixtures/serializers/page_serializer/statutory_instruments_show_page_serializer/si_missing_data.yml +++ b/spec/fixtures/serializers/page_serializer/statutory_instruments_show_page_serializer/si_missing_data.yml @@ -3,14 +3,15 @@ layout: template: layout meta: title: SI Paper Test - data-alternates: + request-id: 123456 open-graph: title: SI Paper Test - original-url: + original-url: https://example.com/ image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png image-width: '1200' image-height: '630' twitter-card: summary_large_image + opensearch-description-url: https://example.com/search/opensearch header-components: - name: link data: diff --git a/spec/integration/controllers/groups_controller_spec.rb b/spec/integration/controllers/groups_controller_spec.rb index 3d334be8..9a4e7127 100644 --- a/spec/integration/controllers/groups_controller_spec.rb +++ b/spec/integration/controllers/groups_controller_spec.rb @@ -3,7 +3,7 @@ RSpec.describe GroupsController, vcr: true do describe 'GET index' do before(:each) do - allow_any_instance_of(GroupsController).to receive(:app_insights_request_id) { 123456 } + allow_any_instance_of(PageSerializer::ListPageSerializer).to receive(:request_id) { 123456 } end context 'navigating to the index page' do @@ -20,7 +20,7 @@ describe 'GET show' do before(:each) do - allow_any_instance_of(GroupsController).to receive(:app_insights_request_id) { 123456 } + allow_any_instance_of(PageSerializer::GroupsShowPageSerializer).to receive(:request_id) { 123456 } end context 'navigating to the show page' do @@ -30,7 +30,7 @@ expected_json = get_fixture('show', '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 diff --git a/spec/integration/controllers/home_controller_spec.rb b/spec/integration/controllers/home_controller_spec.rb index c02e0019..4893349b 100644 --- a/spec/integration/controllers/home_controller_spec.rb +++ b/spec/integration/controllers/home_controller_spec.rb @@ -3,7 +3,7 @@ RSpec.describe HomeController, vcr: true do describe 'GET index' do before(:each) do - allow_any_instance_of(HomeController).to receive(:app_insights_request_id) { 123456 } + allow_any_instance_of(PageSerializer::HomePageSerializer).to receive(:request_id) { 123456 } end context 'navigating to the index page' do diff --git a/spec/integration/controllers/proposed_negative_statutory_instruments_controller_spec.rb b/spec/integration/controllers/proposed_negative_statutory_instruments_controller_spec.rb index 465823d3..efd8c02a 100644 --- a/spec/integration/controllers/proposed_negative_statutory_instruments_controller_spec.rb +++ b/spec/integration/controllers/proposed_negative_statutory_instruments_controller_spec.rb @@ -3,7 +3,7 @@ RSpec.describe ProposedNegativeStatutoryInstrumentsController, vcr: true do describe 'GET index' do before(:each) do - allow_any_instance_of(ProposedNegativeStatutoryInstrumentsController).to receive(:app_insights_request_id) { 123456 } + allow_any_instance_of(PageSerializer::ListPageSerializer).to receive(:request_id) { 123456 } end context 'navigating to the index page' do @@ -20,7 +20,7 @@ describe 'GET show' do before(:each) do - allow_any_instance_of(ProposedNegativeStatutoryInstrumentsController).to receive(:app_insights_request_id) { 123456 } + allow_any_instance_of(PageSerializer::ProposedNegativeStatutoryInstrumentsShowPageSerializer).to receive(:request_id) { 123456 } end context 'navigating to the show page' do diff --git a/spec/integration/controllers/search_controller_spec.rb b/spec/integration/controllers/search_controller_spec.rb index 1049b301..50d6be6a 100644 --- a/spec/integration/controllers/search_controller_spec.rb +++ b/spec/integration/controllers/search_controller_spec.rb @@ -3,7 +3,8 @@ RSpec.describe SearchController, vcr: true do describe 'GET index' do before(:each) do - allow_any_instance_of(SearchController).to receive(:app_insights_request_id) { 123456 } + allow_any_instance_of(PageSerializer::SearchPage::LandingPageSerializer).to receive(:request_id) { 123456 } + allow_any_instance_of(PageSerializer::SearchPage::ResultsPageSerializer).to receive(:request_id) { 123456 } end context 'navigating to the search page' do diff --git a/spec/integration/controllers/statutory_instruments_controller_spec.rb b/spec/integration/controllers/statutory_instruments_controller_spec.rb index 24704f3f..f4682279 100644 --- a/spec/integration/controllers/statutory_instruments_controller_spec.rb +++ b/spec/integration/controllers/statutory_instruments_controller_spec.rb @@ -3,7 +3,7 @@ RSpec.describe StatutoryInstrumentsController, vcr: true do describe 'GET index' do before(:each) do - allow_any_instance_of(StatutoryInstrumentsController).to receive(:app_insights_request_id) { 123456 } + allow_any_instance_of(PageSerializer::ListPageSerializer).to receive(:request_id) { 123456 } end context 'navigating to the index page' do @@ -20,7 +20,7 @@ describe 'GET show' do before(:each) do - allow_any_instance_of(StatutoryInstrumentsController).to receive(:app_insights_request_id) { 123456 } + allow_any_instance_of(PageSerializer::StatutoryInstrumentsShowPageSerializer).to receive(:request_id) { 123456 } end context 'navigating to the show page' do diff --git a/spec/serializers/component_serializer/link_button_component_serializer_spec.rb b/spec/serializers/component_serializer/link_button_component_serializer_spec.rb index 46913a1d..d85290b3 100644 --- a/spec/serializers/component_serializer/link_button_component_serializer_spec.rb +++ b/spec/serializers/component_serializer/link_button_component_serializer_spec.rb @@ -20,7 +20,7 @@ it 'when given a display_data argument returns a hash containing the name and data' do serializer = described_class.new(link: '/mps', text: 'MPs', download: true, display_data: 'display_data') -create_fixture(serializer, 'with_display_data') + expected = get_fixture('with_display_data') expect(serializer.to_yaml).to eq expected diff --git a/spec/serializers/page_serializer/base_page_serializer_spec.rb b/spec/serializers/page_serializer/base_page_serializer_spec.rb index 6539f801..1ec3e41d 100644 --- a/spec/serializers/page_serializer/base_page_serializer_spec.rb +++ b/spec/serializers/page_serializer/base_page_serializer_spec.rb @@ -1,13 +1,9 @@ require_relative '../../rails_helper' RSpec.describe PageSerializer::BasePageSerializer do - let(:base_page_serializer) { described_class.new } + include_context "sample request", include_shared: true - context '#opensearch_description_url' do - it 'raises an error' do - expect { base_page_serializer.send(:opensearch_description_url) }.to raise_error('You must implement #opensearch_description_url') - end - end + let(:base_page_serializer) { described_class.new(request: request) } context '#main_components' do it 'raises an error' do @@ -30,4 +26,10 @@ expect(PartialSerializer::FooterComponentsPartialSerializer).to have_received(:new) end end + + context 'with no original url, or a unexpected request' do + it 'has a nil original_url' do + expect(described_class.new(request: nil).request_original_url).to be_nil + end + end end diff --git a/spec/serializers/page_serializer/groups_show_page_serializer_spec.rb b/spec/serializers/page_serializer/groups_show_page_serializer_spec.rb index adec6b7f..9f42576d 100644 --- a/spec/serializers/page_serializer/groups_show_page_serializer_spec.rb +++ b/spec/serializers/page_serializer/groups_show_page_serializer_spec.rb @@ -1,6 +1,7 @@ require_relative '../../rails_helper' RSpec.describe PageSerializer::GroupsShowPageSerializer do + include_context "sample request", include_shared: true let(:group) do double('group', @@ -10,7 +11,7 @@ ) end - let(:subject) { described_class.new(group: group) } + let(:subject) { described_class.new(request: request, group: group) } context '#to_h' do it 'produces the expected JSON hash' do @@ -30,7 +31,7 @@ end it 'produces the expected JSON hash with missing data' do - serializer = described_class.new(group: group_missing_data) + serializer = described_class.new(request: request, group: group_missing_data) expected = get_fixture('group_missing_data') diff --git a/spec/serializers/page_serializer/home_page_serializer_spec.rb b/spec/serializers/page_serializer/home_page_serializer_spec.rb index 82739848..51fc2f26 100644 --- a/spec/serializers/page_serializer/home_page_serializer_spec.rb +++ b/spec/serializers/page_serializer/home_page_serializer_spec.rb @@ -1,6 +1,7 @@ require_relative '../../rails_helper' RSpec.describe PageSerializer::HomePageSerializer, vcr: true do + include_context "sample request", include_shared: true context '#to_h' do it 'produces a JSON hash' do diff --git a/spec/serializers/page_serializer/laid_thing_show_page_serializer_spec.rb b/spec/serializers/page_serializer/laid_thing_show_page_serializer_spec.rb index 6516b9bf..d37d6c66 100644 --- a/spec/serializers/page_serializer/laid_thing_show_page_serializer_spec.rb +++ b/spec/serializers/page_serializer/laid_thing_show_page_serializer_spec.rb @@ -1,6 +1,8 @@ require_relative '../../rails_helper' RSpec.describe PageSerializer::LaidThingShowPageSerializer do + include_context "sample request", include_shared: true + let(:laying_body) { double('laying_body', name: 'LayingBodyTest', graph_id: 'E1234567') } let(:laying_person) { double('laying_person', display_name: 'LayingPersonTest', graph_id: 'F1234567') } let(:laying) { double('laying', body: laying_body, person: laying_person, date: DateTime.new(2018, 8, 10, 0, 0), graph_id: 'G1234567') } @@ -15,11 +17,10 @@ ) end - let(:subject) { described_class.new(laid_thing: laid_thing) } + subject { described_class.new(request: request, laid_thing: laid_thing) } context '#to_h' do it 'produces the expected JSON hash' do -create_fixture(subject, 'fixture') expected = get_fixture('fixture') expect(subject.to_yaml).to eq expected @@ -36,7 +37,7 @@ end it 'produces the expected JSON hash with missing data' do - serializer = described_class.new(laid_thing: laid_thing_missing_data) + serializer = described_class.new(request: request, laid_thing: laid_thing_missing_data) expected = get_fixture('laid_thing_missing_data') diff --git a/spec/serializers/page_serializer/list_page_serializer_spec.rb b/spec/serializers/page_serializer/list_page_serializer_spec.rb index b49f49a2..b787bd7e 100644 --- a/spec/serializers/page_serializer/list_page_serializer_spec.rb +++ b/spec/serializers/page_serializer/list_page_serializer_spec.rb @@ -1,7 +1,9 @@ require_relative '../../rails_helper' RSpec.describe PageSerializer::ListPageSerializer do - let(:subject) { described_class.new(page_title: 'Test page', list_components: [{ list_component: 'list component' }]) } + include_context "sample request", include_shared: true + + subject { described_class.new(request: request, page_title: 'Test page', list_components: [{ list_component: 'list component' }]) } context 'the serializers are correctly called' do context '#content' do diff --git a/spec/serializers/page_serializer/proposed_negative_statutory_instruments_show_page_serializer_spec.rb b/spec/serializers/page_serializer/proposed_negative_statutory_instruments_show_page_serializer_spec.rb index 6b6b5d38..a886eede 100644 --- a/spec/serializers/page_serializer/proposed_negative_statutory_instruments_show_page_serializer_spec.rb +++ b/spec/serializers/page_serializer/proposed_negative_statutory_instruments_show_page_serializer_spec.rb @@ -1,6 +1,8 @@ require_relative '../../rails_helper' RSpec.describe PageSerializer::ProposedNegativeStatutoryInstrumentsShowPageSerializer do + include_context "sample request", include_shared: true + let(:laying_body) { double('laying_body', name: 'LayingBodyTest', graph_id: 'E1234567') } let(:laying_person) { double('laying_person', display_name: 'LayingPersonTest', graph_id: 'F1234567') } let(:laying) { double('laying', body: laying_body, person: laying_person, date: DateTime.new(2018, 8, 10, 0, 0), graph_id: 'G1234567') } @@ -19,7 +21,7 @@ ) end - let(:subject) { described_class.new(proposed_negative_statutory_instrument: proposed_negative_statutory_instrument) } + subject { described_class.new(request: request, proposed_negative_statutory_instrument: proposed_negative_statutory_instrument) } context '#to_h' do it 'produces the expected JSON hash' do @@ -42,7 +44,7 @@ end it 'produces the expected JSON hash with missing data' do - serializer = described_class.new(proposed_negative_statutory_instrument: si_missing_data) + serializer = described_class.new(request: request, proposed_negative_statutory_instrument: si_missing_data) expected = get_fixture('si_missing_data') diff --git a/spec/serializers/page_serializer/search_page/landing_page_serializer_spec.rb b/spec/serializers/page_serializer/search_page/landing_page_serializer_spec.rb index cbe83e59..daf32919 100644 --- a/spec/serializers/page_serializer/search_page/landing_page_serializer_spec.rb +++ b/spec/serializers/page_serializer/search_page/landing_page_serializer_spec.rb @@ -1,6 +1,8 @@ require_relative '../../../rails_helper' RSpec.describe PageSerializer::SearchPage::LandingPageSerializer do + include_context "sample request", include_shared: true + context '#to_h' do context 'without a query' do it 'produces the correct hash' do @@ -13,7 +15,7 @@ context 'with a flash message' do it 'produces the correct hash' do - serializer = described_class.new(flash_message: 'some flash message') + serializer = described_class.new(request: request, flash_message: 'some flash message') expected = get_fixture('with_flash_message') @@ -37,7 +39,7 @@ context 'with a flash message' do it '#content' do - serializer = described_class.new(flash_message: 'some flash message') + serializer = described_class.new(request: request, flash_message: 'some flash message') allow(ComponentSerializer::SectionComponentSerializer).to receive(:new) diff --git a/spec/serializers/page_serializer/search_page/results_page_serializer_spec.rb b/spec/serializers/page_serializer/search_page/results_page_serializer_spec.rb index 666a5f62..19969f9f 100644 --- a/spec/serializers/page_serializer/search_page/results_page_serializer_spec.rb +++ b/spec/serializers/page_serializer/search_page/results_page_serializer_spec.rb @@ -1,6 +1,8 @@ require_relative '../../../rails_helper' RSpec.describe PageSerializer::SearchPage::ResultsPageSerializer do + include_context "sample request", include_shared: true + let(:pagination_hash) { { start_index: 11, count: 100, results_total: 345, query: 'hello' } } let(:result_one) { double( @@ -36,7 +38,7 @@ } let(:results) { double('results', totalResults: 658, entries: [result_one, result_two, result_three]) } - let(:subject) { described_class.new(query: 'hello', results: results, pagination_hash: pagination_hash) } + subject { described_class.new(request: request, query: 'hello', results: results, pagination_hash: pagination_hash) } context '#to_h' do context 'with a query' do diff --git a/spec/serializers/page_serializer/search_page_spec.rb b/spec/serializers/page_serializer/search_page_spec.rb index 8d3a54e2..892fa98f 100644 --- a/spec/serializers/page_serializer/search_page_spec.rb +++ b/spec/serializers/page_serializer/search_page_spec.rb @@ -1,8 +1,11 @@ require_relative '../../rails_helper' RSpec.describe PageSerializer::SearchPage do + include_context "sample request", include_shared: true + let(:results) { double('results', totalResults: 658) } - let(:subject) { described_class.new(query: 'banana', results: results) } + + subject { described_class.new(request: request, query: 'banana', results: results) } context 'raising errors' do it '#content' do diff --git a/spec/serializers/page_serializer/statutory_instruments_show_page_serializer_spec.rb b/spec/serializers/page_serializer/statutory_instruments_show_page_serializer_spec.rb index 9a0a3a38..5c94115c 100644 --- a/spec/serializers/page_serializer/statutory_instruments_show_page_serializer_spec.rb +++ b/spec/serializers/page_serializer/statutory_instruments_show_page_serializer_spec.rb @@ -1,6 +1,8 @@ require_relative '../../rails_helper' RSpec.describe PageSerializer::StatutoryInstrumentsShowPageSerializer do + include_context "sample request", include_shared: true + let(:laying_body) { double('laying_body', name: 'LayingBodyTest', graph_id: 'E1234567') } let(:laying_person) { double('laying_person', display_name: 'LayingPersonTest', graph_id: 'F1234567') } let(:laying) { double('laying', body: laying_body, person: laying_person, date: DateTime.new(2018, 8, 10, 0, 0), graph_id: 'G1234567') } @@ -25,7 +27,7 @@ ) end - let(:subject) { described_class.new(statutory_instrument: statutory_instrument) } + subject { described_class.new(request: request, statutory_instrument: statutory_instrument) } context '#to_h' do it 'produces the expected JSON hash' do @@ -54,7 +56,7 @@ end it 'produces the expected JSON hash with missing data' do - serializer = described_class.new(statutory_instrument: si_missing_data) + serializer = described_class.new(request: request, statutory_instrument: si_missing_data) expected = get_fixture('si_missing_data') diff --git a/spec/support/shared_contexts/sample_request.rb b/spec/support/shared_contexts/sample_request.rb new file mode 100644 index 00000000..4a8e54af --- /dev/null +++ b/spec/support/shared_contexts/sample_request.rb @@ -0,0 +1,10 @@ +RSpec.shared_context "sample request", :shared_context => :metadata do + let(:request) do + request = ActionDispatch::TestRequest.create({ 'ApplicationInsights.request.id' => 123456 }) + request.host = 'example.com' + + request + end + + subject { described_class.new(request: request) } +end \ No newline at end of file