Commit 3473ab1f authored by Brett Walker's avatar Brett Walker

Ensure that cached_markdown_version is not nil

parent 858320c2
...@@ -39,7 +39,7 @@ module Gitlab ...@@ -39,7 +39,7 @@ module Gitlab
def save_markdown(updates) def save_markdown(updates)
return unless persisted? && Gitlab::Database.read_write? return unless persisted? && Gitlab::Database.read_write?
return if cached_markdown_version < cached_markdown_version_in_database return if cached_markdown_version.to_i < cached_markdown_version_in_database.to_i
update_columns(updates) update_columns(updates)
end end
......
...@@ -228,4 +228,16 @@ RSpec.describe Gitlab::MarkdownCache::ActiveRecord::Extension do ...@@ -228,4 +228,16 @@ RSpec.describe Gitlab::MarkdownCache::ActiveRecord::Extension do
thing.refresh_markdown_cache! thing.refresh_markdown_cache!
end end
end end
context 'when persisted cache is nil' do
before do
thing.update_column(:cached_markdown_version, nil)
end
it 'does not save the generated HTML' do
expect(thing).to receive(:update_columns)
thing.refresh_markdown_cache!
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment