|
31 | 31 | end |
32 | 32 | end |
33 | 33 |
|
| 34 | + describe "with a RawHtml value" do |
| 35 | + let(:field) { TinyAdmin::Field.new(name: "items", type: :string, title: "Items", options: { method: "multiline" }) } |
| 36 | + let(:record) { double("record", id: 1) } # rubocop:disable RSpec/VerifiedDoubles |
| 37 | + |
| 38 | + before do |
| 39 | + allow(TinyAdmin.settings.helper_class).to receive(:multiline) |
| 40 | + .and_return(TinyAdmin::RawHtml.new("1<br/>2<br/>3")) |
| 41 | + end |
| 42 | + |
| 43 | + it "renders the value as raw HTML without escaping", :aggregate_failures do |
| 44 | + html = described_class.new(field, [1, 2, 3], record: record).call |
| 45 | + expect(html).to include("<span>") |
| 46 | + expect(html).to include("1<br/>2<br/>3") |
| 47 | + expect(html).not_to include("<br/>") |
| 48 | + end |
| 49 | + end |
| 50 | + |
| 51 | + describe "with a RawHtml value inside a link" do |
| 52 | + let(:field) { TinyAdmin::Field.new(name: "items", type: :string, title: "Items", options: { method: "multiline", link_to: "posts" }) } |
| 53 | + let(:record) { double("record", id: 1) } # rubocop:disable RSpec/VerifiedDoubles |
| 54 | + |
| 55 | + before do |
| 56 | + allow(TinyAdmin.settings.helper_class).to receive(:multiline) |
| 57 | + .and_return(TinyAdmin::RawHtml.new("1<br/>2<br/>3")) |
| 58 | + end |
| 59 | + |
| 60 | + it "renders the value as raw HTML inside a link without escaping", :aggregate_failures do |
| 61 | + html = described_class.new(field, [1, 2, 3], record: record).call |
| 62 | + expect(html).to include("<a") |
| 63 | + expect(html).to include("<span>1<br/>2<br/>3</span>") |
| 64 | + end |
| 65 | + end |
| 66 | + |
34 | 67 | describe "with value_class option" do |
35 | 68 | let(:field) { TinyAdmin::Field.new(name: "status", type: :string, title: "Status", options: { options: ["value_class"] }) } |
36 | 69 | let(:record) { double("record", id: 1) } # rubocop:disable RSpec/VerifiedDoubles |
|
0 commit comments