[Fix #1801] rename and move html_formatted_description in a generic helper

This commit is contained in:
Mathieu Magnin 2018-05-24 18:01:40 +02:00
parent 0635b50d70
commit 152cf03d72
3 changed files with 10 additions and 9 deletions

View file

@ -0,0 +1,29 @@
RSpec.describe StringToHtmlHelper, type: :helper do
describe "#string_to_html" do
subject { string_to_html(description) }
context "with some simple texte" do
let(:description) { "1er ligne \n 2ieme ligne" }
it { is_expected.to eq("<p>1er ligne \n<br> 2ieme ligne</p>") }
end
context "with a link" do
let(:description) { "https://d-s.fr" }
it { is_expected.to eq("<p><a target=\"_blank\" href=\"https://d-s.fr\">https://d-s.fr</a></p>") }
end
context "with empty decription" do
let(:description) { nil }
it { is_expected.to eq('<p></p>') }
end
context "with a bad script" do
let(:description) { '<script>bad</script>' }
it { is_expected.to eq('<p>bad</p>') }
end
end
end