Reduces time to detect the sub_dir when a lot of urls

This commit is contained in:
erwanlr
2020-02-13 20:07:25 +00:00
parent c100372b31
commit af3f10f74e
2 changed files with 20 additions and 1 deletions

View File

@@ -149,6 +149,24 @@ shared_examples 'WordPress::CustomDirectories' do
expect(target.sub_dir).to eql false
end
end
context 'when a lot of irrelevant urls' do
let(:body) do
Array.new(250) do |i|
"<a href='#{subject.url}#{i}.html>Link</a><img src='#subject.{url}img-#{i}.png'/>"
end.join("\n")
end
it 'should not take a while to detect the sub_dir' do
stub_request(:get, target.url).to_return(body: body)
time_start = Time.now
expect(target.sub_dir).to eql false
time_end = Time.now
expect(time_end - time_start).to be < 1
end
end
end
describe '#url' do