Skip to content
Snippets Groups Projects
Commit 9c8edcd6 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent bc898829
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -76,6 +76,30 @@ module Gitlab
GitalyClient::BlobsStitcher.new(response)
end
 
def get_blob_types(revision_paths, limit = -1)
return {} if revision_paths.empty?
request_revision_paths = revision_paths.map do |rev, path|
Gitaly::GetBlobsRequest::RevisionPath.new(revision: rev, path: encode_binary(path))
end
request = Gitaly::GetBlobsRequest.new(
repository: @gitaly_repo,
revision_paths: request_revision_paths,
limit: limit
)
response = GitalyClient.call(
@gitaly_repo.storage_name,
:blob_service,
:get_blobs,
request,
timeout: GitalyClient.fast_timeout
)
map_blob_types(response)
end
def get_new_lfs_pointers(revision, limit, not_in, dynamic_timeout = nil)
request = Gitaly::GetNewLFSPointersRequest.new(
repository: @gitaly_repo,
Loading
Loading
@@ -132,6 +156,16 @@ module Gitlab
end
end
end
def map_blob_types(response)
types = {}
response.each do |msg|
types[msg.path.dup.force_encoding('utf-8')] = msg.type.downcase
end
types
end
end
end
end
Loading
Loading
@@ -234,6 +234,12 @@ describe 'Issue Boards', :js do
 
expect(find('.board:nth-child(2)')).to have_content(development.title)
expect(find('.board:nth-child(2)')).to have_content(planning.title)
# Make sure list positions are preserved after a reload
visit project_board_path(project, board)
expect(find('.board:nth-child(2)')).to have_content(development.title)
expect(find('.board:nth-child(2)')).to have_content(planning.title)
end
 
it 'dragging does not duplicate list' do
Loading
Loading
/* eslint-disable no-var, prefer-template, no-else-return, dot-notation, no-return-assign, no-new, no-underscore-dangle */
/* eslint-disable no-var, no-else-return, dot-notation, no-return-assign, no-new, no-underscore-dangle */
 
import $ from 'jquery';
import LineHighlighter from '~/line_highlighter';
Loading
Loading
@@ -8,10 +8,10 @@ describe('LineHighlighter', function() {
preloadFixtures('static/line_highlighter.html');
clickLine = function(number, eventData = {}) {
if ($.isEmptyObject(eventData)) {
return $('#L' + number).click();
return $(`#L${number}`).click();
} else {
const e = $.Event('click', eventData);
return $('#L' + number).trigger(e);
return $(`#L${number}`).trigger(e);
}
};
beforeEach(function() {
Loading
Loading
@@ -42,9 +42,9 @@ describe('LineHighlighter', function() {
var line;
new LineHighlighter({ hash: '#L5-25' });
 
expect($('.' + this.css).length).toBe(21);
expect($(`.${this.css}`).length).toBe(21);
for (line = 5; line <= 25; line += 1) {
expect($('#LC' + line)).toHaveClass(this.css);
expect($(`#LC${line}`)).toHaveClass(this.css);
}
});
 
Loading
Loading
@@ -130,7 +130,7 @@ describe('LineHighlighter', function() {
});
 
expect($('#LC13')).toHaveClass(this.css);
expect($('.' + this.css).length).toBe(1);
expect($(`.${this.css}`).length).toBe(1);
});
 
it('sets the hash', function() {
Loading
Loading
@@ -152,9 +152,9 @@ describe('LineHighlighter', function() {
shiftKey: true,
});
 
expect($('.' + this.css).length).toBe(6);
expect($(`.${this.css}`).length).toBe(6);
for (line = 15; line <= 20; line += 1) {
expect($('#LC' + line)).toHaveClass(this.css);
expect($(`#LC${line}`)).toHaveClass(this.css);
}
});
 
Loading
Loading
@@ -165,9 +165,9 @@ describe('LineHighlighter', function() {
shiftKey: true,
});
 
expect($('.' + this.css).length).toBe(6);
expect($(`.${this.css}`).length).toBe(6);
for (line = 5; line <= 10; line += 1) {
expect($('#LC' + line)).toHaveClass(this.css);
expect($(`#LC${line}`)).toHaveClass(this.css);
}
});
});
Loading
Loading
@@ -188,9 +188,9 @@ describe('LineHighlighter', function() {
shiftKey: true,
});
 
expect($('.' + this.css).length).toBe(6);
expect($(`.${this.css}`).length).toBe(6);
for (line = 5; line <= 10; line += 1) {
expect($('#LC' + line)).toHaveClass(this.css);
expect($(`#LC${line}`)).toHaveClass(this.css);
}
});
 
Loading
Loading
@@ -200,9 +200,9 @@ describe('LineHighlighter', function() {
shiftKey: true,
});
 
expect($('.' + this.css).length).toBe(6);
expect($(`.${this.css}`).length).toBe(6);
for (line = 10; line <= 15; line += 1) {
expect($('#LC' + line)).toHaveClass(this.css);
expect($(`#LC${line}`)).toHaveClass(this.css);
}
});
});
Loading
Loading
Loading
Loading
@@ -3,6 +3,9 @@
require 'spec_helper'
 
describe Banzai::Filter::RelativeLinkFilter do
include GitHelpers
include RepoHelpers
def filter(doc, contexts = {})
contexts.reverse_merge!({
commit: commit,
Loading
Loading
@@ -34,6 +37,12 @@ describe Banzai::Filter::RelativeLinkFilter do
%(<div>#{element}</div>)
end
 
def allow_gitaly_n_plus_1
Gitlab::GitalyClient.allow_n_plus_1_calls do
yield
end
end
let(:project) { create(:project, :repository, :public) }
let(:user) { create(:user) }
let(:group) { nil }
Loading
Loading
@@ -44,6 +53,19 @@ describe Banzai::Filter::RelativeLinkFilter do
let(:requested_path) { '/' }
let(:only_path) { true }
 
it 'does not trigger a gitaly n+1', :request_store do
raw_doc = ""
allow_gitaly_n_plus_1 do
30.times do |i|
create_file_in_repo(project, ref, ref, "new_file_#{i}", "x" )
raw_doc += link("new_file_#{i}")
end
end
expect { filter(raw_doc) }.to change { Gitlab::GitalyClient.get_request_count }.by(2)
end
shared_examples :preserve_unchanged do
it 'does not modify any relative URL in anchor' do
doc = filter(link('README.md'))
Loading
Loading
@@ -244,7 +266,8 @@ describe Banzai::Filter::RelativeLinkFilter do
end
 
context 'when ref name contains special chars' do
let(:ref) {'mark#\'@],+;-._/#@!$&()+down'}
let(:ref) { 'mark#\'@],+;-._/#@!$&()+down' }
let(:path) { 'files/images/logo-black.png' }
 
it 'correctly escapes the ref' do
# Addressable won't escape the '#', so we do this manually
Loading
Loading
@@ -252,8 +275,9 @@ describe Banzai::Filter::RelativeLinkFilter do
 
# Stub this method so the branch doesn't actually need to be in the repo
allow_any_instance_of(described_class).to receive(:uri_type).and_return(:raw)
allow_any_instance_of(described_class).to receive(:get_uri_types).and_return({ path: :tree })
 
doc = filter(link('files/images/logo-black.png'))
doc = filter(link(path))
 
expect(doc.at_css('a')['href'])
.to eq "/#{project_path}/raw/#{ref_escaped}/files/images/logo-black.png"
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment