diff options
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/concerns/cache_markdown_field_spec.rb | 17 | ||||
-rw-r--r-- | spec/models/concerns/cacheable_attributes_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/concerns/redactable_spec.rb | 2 |
3 files changed, 14 insertions, 7 deletions
diff --git a/spec/models/concerns/cache_markdown_field_spec.rb b/spec/models/concerns/cache_markdown_field_spec.rb index f8d50e89d40..da5f184af06 100644 --- a/spec/models/concerns/cache_markdown_field_spec.rb +++ b/spec/models/concerns/cache_markdown_field_spec.rb @@ -67,10 +67,11 @@ describe CacheMarkdownField do end let(:markdown) { '`Foo`' } - let(:html) { '<p dir="auto"><code>Foo</code></p>' } + let(:html) { '<p data-sourcepos="1:1-1:5" dir="auto"><code>Foo</code></p>' } let(:updated_markdown) { '`Bar`' } - let(:updated_html) { '<p dir="auto"><code>Bar</code></p>' } + let(:updated_html) { '<p data-sourcepos="1:1-1:5" dir="auto"><code>Bar</code></p>' } + let(:updated_redcarpet_html) { '<p dir="auto"><code>Bar</code></p>' } let(:thing) { ThingWithMarkdownFields.new(foo: markdown, foo_html: html, cached_markdown_version: CacheMarkdownField::CACHE_COMMONMARK_VERSION) } @@ -95,13 +96,16 @@ describe CacheMarkdownField do context 'a changed markdown field' do shared_examples 'with cache version' do |cache_version| let(:thing) { ThingWithMarkdownFields.new(foo: markdown, foo_html: html, cached_markdown_version: cache_version) } + let(:updated_version_html) do + cache_version == CacheMarkdownField::CACHE_REDCARPET_VERSION ? updated_redcarpet_html : updated_html + end before do thing.foo = updated_markdown thing.save end - it { expect(thing.foo_html).to eq(updated_html) } + it { expect(thing.foo_html).to eq(updated_version_html) } it { expect(thing.cached_markdown_version).to eq(cache_version) } end @@ -268,6 +272,9 @@ describe CacheMarkdownField do describe '#refresh_markdown_cache!' do shared_examples 'with cache version' do |cache_version| let(:thing) { ThingWithMarkdownFields.new(foo: markdown, foo_html: html, cached_markdown_version: cache_version) } + let(:updated_version_html) do + cache_version == CacheMarkdownField::CACHE_REDCARPET_VERSION ? updated_redcarpet_html : updated_html + end before do thing.foo = updated_markdown @@ -276,7 +283,7 @@ describe CacheMarkdownField do it 'fills all html fields' do thing.refresh_markdown_cache! - expect(thing.foo_html).to eq(updated_html) + expect(thing.foo_html).to eq(updated_version_html) expect(thing.foo_html_changed?).to be_truthy expect(thing.baz_html_changed?).to be_truthy end @@ -291,7 +298,7 @@ describe CacheMarkdownField do it 'saves the changes using #update_columns' do expect(thing).to receive(:persisted?).and_return(true) expect(thing).to receive(:update_columns) - .with("foo_html" => updated_html, "baz_html" => "", "cached_markdown_version" => cache_version) + .with("foo_html" => updated_version_html, "baz_html" => "", "cached_markdown_version" => cache_version) thing.refresh_markdown_cache! end diff --git a/spec/models/concerns/cacheable_attributes_spec.rb b/spec/models/concerns/cacheable_attributes_spec.rb index 689e7d3058f..9bc381694d6 100644 --- a/spec/models/concerns/cacheable_attributes_spec.rb +++ b/spec/models/concerns/cacheable_attributes_spec.rb @@ -177,7 +177,7 @@ describe CacheableAttributes do cache_record = Appearance.current expect(cache_record.description).to eq('**Hello**') - expect(cache_record.description_html).to eq('<p dir="auto"><strong>Hello</strong></p>') + expect(cache_record.description_html).to eq('<p data-sourcepos="1:1-1:9" dir="auto"><strong>Hello</strong></p>') end end end diff --git a/spec/models/concerns/redactable_spec.rb b/spec/models/concerns/redactable_spec.rb index 7d320edd492..fe17970d75f 100644 --- a/spec/models/concerns/redactable_spec.rb +++ b/spec/models/concerns/redactable_spec.rb @@ -35,7 +35,7 @@ describe Redactable do expected = 'some text /sent_notifications/REDACTED/unsubscribe more text' expect(model[field]).to eq expected - expect(model["#{field}_html"]).to eq "<p dir=\"auto\">#{expected}</p>" + expect(model["#{field}_html"]).to eq "<p data-sourcepos=\"1:1-1:60\" dir=\"auto\">#{expected}</p>" end end |