Skip to content

Commit

Permalink
expanded multi_concern_interaction test
Browse files Browse the repository at this point in the history
  • Loading branch information
Janell-Huyck committed Nov 16, 2023
1 parent 369cb24 commit 92d7a4a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/requests/multi_concern_interaction_spec.rb
Original file line number Diff line number Diff line change
@@ -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|
Expand All @@ -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

0 comments on commit 92d7a4a

Please sign in to comment.