Add inline_qrcode_svg helper for confirmation page (#39633)

This commit is contained in:
Matt Jankowski authored and GitHub committed 2026-06-26 13:53:27 +00:00
1 parent be7d48ba29
commit 9338f5d760
3 files changed
+15 -1

No files matched your search

+6
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(
@@ -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')
+8
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)') }