2019-04-29 19:27:42 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-13 12:40:43 -05:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe UserField do
|
|
|
|
describe "doesn't validate presence of name if field type is 'confirm'" do
|
|
|
|
subject { described_class.new(field_type: 'confirm') }
|
|
|
|
it { is_expected.not_to validate_presence_of :name }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "validates presence of name for other field types" do
|
|
|
|
subject { described_class.new(field_type: 'dropdown') }
|
|
|
|
it { is_expected.to validate_presence_of :name }
|
|
|
|
end
|
2021-10-27 09:33:07 -05:00
|
|
|
|
|
|
|
it 'sanitizes the description' do
|
|
|
|
xss = "<b onmouseover=alert('Wufff!')>click me!</b><script>alert('TEST');</script>"
|
|
|
|
user_field = Fabricate(:user_field)
|
|
|
|
|
|
|
|
user_field.update!(description: xss)
|
|
|
|
|
|
|
|
expect(user_field.description).to eq("<b>click me!</b>alert('TEST');")
|
|
|
|
end
|
2019-03-13 12:40:43 -05:00
|
|
|
end
|