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
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-24 15:06:20 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-24 15:06:20 +0300
commit9c8edcd6163f03b5ffe3af3c8fbe0706e80c4306 (patch)
tree3acfff342020d2c5e18da300b9292318bdb3aefe /spec
parentbc89882970d6a14b1f72eb9c715fae90b26d066c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/boards/boards_spec.rb6
-rw-r--r--spec/javascripts/line_highlighter_spec.js28
-rw-r--r--spec/lib/banzai/filter/relative_link_filter_spec.rb28
3 files changed, 46 insertions, 16 deletions
diff --git a/spec/features/boards/boards_spec.rb b/spec/features/boards/boards_spec.rb
index 57dc9de62fb..25aa1c1fb7d 100644
--- a/spec/features/boards/boards_spec.rb
+++ b/spec/features/boards/boards_spec.rb
@@ -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
diff --git a/spec/javascripts/line_highlighter_spec.js b/spec/javascripts/line_highlighter_spec.js
index a75470b4db8..f8f835ffdef 100644
--- a/spec/javascripts/line_highlighter_spec.js
+++ b/spec/javascripts/line_highlighter_spec.js
@@ -1,4 +1,4 @@
-/* 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';
@@ -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() {
@@ -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);
}
});
@@ -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() {
@@ -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);
}
});
@@ -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);
}
});
});
@@ -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);
}
});
@@ -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);
}
});
});
diff --git a/spec/lib/banzai/filter/relative_link_filter_spec.rb b/spec/lib/banzai/filter/relative_link_filter_spec.rb
index f8b3748c663..8e55f12ddc5 100644
--- a/spec/lib/banzai/filter/relative_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/relative_link_filter_spec.rb
@@ -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,
@@ -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 }
@@ -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'))
@@ -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
@@ -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"