Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/application.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ development:
platform_auth_set_up_enabled: true
rails_mailer_previews_enabled: true
rack_timeout_service_timeout_seconds: 9_999_999_999
raise_on_missing_title: true
s3_report_bucket_prefix: ''
s3_report_public_bucket_prefix: ''
saml_endpoint_configs: '[{"suffix":"2023","secret_key_passphrase":"trust-but-verify"}]'
Expand Down Expand Up @@ -549,6 +550,7 @@ test:
phone_setups_per_ip_track_only_mode: false
piv_cac_verify_token_secret: 3ac13bfa23e22adae321194c083e783faf89469f6f85dcc0802b27475c94b5c3891b5657bd87d0c1ad65de459166440512f2311018db90d57b15d8ab6660748f
poll_rate_for_verify_in_seconds: 0
raise_on_missing_title: true
reg_confirmed_email_max_attempts: 3
reg_unconfirmed_email_max_attempts: 4
reg_unconfirmed_email_window_in_minutes: 70
Expand Down
60 changes: 60 additions & 0 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,66 @@
require 'rails_helper'

RSpec.describe ApplicationHelper do
describe '#title' do
let(:assigned_title) { nil }
subject(:title) { helper.title }

before do
helper.title = assigned_title if assigned_title
end

context 'with a title assigned' do
let(:assigned_title) { 'example' }

it 'returns the assigned title' do
expect(title).to eq(assigned_title)
end
end

context 'without a title assigned' do
let(:raise_on_missing_title) { nil }

before do
allow(IdentityConfig.store).to receive(:raise_on_missing_title).
and_return(raise_on_missing_title)
end

context 'configured not to raise on missing title' do
let(:raise_on_missing_title) { false }

it 'returns an empty string' do
expect(title).to eq('')
end

it 'notices an error' do
expect(NewRelic::Agent).to receive(:notice_error).with(
instance_of(ApplicationHelper::MissingTitleError),
)

title
end
end

context 'configured to raise on missing title' do
let(:raise_on_missing_title) { true }

it 'raises an error' do
expect { title }.to raise_error(ApplicationHelper::MissingTitleError)
end
end
end
end

describe '#title=' do
let(:title) { 'example' }

it 'assigns the title region content' do
helper.title = title

expect(helper.view_flow.get(:title)).to eq(title)
end
end

describe '#session_with_trust?' do
context 'no user present' do
before do
Expand Down
16 changes: 11 additions & 5 deletions spec/views/layouts/application.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,19 @@
context 'without title' do
let(:title_content) { nil }

it 'notifies NewRelic' do
expect(NewRelic::Agent).to receive(:notice_error) do |error|
expect(error).to be_kind_of(ApplicationHelper::MissingTitleError)
expect(error.message).to include('Missing title')
context 'when raise_on_missing_title is false' do
before do
allow(IdentityConfig.store).to receive(:raise_on_missing_title).and_return(false)
end

expect { render }.to_not raise_error
it 'notifies NewRelic' do
expect(NewRelic::Agent).to receive(:notice_error) do |error|
expect(error).to be_kind_of(ApplicationHelper::MissingTitleError)
expect(error.message).to include('Missing title')
end

expect { render }.to_not raise_error
end
end

context 'when raise_on_missing_title is true' do
Expand Down