_preview_card.html.haml_spec.rb 668 B

1234567891011121314151617181920
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe 'admin/trends/links/_preview_card.html.haml' do
  4. it 'correctly escapes user supplied url values' do
  5. form = instance_double(ActionView::Helpers::FormHelper, check_box: nil)
  6. trend = PreviewCardTrend.new(allowed: false)
  7. preview_card = Fabricate.build(
  8. :preview_card,
  9. url: 'https://host.example/path?query=<script>',
  10. trend: trend,
  11. title: 'Fun'
  12. )
  13. render partial: 'admin/trends/links/preview_card', locals: { preview_card: preview_card, f: form }
  14. expect(rendered).to include('<a href="https://host.example/path?query=&lt;script&gt;">Fun</a>')
  15. end
  16. end