diff options
author | Alejandro Rodríguez <alejorro70@gmail.com> | 2016-06-21 10:53:16 -0400 |
---|---|---|
committer | Alejandro Rodríguez <alejorro70@gmail.com> | 2016-06-21 10:53:16 -0400 |
commit | ca696175dbbf664f25a87a300b99f2b97fa5db70 (patch) | |
tree | 94c7783f530a24b1344475beb913f53a9c91b37c /spec/lib/banzai | |
parent | 5804b6a0a28a20b1977ab89e04b15b85475b49e0 (diff) | |
download | gitlab-ce-ca696175dbbf664f25a87a300b99f2b97fa5db70.tar.gz |
Optimize Banzai::Filter::RelativeLinkFilter
A lot of git operations were being repeated, for example, to build a url
you would ask if the path was a Tree, which would call a recursive routine
in Gitlab::Git::Tree#where, then ask if the path was a Blob, which would
call a recursive routine at Gitlab::Git::Blob#find, making reference to
the same git objects several times. Now we call Rugged::Tree#path, which
allows us to determine the type of the path in one pass.
Some other minor improvement added, like saving commonly used references
instead of calculating them each time.
Diffstat (limited to 'spec/lib/banzai')
-rw-r--r-- | spec/lib/banzai/filter/relative_link_filter_spec.rb | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/spec/lib/banzai/filter/relative_link_filter_spec.rb b/spec/lib/banzai/filter/relative_link_filter_spec.rb index 0e6685f0ffb..b9e4a4eaf0e 100644 --- a/spec/lib/banzai/filter/relative_link_filter_spec.rb +++ b/spec/lib/banzai/filter/relative_link_filter_spec.rb @@ -132,11 +132,8 @@ describe Banzai::Filter::RelativeLinkFilter, lib: true do path = 'files/images/한글.png' escaped = Addressable::URI.escape(path) - # Stub these methods so the file doesn't actually need to be in the repo - allow_any_instance_of(described_class). - to receive(:file_exists?).and_return(true) - allow_any_instance_of(described_class). - to receive(:image?).with(path).and_return(true) + # Stub this method so the file doesn't actually need to be in the repo + allow_any_instance_of(described_class).to receive(:uri_type).and_return(:raw) doc = filter(image(escaped)) expect(doc.at_css('img')['src']).to match '/raw/' |