2018-11-18 11:00:15 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Gitlab::HookData::BaseBuilder do
|
|
|
|
describe '#absolute_image_urls' do
|
|
|
|
let(:subclass) do
|
|
|
|
Class.new(described_class) do
|
|
|
|
public :absolute_image_urls
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
using RSpec::Parameterized::TableSyntax
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
context 'with an upload prefix specified' do
|
|
|
|
let(:project_with_path) { double(full_path: 'baz/bar') }
|
|
|
|
let(:object_with_project) { double(project: project_with_path) }
|
|
|
|
subject { subclass.new(object_with_project) }
|
|
|
|
|
|
|
|
where do
|
|
|
|
{
|
|
|
|
'relative image URL' => {
|
|
|
|
input: '',
|
|
|
|
output: ""
|
|
|
|
},
|
|
|
|
'absolute upload URL' => {
|
|
|
|
input: '',
|
|
|
|
output: ""
|
|
|
|
},
|
|
|
|
'absolute non-upload URL' => {
|
|
|
|
input: '',
|
|
|
|
output: ""
|
|
|
|
}
|
2018-11-18 11:00:15 +05:30
|
|
|
}
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
with_them do
|
|
|
|
it { expect(subject.absolute_image_urls(input)).to eq(output) }
|
|
|
|
end
|
2018-11-18 11:00:15 +05:30
|
|
|
end
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
context 'without an upload prefix specified' do
|
|
|
|
subject { subclass.new(nil) }
|
|
|
|
|
|
|
|
where do
|
|
|
|
{
|
|
|
|
'relative image URL' => {
|
|
|
|
input: '',
|
|
|
|
output: ""
|
|
|
|
},
|
|
|
|
'absolute upload URL' => {
|
|
|
|
input: '',
|
|
|
|
output: ""
|
|
|
|
},
|
|
|
|
'absolute non-upload URL' => {
|
|
|
|
input: '',
|
|
|
|
output: ""
|
|
|
|
},
|
|
|
|
'HTTP URL' => {
|
|
|
|
input: '',
|
|
|
|
output: ''
|
|
|
|
},
|
|
|
|
'HTTPS URL' => {
|
|
|
|
input: '',
|
|
|
|
output: ''
|
|
|
|
},
|
|
|
|
'protocol-relative URL' => {
|
|
|
|
input: '',
|
|
|
|
output: ''
|
|
|
|
},
|
|
|
|
'URL reference by title' => {
|
|
|
|
input: "![foo]\n\n[foo]: foo.png",
|
|
|
|
output: "![foo]\n\n[foo]: foo.png"
|
|
|
|
},
|
|
|
|
'URL reference by label' => {
|
|
|
|
input: "![][foo]\n\n[foo]: foo.png",
|
|
|
|
output: "![][foo]\n\n[foo]: foo.png"
|
|
|
|
},
|
|
|
|
'in Markdown inline code block' => {
|
|
|
|
input: '``',
|
|
|
|
output: "``"
|
|
|
|
},
|
|
|
|
'in HTML tag on the same line' => {
|
|
|
|
input: '<p></p>',
|
|
|
|
output: "<p></p>"
|
|
|
|
},
|
|
|
|
'in Markdown multi-line code block' => {
|
|
|
|
input: "```\n\n```",
|
|
|
|
output: "```\n\n```"
|
|
|
|
},
|
|
|
|
'in HTML tag on different lines' => {
|
|
|
|
input: "<p>\n\n</p>",
|
|
|
|
output: "<p>\n\n</p>"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
with_them do
|
|
|
|
it { expect(subject.absolute_image_urls(input)).to eq(output) }
|
|
|
|
end
|
2018-11-18 11:00:15 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|