preview_card_spec.rb 673 B

12345678910111213141516171819202122232425262728
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe PreviewCard do
  4. describe 'validations' do
  5. describe 'urls' do
  6. it 'allows http schemes' do
  7. record = described_class.new(url: 'http://example.host/path')
  8. expect(record).to be_valid
  9. end
  10. it 'allows https schemes' do
  11. record = described_class.new(url: 'https://example.host/path')
  12. expect(record).to be_valid
  13. end
  14. it 'does not allow javascript: schemes' do
  15. record = described_class.new(url: 'javascript:alert()')
  16. expect(record).to_not be_valid
  17. expect(record).to model_have_error_on_field(:url)
  18. end
  19. end
  20. end
  21. end