Add inline_qrcode_svg helper for confirmation page (#39633)

This commit is contained in:
Matt Jankowski
2026-06-26 09:53:27 -04:00
committed by GitHub
parent be7d48ba29
commit 9338f5d760
3 changed files with 15 additions and 1 deletions

View File

@@ -9,6 +9,12 @@ module SettingsHelper
LanguagesHelper.sorted_locale_keys(I18n.available_locales)
end
def inline_qrcode_svg(code)
code
.as_svg(padding: 0, module_size: 4, use_path: true)
.html_safe # rubocop:disable Rails/OutputSafety
end
def featured_tags_hint(recently_used_tags)
recently_used_tags.present? &&
safe_join(

View File

@@ -5,7 +5,7 @@
%p.hint= t('otp_authentication.instructions_html')
.qr-wrapper
.qr-code!= @qrcode.as_svg(padding: 0, module_size: 4, use_path: true)
.qr-code= inline_qrcode_svg(@qrcode)
.qr-alternative
%p.hint= t('otp_authentication.manual_instructions')

View File

@@ -19,6 +19,14 @@ RSpec.describe SettingsHelper do
end
end
describe '#inline_qrcode_svg' do
subject { inline_qrcode_svg(code) }
let(:code) { RQRCode::QRCode.new('https://host.example') }
it { is_expected.to include('</svg>').and(be_html_safe) }
end
describe 'session_device_icon' do
context 'with a mobile device' do
let(:session) { SessionActivation.new(user_agent: 'Mozilla/5.0 (iPhone)') }