diff options
Diffstat (limited to 'spec/models/concerns/cache_markdown_field_spec.rb')
-rw-r--r-- | spec/models/concerns/cache_markdown_field_spec.rb | 17 |
1 files changed, 12 insertions, 5 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 |