From 92d7a4a8df22219f95aa7322ebd1ea6158410851 Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Thu, 19 Oct 2023 10:22:05 -0400 Subject: [PATCH] expanded multi_concern_interaction test --- spec/requests/multi_concern_interaction_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/requests/multi_concern_interaction_spec.rb b/spec/requests/multi_concern_interaction_spec.rb index 625d3a20..09481fe3 100644 --- a/spec/requests/multi_concern_interaction_spec.rb +++ b/spec/requests/multi_concern_interaction_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'rails_helper' + RSpec.describe 'Authenticity and Date Checks', type: :request do before do allow_any_instance_of(ApplicationController).to receive(:verify_authenticity_token) do |instance| @@ -11,11 +12,24 @@ it 'redirects to closed page when app is out of date and token is invalid' do allow(ENV).to receive(:fetch).with('EXPIRATION_DATE').and_return('2000-01-01') + warn_count = 0 + allow(Rails.logger).to receive(:warn) do |arg| + warn_count += 1 if arg.match?(/InvalidAuthenticityToken occurred:/) + end + get publications_path, headers: { '_csrf_token' => 'invalid_token' } + expect(response).to have_http_status(:redirect) # 302 expect(response).to redirect_to(root_path) follow_redirect! + expect(warn_count).to eq(1) + expect(response).to have_http_status(:redirect) # 302 expect(response).to redirect_to('/pages/closed') + + # Reset the received count for :warn calls on Rails.logger + allow(Rails.logger).to receive(:warn).once + + expect(warn_count).to eq(1) end end