diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/lib/gitlab/markdown_cache | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/lib/gitlab/markdown_cache')
3 files changed, 17 insertions, 16 deletions
diff --git a/spec/lib/gitlab/markdown_cache/active_record/extension_spec.rb b/spec/lib/gitlab/markdown_cache/active_record/extension_spec.rb index be562d916d3..23dbd4a5bb3 100644 --- a/spec/lib/gitlab/markdown_cache/active_record/extension_spec.rb +++ b/spec/lib/gitlab/markdown_cache/active_record/extension_spec.rb @@ -15,7 +15,7 @@ RSpec.describe Gitlab::MarkdownCache::ActiveRecord::Extension do end let(:cache_version) { Gitlab::MarkdownCache::CACHE_COMMONMARK_VERSION << 16 } - let(:thing) { klass.create(title: markdown, title_html: html, cached_markdown_version: cache_version) } + let(:thing) { klass.create!(title: markdown, title_html: html, cached_markdown_version: cache_version) } let(:markdown) { '`Foo`' } let(:html) { '<p data-sourcepos="1:1-1:5" dir="auto"><code>Foo</code></p>' } @@ -28,7 +28,7 @@ RSpec.describe Gitlab::MarkdownCache::ActiveRecord::Extension do before do thing.title = thing.title - thing.save + thing.save! end it { expect(thing.title).to eq(markdown) } @@ -38,11 +38,11 @@ RSpec.describe Gitlab::MarkdownCache::ActiveRecord::Extension do end context 'a changed markdown field' do - let(:thing) { klass.create(title: markdown, title_html: html, cached_markdown_version: cache_version) } + let(:thing) { klass.create!(title: markdown, title_html: html, cached_markdown_version: cache_version) } before do thing.title = updated_markdown - thing.save + thing.save! end it { expect(thing.title_html).to eq(updated_html) } @@ -53,9 +53,9 @@ RSpec.describe Gitlab::MarkdownCache::ActiveRecord::Extension do it do expect(thing).to receive(:refresh_markdown_cache).once thing.title = '' - thing.save + thing.save! thing.title = '' - thing.save + thing.save! end end @@ -63,9 +63,9 @@ RSpec.describe Gitlab::MarkdownCache::ActiveRecord::Extension do it do expect(thing).to receive(:refresh_markdown_cache).once thing.title = '[//]: # (This is also a comment.)' - thing.save + thing.save! thing.title = '[//]: # (This is also a comment.)' - thing.save + thing.save! end end @@ -74,7 +74,7 @@ RSpec.describe Gitlab::MarkdownCache::ActiveRecord::Extension do before do thing.state_id = 2 - thing.save + thing.save! end it { expect(thing.state_id).to eq(2) } @@ -87,7 +87,7 @@ RSpec.describe Gitlab::MarkdownCache::ActiveRecord::Extension do let(:thing) { klass.new(title: updated_markdown, title_html: html, cached_markdown_version: nil) } before do - thing.save + thing.save! end it { expect(thing.title_html).to eq(updated_html) } @@ -99,7 +99,7 @@ RSpec.describe Gitlab::MarkdownCache::ActiveRecord::Extension do thing.project = :new_project allow(Banzai::Renderer).to receive(:cacheless_render_field).and_return(updated_html) - thing.save + thing.save! expect(thing.title_html).to eq(updated_html) expect(thing.description_html).to eq(updated_html) @@ -110,7 +110,7 @@ RSpec.describe Gitlab::MarkdownCache::ActiveRecord::Extension do thing.author = :new_author allow(Banzai::Renderer).to receive(:cacheless_render_field).and_return(updated_html) - thing.save + thing.save! expect(thing.title_html).to eq(updated_html) expect(thing.description_html).to eq(updated_html) @@ -125,7 +125,7 @@ RSpec.describe Gitlab::MarkdownCache::ActiveRecord::Extension do end describe '#cached_html_up_to_date?' do - let(:thing) { klass.create(title: updated_markdown, title_html: html, cached_markdown_version: nil) } + let(:thing) { klass.create!(title: updated_markdown, title_html: html, cached_markdown_version: nil) } subject { thing.cached_html_up_to_date?(:title) } diff --git a/spec/lib/gitlab/markdown_cache/redis/extension_spec.rb b/spec/lib/gitlab/markdown_cache/redis/extension_spec.rb index 3dcb9f160ba..b5d458f15fc 100644 --- a/spec/lib/gitlab/markdown_cache/redis/extension_spec.rb +++ b/spec/lib/gitlab/markdown_cache/redis/extension_spec.rb @@ -7,7 +7,8 @@ RSpec.describe Gitlab::MarkdownCache::Redis::Extension, :clean_gitlab_redis_cach include CacheMarkdownField def initialize(title: nil, description: nil) - @title, @description = title, description + @title = title + @description = description end attr_reader :title, :description diff --git a/spec/lib/gitlab/markdown_cache/redis/store_spec.rb b/spec/lib/gitlab/markdown_cache/redis/store_spec.rb index bf40af8e62e..07a87b245c2 100644 --- a/spec/lib/gitlab/markdown_cache/redis/store_spec.rb +++ b/spec/lib/gitlab/markdown_cache/redis/store_spec.rb @@ -40,7 +40,7 @@ RSpec.describe Gitlab::MarkdownCache::Redis::Store, :clean_gitlab_redis_cache do describe '.bulk_read' do before do - store.save(field_1_html: "hello", field_2_html: "world", cached_markdown_version: 1) + store.save(field_1_html: "hello", field_2_html: "world", cached_markdown_version: 1) # rubocop:disable Rails/SaveBang end it 'returns a hash of values from store' do @@ -59,7 +59,7 @@ RSpec.describe Gitlab::MarkdownCache::Redis::Store, :clean_gitlab_redis_cache do it 'stores updates to html fields and version' do values_to_store = { field_1_html: "hello", field_2_html: "world", cached_markdown_version: 1 } - store.save(values_to_store) + store.save(values_to_store) # rubocop:disable Rails/SaveBang expect(read_values) .to eq(field_1_html: "hello", field_2_html: "world", cached_markdown_version: "1") |