15
spec/helpers/url_helper_spec.rb
Normal file
15
spec/helpers/url_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe UrlHelper, type: :helper do
|
||||
describe '#url_valid' do
|
||||
context 'when url valid called' do
|
||||
it 'return if valid url passed' do
|
||||
expect(helper.url_valid?('https://app.chatwoot.com/')).to eq true
|
||||
end
|
||||
|
||||
it 'return false if invalid url passed' do
|
||||
expect(helper.url_valid?('javascript:alert(document.cookie)')).to eq false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -525,4 +525,20 @@ RSpec.describe Conversation, type: :model do
|
||||
expect { notification.reload }.to raise_error ActiveRecord::RecordNotFound
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validate invalid referer url' do
|
||||
let(:conversation) { create(:conversation, additional_attributes: { referer: 'javascript' }) }
|
||||
|
||||
it 'returns nil' do
|
||||
expect(conversation['additional_attributes']['referer']).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validate valid referer url' do
|
||||
let(:conversation) { create(:conversation, additional_attributes: { referer: 'https://www.chatwoot.com/' }) }
|
||||
|
||||
it 'returns nil' do
|
||||
expect(conversation['additional_attributes']['referer']).to eq('https://www.chatwoot.com/')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user