Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-29 12:13:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-29 12:13:28 +0300
commitdc90e040b1da4c089e90b21809a325d67ab2c5cb (patch)
treec894e6d6e008562db76151beb771a8c3ae3260ca /spec/support
parent6a4f265c940d3d0a9aeacf09222920d7d2cc4e45 (diff)
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/shared_examples/models/mentionable_shared_examples.rb60
1 files changed, 35 insertions, 25 deletions
diff --git a/spec/support/shared_examples/models/mentionable_shared_examples.rb b/spec/support/shared_examples/models/mentionable_shared_examples.rb
index d3e9035393f..dda5fa37b26 100644
--- a/spec/support/shared_examples/models/mentionable_shared_examples.rb
+++ b/spec/support/shared_examples/models/mentionable_shared_examples.rb
@@ -80,25 +80,21 @@ RSpec.shared_examples 'a mentionable' do
context 'when there are cached markdown fields' do
before do
- if subject.is_a?(CacheMarkdownField)
- subject.refresh_markdown_cache
- end
+ skip unless subject.is_a?(CacheMarkdownField)
end
it 'sends in cached markdown fields when appropriate' do
- if subject.is_a?(CacheMarkdownField) && subject.extractors[author].blank?
- expect_next_instance_of(Gitlab::ReferenceExtractor) do |ext|
- attrs = subject.class.mentionable_attrs.collect(&:first) & subject.cached_markdown_fields.markdown_fields
- attrs.each do |field|
- expect(ext).to receive(:analyze).with(subject.send(field), hash_including(rendered: anything))
- end
+ subject.extractors[author] = nil
+ expect_next_instance_of(Gitlab::ReferenceExtractor) do |ext|
+ attrs = subject.class.mentionable_attrs.collect(&:first) & subject.cached_markdown_fields.markdown_fields
+ attrs.each do |field|
+ expect(ext).to receive(:analyze).with(subject.send(field), hash_including(rendered: anything))
end
+ end
- expect(subject).not_to receive(:refresh_markdown_cache)
- expect(subject).to receive(:cached_markdown_fields).at_least(:once).and_call_original
+ expect(subject).to receive(:cached_markdown_fields).at_least(:once).and_call_original
- subject.all_references(author)
- end
+ subject.all_references(author)
end
end
@@ -126,26 +122,40 @@ RSpec.shared_examples 'an editable mentionable' do
context 'when there are cached markdown fields' do
before do
- if subject.is_a?(CacheMarkdownField)
- subject.refresh_markdown_cache
- end
- end
+ skip unless subject.is_a?(CacheMarkdownField)
- it 'refreshes markdown cache if necessary' do
subject.save!
+ end
+ it 'refreshes markdown cache if necessary' do
set_mentionable_text.call('This is a text')
- if subject.is_a?(CacheMarkdownField) && subject.extractors[author].blank?
- expect_next_instance_of(Gitlab::ReferenceExtractor) do |ext|
- subject.cached_markdown_fields.markdown_fields.each do |field|
- expect(ext).to receive(:analyze).with(subject.send(field), hash_including(rendered: anything))
- end
+ subject.extractors[author] = nil
+ expect_next_instance_of(Gitlab::ReferenceExtractor) do |ext|
+ subject.cached_markdown_fields.markdown_fields.each do |field|
+ expect(ext).to receive(:analyze).with(subject.send(field), hash_including(rendered: anything))
end
+ end
- expect(subject).to receive(:refresh_markdown_cache)
- expect(subject).to receive(:cached_markdown_fields).at_least(:once).and_call_original
+ expect(subject).to receive(:refresh_markdown_cache).and_call_original
+ expect(subject).to receive(:cached_markdown_fields).at_least(:once).and_call_original
+
+ subject.all_references(author)
+ end
+
+ context 'when the markdown cache is stale' do
+ before do
+ expect(subject).to receive(:latest_cached_markdown_version).at_least(:once) do
+ (Gitlab::MarkdownCache::CACHE_COMMONMARK_VERSION + 1) << 16
+ end
+ end
+
+ it 'persists the refreshed cache so that it does not have to be refreshed every time' do
+ expect(subject).to receive(:refresh_markdown_cache).once.and_call_original
+
+ subject.all_references(author)
+ subject.reload
subject.all_references(author)
end
end