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>2021-09-20 16:18:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-09-20 16:18:24 +0300
commit0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch)
tree4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/lib/banzai
parent744144d28e3e7fddc117924fef88de5d9674fe4c (diff)
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/lib/banzai')
-rw-r--r--spec/lib/banzai/filter/audio_link_filter_spec.rb16
-rw-r--r--spec/lib/banzai/filter/video_link_filter_spec.rb16
-rw-r--r--spec/lib/banzai/reference_parser/base_parser_spec.rb12
-rw-r--r--spec/lib/banzai/reference_parser/mentioned_group_parser_spec.rb6
-rw-r--r--spec/lib/banzai/reference_parser/mentioned_project_parser_spec.rb6
-rw-r--r--spec/lib/banzai/reference_parser/mentioned_user_parser_spec.rb6
-rw-r--r--spec/lib/banzai/reference_parser/project_parser_spec.rb8
7 files changed, 29 insertions, 41 deletions
diff --git a/spec/lib/banzai/filter/audio_link_filter_spec.rb b/spec/lib/banzai/filter/audio_link_filter_spec.rb
index 4198a50e980..71e069eb29f 100644
--- a/spec/lib/banzai/filter/audio_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/audio_link_filter_spec.rb
@@ -25,18 +25,14 @@ RSpec.describe Banzai::Filter::AudioLinkFilter do
it 'replaces the image tag with an audio tag' do
container = filter(image).children.first
- expect(container.name).to eq 'div'
- expect(container['class']).to eq 'audio-container'
+ expect(container.name).to eq 'span'
+ expect(container['class']).to eq 'media-container audio-container'
- audio, paragraph = container.children
+ audio, link = container.children
expect(audio.name).to eq 'audio'
expect(audio['src']).to eq src
- expect(paragraph.name).to eq 'p'
-
- link = paragraph.children.first
-
expect(link.name).to eq 'a'
expect(link['href']).to eq src
expect(link['target']).to eq '_blank'
@@ -105,15 +101,13 @@ RSpec.describe Banzai::Filter::AudioLinkFilter do
image = %(<img src="#{proxy_src}" data-canonical-src="#{canonical_src}"/>)
container = filter(image).children.first
- expect(container['class']).to eq 'audio-container'
+ expect(container['class']).to eq 'media-container audio-container'
- audio, paragraph = container.children
+ audio, link = container.children
expect(audio['src']).to eq proxy_src
expect(audio['data-canonical-src']).to eq canonical_src
- link = paragraph.children.first
-
expect(link['href']).to eq proxy_src
end
end
diff --git a/spec/lib/banzai/filter/video_link_filter_spec.rb b/spec/lib/banzai/filter/video_link_filter_spec.rb
index ec954aa9163..a0b0ba309f5 100644
--- a/spec/lib/banzai/filter/video_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/video_link_filter_spec.rb
@@ -25,20 +25,16 @@ RSpec.describe Banzai::Filter::VideoLinkFilter do
it 'replaces the image tag with a video tag' do
container = filter(image).children.first
- expect(container.name).to eq 'div'
- expect(container['class']).to eq 'video-container'
+ expect(container.name).to eq 'span'
+ expect(container['class']).to eq 'media-container video-container'
- video, paragraph = container.children
+ video, link = container.children
expect(video.name).to eq 'video'
expect(video['src']).to eq src
expect(video['width']).to eq "400"
expect(video['preload']).to eq 'metadata'
- expect(paragraph.name).to eq 'p'
-
- link = paragraph.children.first
-
expect(link.name).to eq 'a'
expect(link['href']).to eq src
expect(link['target']).to eq '_blank'
@@ -107,15 +103,13 @@ RSpec.describe Banzai::Filter::VideoLinkFilter do
image = %(<img src="#{proxy_src}" data-canonical-src="#{canonical_src}"/>)
container = filter(image).children.first
- expect(container['class']).to eq 'video-container'
+ expect(container['class']).to eq 'media-container video-container'
- video, paragraph = container.children
+ video, link = container.children
expect(video['src']).to eq proxy_src
expect(video['data-canonical-src']).to eq canonical_src
- link = paragraph.children.first
-
expect(link['href']).to eq proxy_src
end
end
diff --git a/spec/lib/banzai/reference_parser/base_parser_spec.rb b/spec/lib/banzai/reference_parser/base_parser_spec.rb
index 095500cdc53..4701caa0667 100644
--- a/spec/lib/banzai/reference_parser/base_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/base_parser_spec.rb
@@ -247,15 +247,15 @@ RSpec.describe Banzai::ReferenceParser::BaseParser do
end
end
- it 'returns referenceable and visible objects, alongside nodes that are referenceable but not visible' do
- expect(subject.gather_references(nodes)).to match(
- visible: contain_exactly(6, 8, 10),
- not_visible: match_array(nodes.select { |n| n.id.even? && n.id <= 5 })
- )
+ it 'returns referenceable and visible objects, alongside all and visible nodes' do
+ referenceable = nodes.select { |n| n.id.even? }
+ visible = nodes.select { |n| [6, 8, 10].include?(n.id) }
+
+ expect_gathered_references(subject.gather_references(nodes), [6, 8, 10], referenceable, visible)
end
it 'is always empty if the input is empty' do
- expect(subject.gather_references([])) .to match(visible: be_empty, not_visible: be_empty)
+ expect_gathered_references(subject.gather_references([]), [], [], [])
end
end
diff --git a/spec/lib/banzai/reference_parser/mentioned_group_parser_spec.rb b/spec/lib/banzai/reference_parser/mentioned_group_parser_spec.rb
index 4610da7cbe6..576e629d271 100644
--- a/spec/lib/banzai/reference_parser/mentioned_group_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/mentioned_group_parser_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe Banzai::ReferenceParser::MentionedGroupParser do
it 'returns empty array' do
link['data-group'] = project.group.id.to_s
- expect_gathered_references(subject.gather_references([link]), [], 1)
+ expect_gathered_references(subject.gather_references([link]), [], [link], [])
end
end
@@ -30,7 +30,7 @@ RSpec.describe Banzai::ReferenceParser::MentionedGroupParser do
end
it 'returns groups' do
- expect_gathered_references(subject.gather_references([link]), [group], 0)
+ expect_gathered_references(subject.gather_references([link]), [group], [link], [link])
end
end
@@ -38,7 +38,7 @@ RSpec.describe Banzai::ReferenceParser::MentionedGroupParser do
it 'returns an empty Array' do
link['data-group'] = 'test-non-existing'
- expect_gathered_references(subject.gather_references([link]), [], 1)
+ expect_gathered_references(subject.gather_references([link]), [], [link], [])
end
end
end
diff --git a/spec/lib/banzai/reference_parser/mentioned_project_parser_spec.rb b/spec/lib/banzai/reference_parser/mentioned_project_parser_spec.rb
index 7eb58ee40d3..983407addce 100644
--- a/spec/lib/banzai/reference_parser/mentioned_project_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/mentioned_project_parser_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe Banzai::ReferenceParser::MentionedProjectParser do
it 'returns empty Array' do
link['data-project'] = project.id.to_s
- expect_gathered_references(subject.gather_references([link]), [], 1)
+ expect_gathered_references(subject.gather_references([link]), [], [link], [])
end
end
@@ -30,7 +30,7 @@ RSpec.describe Banzai::ReferenceParser::MentionedProjectParser do
end
it 'returns an Array of referenced projects' do
- expect_gathered_references(subject.gather_references([link]), [project], 0)
+ expect_gathered_references(subject.gather_references([link]), [project], [link], [link])
end
end
@@ -38,7 +38,7 @@ RSpec.describe Banzai::ReferenceParser::MentionedProjectParser do
it 'returns an empty Array' do
link['data-project'] = 'inexisting-project-id'
- expect_gathered_references(subject.gather_references([link]), [], 1)
+ expect_gathered_references(subject.gather_references([link]), [], [link], [])
end
end
end
diff --git a/spec/lib/banzai/reference_parser/mentioned_user_parser_spec.rb b/spec/lib/banzai/reference_parser/mentioned_user_parser_spec.rb
index 4be07866db1..f117d796dad 100644
--- a/spec/lib/banzai/reference_parser/mentioned_user_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/mentioned_user_parser_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe Banzai::ReferenceParser::MentionedUserParser do
end
it 'returns empty list of users' do
- expect_gathered_references(subject.gather_references([link]), [], 0)
+ expect_gathered_references(subject.gather_references([link]), [], [link], [link])
end
end
end
@@ -35,7 +35,7 @@ RSpec.describe Banzai::ReferenceParser::MentionedUserParser do
end
it 'returns empty list of users' do
- expect_gathered_references(subject.gather_references([link]), [], 0)
+ expect_gathered_references(subject.gather_references([link]), [], [link], [link])
end
end
end
@@ -44,7 +44,7 @@ RSpec.describe Banzai::ReferenceParser::MentionedUserParser do
it 'returns an Array of users' do
link['data-user'] = user.id.to_s
- expect_gathered_references(subject.gather_references([link]), [user], 0)
+ expect_gathered_references(subject.gather_references([link]), [user], [link], [link])
end
end
end
diff --git a/spec/lib/banzai/reference_parser/project_parser_spec.rb b/spec/lib/banzai/reference_parser/project_parser_spec.rb
index 6358a04f12a..2c0b6c417b0 100644
--- a/spec/lib/banzai/reference_parser/project_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/project_parser_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe Banzai::ReferenceParser::ProjectParser do
it 'returns an Array of projects' do
link['data-project'] = project.id.to_s
- expect_gathered_references(subject.gather_references([link]), [project], 0)
+ expect_gathered_references(subject.gather_references([link]), [project], [link], [link])
end
end
@@ -25,7 +25,7 @@ RSpec.describe Banzai::ReferenceParser::ProjectParser do
it 'returns an empty Array' do
link['data-project'] = ''
- expect_gathered_references(subject.gather_references([link]), [], 1)
+ expect_gathered_references(subject.gather_references([link]), [], [link], [])
end
end
@@ -35,7 +35,7 @@ RSpec.describe Banzai::ReferenceParser::ProjectParser do
link['data-project'] = private_project.id.to_s
- expect_gathered_references(subject.gather_references([link]), [], 1)
+ expect_gathered_references(subject.gather_references([link]), [], [link], [])
end
it 'returns an Array when authorized' do
@@ -43,7 +43,7 @@ RSpec.describe Banzai::ReferenceParser::ProjectParser do
link['data-project'] = private_project.id.to_s
- expect_gathered_references(subject.gather_references([link]), [private_project], 0)
+ expect_gathered_references(subject.gather_references([link]), [private_project], [link], [link])
end
end
end