diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-21 09:06:16 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-21 09:06:16 +0000 |
commit | a048261403ea7e12992ccffe704f0779235712d7 (patch) | |
tree | 59254549db6d39a4da824379a7bf354e7c8e7e67 /spec | |
parent | 80e5134020483299c039114e76b734436f006c66 (diff) | |
download | gitlab-ce-a048261403ea7e12992ccffe704f0779235712d7.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
43 files changed, 260 insertions, 81 deletions
diff --git a/spec/frontend/autosave_spec.js b/spec/frontend/autosave_spec.js index 33d402388c9..1d73e452eb4 100644 --- a/spec/frontend/autosave_spec.js +++ b/spec/frontend/autosave_spec.js @@ -9,6 +9,7 @@ describe('Autosave', () => { let autosave; const field = $('<textarea></textarea>'); const key = 'key'; + const fallbackKey = 'fallbackKey'; describe('class constructor', () => { beforeEach(() => { @@ -22,6 +23,13 @@ describe('Autosave', () => { expect(AccessorUtilities.isLocalStorageAccessSafe).toHaveBeenCalled(); expect(autosave.isLocalStorageAvailable).toBe(true); }); + + it('should set .isLocalStorageAvailable if fallbackKey is passed', () => { + autosave = new Autosave(field, key, fallbackKey); + + expect(AccessorUtilities.isLocalStorageAccessSafe).toHaveBeenCalled(); + expect(autosave.isLocalStorageAvailable).toBe(true); + }); }); describe('restore', () => { @@ -151,4 +159,33 @@ describe('Autosave', () => { }); }); }); + + describe('restore with fallbackKey', () => { + beforeEach(() => { + autosave = { + field, + key, + fallbackKey, + }; + autosave.isLocalStorageAvailable = true; + }); + + it('should call .getItem', () => { + Autosave.prototype.restore.call(autosave); + + expect(window.localStorage.getItem).toHaveBeenCalledWith(fallbackKey); + }); + + it('should call .setItem for key and fallbackKey', () => { + Autosave.prototype.save.call(autosave); + + expect(window.localStorage.setItem).toHaveBeenCalledTimes(2); + }); + + it('should call .removeItem for key and fallbackKey', () => { + Autosave.prototype.reset.call(autosave); + + expect(window.localStorage.removeItem).toHaveBeenCalledTimes(2); + }); + }); }); diff --git a/spec/frontend/clusters/services/crossplane_provider_stack_spec.js b/spec/frontend/clusters/services/crossplane_provider_stack_spec.js index 0d234822d7b..d43dc9333b4 100644 --- a/spec/frontend/clusters/services/crossplane_provider_stack_spec.js +++ b/spec/frontend/clusters/services/crossplane_provider_stack_spec.js @@ -1,5 +1,5 @@ import { shallowMount } from '@vue/test-utils'; -import { GlDropdownItem } from '@gitlab/ui'; +import { GlDropdownItem, GlIcon } from '@gitlab/ui'; import CrossplaneProviderStack from '~/clusters/components/crossplane_provider_stack.vue'; describe('CrossplaneProviderStack component', () => { @@ -72,7 +72,12 @@ describe('CrossplaneProviderStack component', () => { findFirstDropdownElement().vm.$emit('click'); expect(wrapper.emitted().set[0][0].code).toEqual('gcp'); }); - it('it renders the correct dropdown text when no stack is selected', () => { + + it('renders the correct dropdown text when no stack is selected', () => { expect(wrapper.vm.dropdownText).toBe('Select Stack'); }); + + it('renders an external link', () => { + expect(wrapper.find(GlIcon).props('name')).toBe('external-link'); + }); }); diff --git a/spec/frontend/lib/utils/url_utility_spec.js b/spec/frontend/lib/utils/url_utility_spec.js index 6edb2e2dce2..8244acbceea 100644 --- a/spec/frontend/lib/utils/url_utility_spec.js +++ b/spec/frontend/lib/utils/url_utility_spec.js @@ -282,4 +282,20 @@ describe('URL utility', () => { expect(urlUtils.getWebSocketUrl(path)).toEqual('ws://example.com/lorem/ipsum?a=bc'); }); }); + + describe('queryToObject', () => { + it('converts search query into an object', () => { + const searchQuery = '?one=1&two=2'; + + expect(urlUtils.queryToObject(searchQuery)).toEqual({ one: '1', two: '2' }); + }); + }); + + describe('objectToQuery', () => { + it('converts search query object back into a search query', () => { + const searchQueryObject = { one: '1', two: '2' }; + + expect(urlUtils.objectToQuery(searchQueryObject)).toEqual('one=1&two=2'); + }); + }); }); diff --git a/spec/frontend/notes/components/note_edited_text_spec.js b/spec/frontend/notes/components/note_edited_text_spec.js index e4c8d954d50..e8d5a24e86a 100644 --- a/spec/frontend/notes/components/note_edited_text_spec.js +++ b/spec/frontend/notes/components/note_edited_text_spec.js @@ -1,47 +1,49 @@ -import Vue from 'vue'; -import noteEditedText from '~/notes/components/note_edited_text.vue'; - -describe('note_edited_text', () => { - let vm; - let props; +import { shallowMount, createLocalVue } from '@vue/test-utils'; +import NoteEditedText from '~/notes/components/note_edited_text.vue'; + +const localVue = createLocalVue(); +const propsData = { + actionText: 'Edited', + className: 'foo-bar', + editedAt: '2017-08-04T09:52:31.062Z', + editedBy: { + avatar_url: 'path', + id: 1, + name: 'Root', + path: '/root', + state: 'active', + username: 'root', + }, +}; + +describe('NoteEditedText', () => { + let wrapper; beforeEach(() => { - const Component = Vue.extend(noteEditedText); - props = { - actionText: 'Edited', - className: 'foo-bar', - editedAt: '2017-08-04T09:52:31.062Z', - editedBy: { - avatar_url: 'path', - id: 1, - name: 'Root', - path: '/root', - state: 'active', - username: 'root', - }, - }; - - vm = new Component({ - propsData: props, - }).$mount(); + wrapper = shallowMount(NoteEditedText, { + localVue, + propsData, + sync: false, + attachToDocument: true, + }); }); afterEach(() => { - vm.$destroy(); + wrapper.destroy(); }); it('should render block with provided className', () => { - expect(vm.$el.className).toEqual(props.className); + expect(wrapper.classes()).toContain(propsData.className); }); it('should render provided actionText', () => { - expect(vm.$el.textContent).toContain(props.actionText); + expect(wrapper.text().trim()).toContain(propsData.actionText); }); it('should render provided user information', () => { - const authorLink = vm.$el.querySelector('.js-user-link'); + const authorLink = wrapper.find('.js-user-link'); - expect(authorLink.getAttribute('href')).toEqual(props.editedBy.path); - expect(authorLink.textContent.trim()).toEqual(props.editedBy.name); + expect(authorLink.attributes('href')).toEqual(propsData.editedBy.path); + expect(authorLink.text().trim()).toEqual(propsData.editedBy.name); }); }); diff --git a/spec/frontend/registry/components/app_spec.js b/spec/frontend/registry/components/app_spec.js index a69c33c246d..2bb21c12fc9 100644 --- a/spec/frontend/registry/components/app_spec.js +++ b/spec/frontend/registry/components/app_spec.js @@ -39,6 +39,8 @@ describe('Registry List', () => { // See https://github.com/vuejs/vue-test-utils/issues/532. Vue.config.silent = true; wrapper = mount(registry, { + attachToDocument: true, + sync: false, propsData, computed: { repos() { @@ -67,6 +69,8 @@ describe('Registry List', () => { let localWrapper; beforeEach(() => { localWrapper = mount(registry, { + attachToDocument: true, + sync: false, propsData, computed: { repos() { diff --git a/spec/frontend/registry/components/collapsible_container_spec.js b/spec/frontend/registry/components/collapsible_container_spec.js index d035055afd3..3d07ab63776 100644 --- a/spec/frontend/registry/components/collapsible_container_spec.js +++ b/spec/frontend/registry/components/collapsible_container_spec.js @@ -22,7 +22,14 @@ describe('collapsible registry container', () => { const findToggleRepos = (w = wrapper) => w.findAll('.js-toggle-repo'); const findDeleteModal = (w = wrapper) => w.find({ ref: 'deleteModal' }); - const mountWithStore = config => mount(collapsibleComponent, { ...config, store, localVue }); + const mountWithStore = config => + mount(collapsibleComponent, { + ...config, + store, + localVue, + attachToDocument: true, + sync: false, + }); beforeEach(() => { createFlash.mockClear(); @@ -63,12 +70,15 @@ describe('collapsible registry container', () => { it('should be closed by default', () => { expectIsClosed(); }); - it('should be open when user clicks on closed repo', () => { + it('should be open when user clicks on closed repo', done => { const toggleRepos = findToggleRepos(wrapper); toggleRepos.at(0).trigger('click'); - const container = findContainerImageTags(wrapper); - expect(container.exists()).toBe(true); - expect(wrapper.vm.fetchList).toHaveBeenCalled(); + Vue.nextTick(() => { + const container = findContainerImageTags(wrapper); + expect(container.exists()).toBe(true); + expect(wrapper.vm.fetchList).toHaveBeenCalled(); + done(); + }); }); it('should be closed when the user clicks on an opened repo', done => { const toggleRepos = findToggleRepos(wrapper); diff --git a/spec/frontend/registry/components/project_empty_state_spec.js b/spec/frontend/registry/components/project_empty_state_spec.js index 913524db3aa..dd0fe32b68c 100644 --- a/spec/frontend/registry/components/project_empty_state_spec.js +++ b/spec/frontend/registry/components/project_empty_state_spec.js @@ -6,6 +6,8 @@ describe('Registry Project Empty state', () => { beforeEach(() => { wrapper = mount(projectEmptyState, { + attachToDocument: true, + sync: false, propsData: { noContainersImage: 'imageUrl', helpPagePath: 'help', diff --git a/spec/frontend/registry/components/table_registry_spec.js b/spec/frontend/registry/components/table_registry_spec.js index b9075f565e9..4566e6ed705 100644 --- a/spec/frontend/registry/components/table_registry_spec.js +++ b/spec/frontend/registry/components/table_registry_spec.js @@ -28,7 +28,8 @@ describe('table registry', () => { const findImageId = (w = wrapper) => w.find({ ref: 'imageId' }); const bulkDeletePath = 'path'; - const mountWithStore = config => mount(tableRegistry, { ...config, store, localVue }); + const mountWithStore = config => + mount(tableRegistry, { ...config, store, localVue, attachToDocument: true, sync: false }); beforeEach(() => { // This is needed due to console.error called by vue to emit a warning that stop the tests @@ -196,7 +197,7 @@ describe('table registry', () => { expect(wrapper.vm.handleSingleDelete).toHaveBeenCalledWith(repoPropsData.list[0]); expect(wrapper.vm.handleMultipleDelete).not.toHaveBeenCalled(); }); - it('on ok when multiple items are selected should call muultiDelete', () => { + it('on ok when multiple items are selected should call multiDelete', () => { wrapper.setData({ itemsToBeDeleted: [0, 1, 2] }); wrapper.vm.onDeletionConfirmed(); diff --git a/spec/javascripts/line_highlighter_spec.js b/spec/javascripts/line_highlighter_spec.js index f8f835ffdef..45b10fc3bd8 100644 --- a/spec/javascripts/line_highlighter_spec.js +++ b/spec/javascripts/line_highlighter_spec.js @@ -1,12 +1,11 @@ -/* eslint-disable no-var, no-else-return, dot-notation, no-return-assign, no-new, no-underscore-dangle */ +/* eslint-disable no-else-return, dot-notation, no-return-assign, no-new, no-underscore-dangle */ import $ from 'jquery'; import LineHighlighter from '~/line_highlighter'; describe('LineHighlighter', function() { - var clickLine; preloadFixtures('static/line_highlighter.html'); - clickLine = function(number, eventData = {}) { + const clickLine = function(number, eventData = {}) { if ($.isEmptyObject(eventData)) { return $(`#L${number}`).click(); } else { @@ -39,34 +38,30 @@ describe('LineHighlighter', function() { }); it('highlights a range of lines given in the URL hash', function() { - var line; new LineHighlighter({ hash: '#L5-25' }); expect($(`.${this.css}`).length).toBe(21); - for (line = 5; line <= 25; line += 1) { + for (let line = 5; line <= 25; line += 1) { expect($(`#LC${line}`)).toHaveClass(this.css); } }); it('scrolls to the first highlighted line on initial load', function() { - var spy; - spy = spyOn($, 'scrollTo'); + const spy = spyOn($, 'scrollTo'); new LineHighlighter({ hash: '#L5-25' }); expect(spy).toHaveBeenCalledWith('#L5', jasmine.anything()); }); it('discards click events', function() { - var spy; - spy = spyOnEvent('a[data-line-number]', 'click'); + const spy = spyOnEvent('a[data-line-number]', 'click'); clickLine(13); expect(spy).toHaveBeenPrevented(); }); it('handles garbage input from the hash', function() { - var func; - func = function() { + const func = function() { return new LineHighlighter({ fileHolderSelector: '#blob-content-holder' }); }; @@ -76,8 +71,7 @@ describe('LineHighlighter', function() { describe('clickHandler', function() { it('handles clicking on a child icon element', function() { - var spy; - spy = spyOn(this['class'], 'setHash').and.callThrough(); + const spy = spyOn(this['class'], 'setHash').and.callThrough(); $('#L13 i') .mousedown() .click(); @@ -102,8 +96,7 @@ describe('LineHighlighter', function() { }); it('sets the hash', function() { - var spy; - spy = spyOn(this['class'], 'setHash').and.callThrough(); + const spy = spyOn(this['class'], 'setHash').and.callThrough(); clickLine(13); expect(spy).toHaveBeenCalledWith(13); @@ -112,8 +105,7 @@ describe('LineHighlighter', function() { describe('with shiftKey', function() { it('sets the hash', function() { - var spy; - spy = spyOn(this['class'], 'setHash').and.callThrough(); + const spy = spyOn(this['class'], 'setHash').and.callThrough(); clickLine(13); clickLine(20, { shiftKey: true, @@ -134,8 +126,7 @@ describe('LineHighlighter', function() { }); it('sets the hash', function() { - var spy; - spy = spyOn(this['class'], 'setHash'); + const spy = spyOn(this['class'], 'setHash'); clickLine(13, { shiftKey: true, }); @@ -146,27 +137,25 @@ describe('LineHighlighter', function() { describe('with existing single-line highlight', function() { it('uses existing line as last line when target is lesser', function() { - var line; clickLine(20); clickLine(15, { shiftKey: true, }); expect($(`.${this.css}`).length).toBe(6); - for (line = 15; line <= 20; line += 1) { + for (let line = 15; line <= 20; line += 1) { expect($(`#LC${line}`)).toHaveClass(this.css); } }); it('uses existing line as first line when target is greater', function() { - var line; clickLine(5); clickLine(10, { shiftKey: true, }); expect($(`.${this.css}`).length).toBe(6); - for (line = 5; line <= 10; line += 1) { + for (let line = 5; line <= 10; line += 1) { expect($(`#LC${line}`)).toHaveClass(this.css); } }); @@ -183,25 +172,23 @@ describe('LineHighlighter', function() { }); it('uses target as first line when it is less than existing first line', function() { - var line; clickLine(5, { shiftKey: true, }); expect($(`.${this.css}`).length).toBe(6); - for (line = 5; line <= 10; line += 1) { + for (let line = 5; line <= 10; line += 1) { expect($(`#LC${line}`)).toHaveClass(this.css); } }); it('uses target as last line when it is greater than existing first line', function() { - var line; clickLine(15, { shiftKey: true, }); expect($(`.${this.css}`).length).toBe(6); - for (line = 10; line <= 15; line += 1) { + for (let line = 10; line <= 15; line += 1) { expect($(`#LC${line}`)).toHaveClass(this.css); } }); diff --git a/spec/javascripts/monitoring/components/graph_group_spec.js b/spec/javascripts/monitoring/components/graph_group_spec.js index 068c4b5302c..7bcab9116e9 100644 --- a/spec/javascripts/monitoring/components/graph_group_spec.js +++ b/spec/javascripts/monitoring/components/graph_group_spec.js @@ -3,6 +3,8 @@ import GraphGroup from '~/monitoring/components/graph_group.vue'; describe('Graph group component', () => { let graphGroup; + const findPrometheusGroup = () => graphGroup.find('.prometheus-graph-group'); + const findPrometheusPanel = () => graphGroup.find('.prometheus-panel'); afterEach(() => { graphGroup.destroy(); @@ -40,8 +42,32 @@ describe('Graph group component', () => { }); }); - it('should not contain a prometheus-graph-group container when showPanels is false', () => { - expect(graphGroup.vm.$el.querySelector('.prometheus-graph-group')).toBe(null); + it('should not contain a prometheus-panel container when showPanels is false', () => { + expect(findPrometheusPanel().exists()).toBe(false); + }); + }); + + describe('When collapseGroup prop is updated', () => { + beforeEach(() => { + graphGroup = shallowMount(GraphGroup, { + propsData: { + name: 'panel', + collapseGroup: false, + }, + }); + }); + + it('previously collapsed group should respond to the prop change', done => { + expect(findPrometheusGroup().exists()).toBe(false); + + graphGroup.setProps({ + collapseGroup: true, + }); + + graphGroup.vm.$nextTick(() => { + expect(findPrometheusGroup().exists()).toBe(true); + done(); + }); }); }); }); diff --git a/spec/lib/gitlab/git/attributes_at_ref_parser_spec.rb b/spec/lib/gitlab/git/attributes_at_ref_parser_spec.rb index 134bd5657e7..6c4f650fa83 100644 --- a/spec/lib/gitlab/git/attributes_at_ref_parser_spec.rb +++ b/spec/lib/gitlab/git/attributes_at_ref_parser_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::AttributesAtRefParser, :seed_helper do diff --git a/spec/lib/gitlab/git/attributes_parser_spec.rb b/spec/lib/gitlab/git/attributes_parser_spec.rb index f431d4e2a53..94b7a086e59 100644 --- a/spec/lib/gitlab/git/attributes_parser_spec.rb +++ b/spec/lib/gitlab/git/attributes_parser_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::AttributesParser, :seed_helper do diff --git a/spec/lib/gitlab/git/blame_spec.rb b/spec/lib/gitlab/git/blame_spec.rb index ac085e2c266..9b2d6fa3bcb 100644 --- a/spec/lib/gitlab/git/blame_spec.rb +++ b/spec/lib/gitlab/git/blame_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe Gitlab::Git::Blame, :seed_helper do diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb index 7f680071969..15d03a481d5 100644 --- a/spec/lib/gitlab/git/blob_spec.rb +++ b/spec/lib/gitlab/git/blob_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe Gitlab::Git::Blob, :seed_helper do diff --git a/spec/lib/gitlab/git/branch_spec.rb b/spec/lib/gitlab/git/branch_spec.rb index 02ef7b92538..cc26b7e7fcd 100644 --- a/spec/lib/gitlab/git/branch_spec.rb +++ b/spec/lib/gitlab/git/branch_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe Gitlab::Git::Branch, :seed_helper do @@ -77,7 +79,7 @@ describe Gitlab::Git::Branch, :seed_helper do tree = parents.first.tree { - message: 'commit message', + message: +'commit message', author: committer, committer: committer, tree: tree, @@ -126,7 +128,7 @@ describe Gitlab::Git::Branch, :seed_helper do it { expect(repository.branches.size).to eq(SeedRepo::Repo::BRANCHES.size) } def create_commit - params[:message].delete!("\r") + params[:message].delete!(+"\r") Rugged::Commit.create(rugged, params.merge(committer: committer.merge(time: Time.now))) end end diff --git a/spec/lib/gitlab/git/bundle_file_spec.rb b/spec/lib/gitlab/git/bundle_file_spec.rb index ff7c981dadd..e88e163a03f 100644 --- a/spec/lib/gitlab/git/bundle_file_spec.rb +++ b/spec/lib/gitlab/git/bundle_file_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::BundleFile do diff --git a/spec/lib/gitlab/git/commit_spec.rb b/spec/lib/gitlab/git/commit_spec.rb index cdab7127748..6c9467916de 100644 --- a/spec/lib/gitlab/git/commit_spec.rb +++ b/spec/lib/gitlab/git/commit_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe Gitlab::Git::Commit, :seed_helper do @@ -64,8 +66,8 @@ describe Gitlab::Git::Commit, :seed_helper do end describe "Commit info from gitaly commit" do - let(:subject) { "My commit".force_encoding('ASCII-8BIT') } - let(:body) { subject + "My body".force_encoding('ASCII-8BIT') } + let(:subject) { (+"My commit").force_encoding('ASCII-8BIT') } + let(:body) { subject + (+"My body").force_encoding('ASCII-8BIT') } let(:body_size) { body.length } let(:gitaly_commit) { build(:gitaly_commit, subject: subject, body: body, body_size: body_size) } let(:id) { gitaly_commit.id } @@ -85,7 +87,7 @@ describe Gitlab::Git::Commit, :seed_helper do it { expect(commit.parent_ids).to eq(gitaly_commit.parent_ids) } context 'body_size != body.size' do - let(:body) { "".force_encoding('ASCII-8BIT') } + let(:body) { (+"").force_encoding('ASCII-8BIT') } context 'zero body_size' do it { expect(commit.safe_message).to eq(subject) } diff --git a/spec/lib/gitlab/git/compare_spec.rb b/spec/lib/gitlab/git/compare_spec.rb index 65dfb93d0db..6136df57acb 100644 --- a/spec/lib/gitlab/git/compare_spec.rb +++ b/spec/lib/gitlab/git/compare_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe Gitlab::Git::Compare, :seed_helper do diff --git a/spec/lib/gitlab/git/conflict/file_spec.rb b/spec/lib/gitlab/git/conflict/file_spec.rb index a6cabd4966a..0ee9ff93e87 100644 --- a/spec/lib/gitlab/git/conflict/file_spec.rb +++ b/spec/lib/gitlab/git/conflict/file_spec.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::Conflict::File do let(:conflict) { { theirs: { path: 'foo', mode: 33188 }, ours: { path: 'foo', mode: 33188 } } } - let(:invalid_content) { described_class.new(nil, nil, conflict, "a\xC4\xFC".force_encoding(Encoding::ASCII_8BIT)) } - let(:valid_content) { described_class.new(nil, nil, conflict, "Espa\xC3\xB1a".force_encoding(Encoding::ASCII_8BIT)) } + let(:invalid_content) { described_class.new(nil, nil, conflict, (+"a\xC4\xFC").force_encoding(Encoding::ASCII_8BIT)) } + let(:valid_content) { described_class.new(nil, nil, conflict, (+"Espa\xC3\xB1a").force_encoding(Encoding::ASCII_8BIT)) } describe '#lines' do context 'when the content contains non-UTF-8 characters' do diff --git a/spec/lib/gitlab/git/conflict/parser_spec.rb b/spec/lib/gitlab/git/conflict/parser_spec.rb index 29a1702a1c6..600c870acd4 100644 --- a/spec/lib/gitlab/git/conflict/parser_spec.rb +++ b/spec/lib/gitlab/git/conflict/parser_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::Conflict::Parser do @@ -208,7 +210,7 @@ CONFLICT # these strings. context 'when the file contains UTF-8 characters' do it 'does not raise' do - expect { parse_text("Espa\xC3\xB1a".force_encoding(Encoding::ASCII_8BIT)) } + expect { parse_text((+"Espa\xC3\xB1a").force_encoding(Encoding::ASCII_8BIT)) } .not_to raise_error end end diff --git a/spec/lib/gitlab/git/diff_collection_spec.rb b/spec/lib/gitlab/git/diff_collection_spec.rb index ce45d6e24ba..0d19d35bc52 100644 --- a/spec/lib/gitlab/git/diff_collection_spec.rb +++ b/spec/lib/gitlab/git/diff_collection_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::DiffCollection, :seed_helper do diff --git a/spec/lib/gitlab/git/diff_spec.rb b/spec/lib/gitlab/git/diff_spec.rb index 9ab669ad488..456d6af7bd8 100644 --- a/spec/lib/gitlab/git/diff_spec.rb +++ b/spec/lib/gitlab/git/diff_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe Gitlab::Git::Diff, :seed_helper do diff --git a/spec/lib/gitlab/git/gitmodules_parser_spec.rb b/spec/lib/gitlab/git/gitmodules_parser_spec.rb index de81dcd227d..58d1d2c71da 100644 --- a/spec/lib/gitlab/git/gitmodules_parser_spec.rb +++ b/spec/lib/gitlab/git/gitmodules_parser_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::GitmodulesParser do diff --git a/spec/lib/gitlab/git/hook_env_spec.rb b/spec/lib/gitlab/git/hook_env_spec.rb index 5e49ea6da7a..ca6a4ad42a3 100644 --- a/spec/lib/gitlab/git/hook_env_spec.rb +++ b/spec/lib/gitlab/git/hook_env_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::HookEnv do diff --git a/spec/lib/gitlab/git/lfs_changes_spec.rb b/spec/lib/gitlab/git/lfs_changes_spec.rb index d035df7e0c2..a99e8c4f60c 100644 --- a/spec/lib/gitlab/git/lfs_changes_spec.rb +++ b/spec/lib/gitlab/git/lfs_changes_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::LfsChanges do diff --git a/spec/lib/gitlab/git/lfs_pointer_file_spec.rb b/spec/lib/gitlab/git/lfs_pointer_file_spec.rb index d7f76737f3f..8bb26ed4854 100644 --- a/spec/lib/gitlab/git/lfs_pointer_file_spec.rb +++ b/spec/lib/gitlab/git/lfs_pointer_file_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::LfsPointerFile do diff --git a/spec/lib/gitlab/git/pre_receive_error_spec.rb b/spec/lib/gitlab/git/pre_receive_error_spec.rb index cb030e38032..cb539261671 100644 --- a/spec/lib/gitlab/git/pre_receive_error_spec.rb +++ b/spec/lib/gitlab/git/pre_receive_error_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::PreReceiveError do diff --git a/spec/lib/gitlab/git/push_spec.rb b/spec/lib/gitlab/git/push_spec.rb index 566c8209504..32c4c1c82d4 100644 --- a/spec/lib/gitlab/git/push_spec.rb +++ b/spec/lib/gitlab/git/push_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::Push do diff --git a/spec/lib/gitlab/git/raw_diff_change_spec.rb b/spec/lib/gitlab/git/raw_diff_change_spec.rb index a0bb37fd84a..79b2fc21011 100644 --- a/spec/lib/gitlab/git/raw_diff_change_spec.rb +++ b/spec/lib/gitlab/git/raw_diff_change_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::RawDiffChange do diff --git a/spec/lib/gitlab/git/remote_mirror_spec.rb b/spec/lib/gitlab/git/remote_mirror_spec.rb index dc63eef7814..9744562b51b 100644 --- a/spec/lib/gitlab/git/remote_mirror_spec.rb +++ b/spec/lib/gitlab/git/remote_mirror_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::RemoteMirror do diff --git a/spec/lib/gitlab/git/remote_repository_spec.rb b/spec/lib/gitlab/git/remote_repository_spec.rb index e166628d4ca..556cc692231 100644 --- a/spec/lib/gitlab/git/remote_repository_spec.rb +++ b/spec/lib/gitlab/git/remote_repository_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::RemoteRepository, :seed_helper do diff --git a/spec/lib/gitlab/git/repository_cleaner_spec.rb b/spec/lib/gitlab/git/repository_cleaner_spec.rb index 7bba0107e58..b387d1033d3 100644 --- a/spec/lib/gitlab/git/repository_cleaner_spec.rb +++ b/spec/lib/gitlab/git/repository_cleaner_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::RepositoryCleaner do diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 44c41da7560..20a74af7a45 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe Gitlab::Git::Repository, :seed_helper do diff --git a/spec/lib/gitlab/git/tag_spec.rb b/spec/lib/gitlab/git/tag_spec.rb index 4c0291f64f0..87db3f588ad 100644 --- a/spec/lib/gitlab/git/tag_spec.rb +++ b/spec/lib/gitlab/git/tag_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe Gitlab::Git::Tag, :seed_helper do diff --git a/spec/lib/gitlab/git/tree_spec.rb b/spec/lib/gitlab/git/tree_spec.rb index 7e169cfe270..98bb4ffd0bd 100644 --- a/spec/lib/gitlab/git/tree_spec.rb +++ b/spec/lib/gitlab/git/tree_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe Gitlab::Git::Tree, :seed_helper do diff --git a/spec/lib/gitlab/git/user_spec.rb b/spec/lib/gitlab/git/user_spec.rb index d9d338206f8..277b1c48355 100644 --- a/spec/lib/gitlab/git/user_spec.rb +++ b/spec/lib/gitlab/git/user_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::User do diff --git a/spec/lib/gitlab/git/util_spec.rb b/spec/lib/gitlab/git/util_spec.rb index 88c871855df..81918f036f9 100644 --- a/spec/lib/gitlab/git/util_spec.rb +++ b/spec/lib/gitlab/git/util_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::Util do diff --git a/spec/lib/gitlab/git/wiki_spec.rb b/spec/lib/gitlab/git/wiki_spec.rb index 1e577392949..8bae2e8125e 100644 --- a/spec/lib/gitlab/git/wiki_spec.rb +++ b/spec/lib/gitlab/git/wiki_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::Wiki do diff --git a/spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb b/spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb index bcf4814edb6..a4489cca443 100644 --- a/spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb +++ b/spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Git::WrapsGitalyErrors do diff --git a/spec/lib/gitlab/gpg/commit_spec.rb b/spec/lib/gitlab/gpg/commit_spec.rb index 8401b683fd5..ea0a6e1b967 100644 --- a/spec/lib/gitlab/gpg/commit_spec.rb +++ b/spec/lib/gitlab/gpg/commit_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::Gpg::Commit do diff --git a/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb b/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb index da307754243..c1516a48b80 100644 --- a/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb +++ b/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index df82ac38fc6..ad256c10964 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -990,7 +990,8 @@ describe Notify do end context 'when a comment on an existing discussion' do - let!(:second_note) { create(model, author: note_author, noteable: nil, in_reply_to: note) } + let(:first_note) { create_note } + let(:note) { create(model, author: note_author, noteable: nil, in_reply_to: first_note) } it 'contains an introduction' do is_expected.to have_body_text 'commented on a' @@ -1000,7 +1001,11 @@ describe Notify do describe 'on a commit' do let(:commit) { project.commit } - let(:note) { create(:discussion_note_on_commit, commit_id: commit.id, project: project, author: note_author) } + let(:note) { create_note } + + def create_note + create(:discussion_note_on_commit, commit_id: commit.id, project: project, author: note_author) + end before do allow(note).to receive(:noteable).and_return(commit) @@ -1027,9 +1032,13 @@ describe Notify do end describe 'on a merge request' do - let(:note) { create(:discussion_note_on_merge_request, noteable: merge_request, project: project, author: note_author) } + let(:note) { create_note } let(:note_on_merge_request_path) { project_merge_request_path(project, merge_request, anchor: "note_#{note.id}") } + def create_note + create(:discussion_note_on_merge_request, noteable: merge_request, project: project, author: note_author) + end + before do allow(note).to receive(:noteable).and_return(merge_request) end @@ -1055,9 +1064,13 @@ describe Notify do end describe 'on an issue' do - let(:note) { create(:discussion_note_on_issue, noteable: issue, project: project, author: note_author) } + let(:note) { create_note } let(:note_on_issue_path) { project_issue_path(project, issue, anchor: "note_#{note.id}") } + def create_note + create(:discussion_note_on_issue, noteable: issue, project: project, author: note_author) + end + before do allow(note).to receive(:noteable).and_return(issue) end @@ -1134,7 +1147,8 @@ describe Notify do end context 'when a comment on an existing discussion' do - let!(:second_note) { create(model, author: note_author, noteable: nil, in_reply_to: note) } + let(:first_note) { create(model) } + let(:note) { create(model, author: note_author, noteable: nil, in_reply_to: first_note) } it 'contains an introduction' do is_expected.to have_body_text 'commented on a discussion on' diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 3ab88b52568..b09e699a8a7 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -456,6 +456,19 @@ describe Note do end end + describe '#start_of_discussion?' do + let_it_be(:note) { create(:discussion_note_on_merge_request) } + let_it_be(:reply) { create(:discussion_note_on_merge_request, in_reply_to: note) } + + it 'returns true when note is the start of a discussion' do + expect(note).to be_start_of_discussion + end + + it 'returns false when note is a reply' do + expect(reply).not_to be_start_of_discussion + end + end + describe '.find_discussion' do let!(:note) { create(:discussion_note_on_merge_request) } let!(:note2) { create(:discussion_note_on_merge_request, in_reply_to: note) } |