diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-12 18:09:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-12 18:09:33 +0300 |
commit | 006000e366ad5dc61966770d33e3afd4c07e728d (patch) | |
tree | 2724bc1cd73a6f829d62f5ca68a423b921bd1af8 /spec | |
parent | 26e44c6225a19c3ec4e7d607f92b16d42b437c80 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/benchmarks/banzai_benchmark.rb | 2 | ||||
-rw-r--r-- | spec/features/markdown/markdown_spec.rb | 2 | ||||
-rw-r--r-- | spec/frontend/boards/mock_data.js | 44 | ||||
-rw-r--r-- | spec/frontend/boards/project_select_deprecated_spec.js | 1 | ||||
-rw-r--r-- | spec/frontend/boards/project_select_spec.js | 64 | ||||
-rw-r--r-- | spec/frontend/boards/stores/getters_spec.js | 12 | ||||
-rw-r--r-- | spec/lib/banzai/filter/gollum_tags_filter_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/tracking_spec.rb | 4 | ||||
-rw-r--r-- | spec/mailers/emails/in_product_marketing_spec.rb | 44 | ||||
-rw-r--r-- | spec/support/shared_examples/models/wiki_shared_examples.rb | 46 | ||||
-rw-r--r-- | spec/tooling/danger/project_helper_spec.rb | 2 |
11 files changed, 162 insertions, 63 deletions
diff --git a/spec/benchmarks/banzai_benchmark.rb b/spec/benchmarks/banzai_benchmark.rb index a87414ba512..4cf079b2130 100644 --- a/spec/benchmarks/banzai_benchmark.rb +++ b/spec/benchmarks/banzai_benchmark.rb @@ -56,7 +56,7 @@ RSpec.describe 'GitLab Markdown Benchmark', :aggregate_failures do it 'benchmarks several pipelines' do path = 'images/example.jpg' gitaly_wiki_file = Gitlab::GitalyClient::WikiFile.new(path: path) - allow(wiki).to receive(:find_file).with(path).and_return(Gitlab::Git::WikiFile.new(gitaly_wiki_file)) + allow(wiki).to receive(:find_file).with(path, load_content: false).and_return(Gitlab::Git::WikiFile.new(gitaly_wiki_file)) allow(wiki).to receive(:wiki_base_path) { '/namespace1/gitlabhq/wikis' } puts "\n--> Benchmarking Full, Wiki, and Plain pipelines\n" diff --git a/spec/features/markdown/markdown_spec.rb b/spec/features/markdown/markdown_spec.rb index 8e28f89f49e..e84b300a748 100644 --- a/spec/features/markdown/markdown_spec.rb +++ b/spec/features/markdown/markdown_spec.rb @@ -290,7 +290,7 @@ RSpec.describe 'GitLab Markdown', :aggregate_failures do path = 'images/example.jpg' gitaly_wiki_file = Gitlab::GitalyClient::WikiFile.new(path: path) - expect(@wiki).to receive(:find_file).with(path).and_return(Gitlab::Git::WikiFile.new(gitaly_wiki_file)) + expect(@wiki).to receive(:find_file).with(path, load_content: false).and_return(Gitlab::Git::WikiFile.new(gitaly_wiki_file)) allow(@wiki).to receive(:wiki_base_path) { '/namespace1/gitlabhq/wikis' } @html = markdown(@feat.raw_markdown, { pipeline: :wiki, wiki: @wiki, page_slug: @wiki_page.slug }) diff --git a/spec/frontend/boards/mock_data.js b/spec/frontend/boards/mock_data.js index e106b9235d6..500240d00fc 100644 --- a/spec/frontend/boards/mock_data.js +++ b/spec/frontend/boards/mock_data.js @@ -351,6 +351,7 @@ export const issues = { [mockIssue4.id]: mockIssue4, }; +// The response from group project REST API export const mockRawGroupProjects = [ { id: 0, @@ -366,17 +367,34 @@ export const mockRawGroupProjects = [ }, ]; -export const mockGroupProjects = [ - { - id: 0, - name: 'Example Project', - nameWithNamespace: 'Awesome Group / Example Project', - fullPath: 'awesome-group/example-project', - }, - { - id: 1, - name: 'Foobar Project', - nameWithNamespace: 'Awesome Group / Foobar Project', - fullPath: 'awesome-group/foobar-project', - }, +// The response from GraphQL endpoint +export const mockGroupProject1 = { + id: 0, + name: 'Example Project', + nameWithNamespace: 'Awesome Group / Example Project', + fullPath: 'awesome-group/example-project', + archived: false, +}; + +export const mockGroupProject2 = { + id: 1, + name: 'Foobar Project', + nameWithNamespace: 'Awesome Group / Foobar Project', + fullPath: 'awesome-group/foobar-project', + archived: false, +}; + +export const mockArchivedGroupProject = { + id: 2, + name: 'Archived Project', + nameWithNamespace: 'Awesome Group / Archived Project', + fullPath: 'awesome-group/archived-project', + archived: true, +}; + +export const mockGroupProjects = [mockGroupProject1, mockGroupProject2]; + +export const mockActiveGroupProjects = [ + { ...mockGroupProject1, archived: false }, + { ...mockGroupProject2, archived: false }, ]; diff --git a/spec/frontend/boards/project_select_deprecated_spec.js b/spec/frontend/boards/project_select_deprecated_spec.js index 9042c4bf9ba..37f519ef5b9 100644 --- a/spec/frontend/boards/project_select_deprecated_spec.js +++ b/spec/frontend/boards/project_select_deprecated_spec.js @@ -27,6 +27,7 @@ const mockDefaultFetchOptions = { with_shared: false, include_subgroups: true, order_by: 'similarity', + archived: false, }; const itemsPerPage = 20; diff --git a/spec/frontend/boards/project_select_spec.js b/spec/frontend/boards/project_select_spec.js index aa71952c42b..de823094630 100644 --- a/spec/frontend/boards/project_select_spec.js +++ b/spec/frontend/boards/project_select_spec.js @@ -1,30 +1,17 @@ import { GlDropdown, GlDropdownItem, GlSearchBoxByType, GlLoadingIcon } from '@gitlab/ui'; -import { createLocalVue, mount } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import ProjectSelect from '~/boards/components/project_select.vue'; import defaultState from '~/boards/stores/state'; -import { mockList, mockGroupProjects } from './mock_data'; +import { mockList, mockActiveGroupProjects } from './mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); - -const actions = { - fetchGroupProjects: jest.fn(), - setSelectedProject: jest.fn(), -}; - -const createStore = (state = defaultState) => { - return new Vuex.Store({ - state, - actions, - }); -}; - -const mockProjectsList1 = mockGroupProjects.slice(0, 1); +const mockProjectsList1 = mockActiveGroupProjects.slice(0, 1); describe('ProjectSelect component', () => { let wrapper; + let store; const findLabel = () => wrapper.find("[data-testid='header-label']"); const findGlDropdown = () => wrapper.find(GlDropdown); @@ -36,20 +23,37 @@ describe('ProjectSelect component', () => { const findInMenuLoadingIcon = () => wrapper.find("[data-testid='dropdown-text-loading-icon']"); const findEmptySearchMessage = () => wrapper.find("[data-testid='empty-result-message']"); - const createWrapper = (state = {}) => { - const store = createStore({ - groupProjects: [], - groupProjectsFlags: { - isLoading: false, - pageInfo: { - hasNextPage: false, + const createStore = ({ state, activeGroupProjects }) => { + Vue.use(Vuex); + + store = new Vuex.Store({ + state: { + defaultState, + groupProjectsFlags: { + isLoading: false, + pageInfo: { + hasNextPage: false, + }, }, + ...state, + }, + actions: { + fetchGroupProjects: jest.fn(), + setSelectedProject: jest.fn(), }, - ...state, + getters: { + activeGroupProjects: () => activeGroupProjects, + }, + }); + }; + + const createWrapper = ({ state = {}, activeGroupProjects = [] } = {}) => { + createStore({ + state, + activeGroupProjects, }); wrapper = mount(ProjectSelect, { - localVue, propsData: { list: mockList, }, @@ -93,7 +97,7 @@ describe('ProjectSelect component', () => { describe('when dropdown menu is open', () => { describe('by default', () => { beforeEach(() => { - createWrapper({ groupProjects: mockGroupProjects }); + createWrapper({ activeGroupProjects: mockActiveGroupProjects }); }); it('shows GlSearchBoxByType with default attributes', () => { @@ -128,7 +132,7 @@ describe('ProjectSelect component', () => { describe('when a project is selected', () => { beforeEach(() => { - createWrapper({ groupProjects: mockProjectsList1 }); + createWrapper({ activeGroupProjects: mockProjectsList1 }); findFirstGlDropdownItem().find('button').trigger('click'); }); @@ -142,7 +146,7 @@ describe('ProjectSelect component', () => { describe('when projects are loading', () => { beforeEach(() => { - createWrapper({ groupProjectsFlags: { isLoading: true } }); + createWrapper({ state: { groupProjectsFlags: { isLoading: true } } }); }); it('displays and hides gl-loading-icon while and after fetching data', () => { diff --git a/spec/frontend/boards/stores/getters_spec.js b/spec/frontend/boards/stores/getters_spec.js index c0c19e9d797..32d73d861bc 100644 --- a/spec/frontend/boards/stores/getters_spec.js +++ b/spec/frontend/boards/stores/getters_spec.js @@ -7,6 +7,8 @@ import { mockIssuesByListId, issues, mockLists, + mockGroupProject1, + mockArchivedGroupProject, } from '../mock_data'; describe('Boards - Getters', () => { @@ -165,4 +167,14 @@ describe('Boards - Getters', () => { expect(getters.getListByTitle(boardsState)('To Do')).toEqual(mockLists[1]); }); }); + + describe('activeGroupProjects', () => { + const state = { + groupProjects: [mockGroupProject1, mockArchivedGroupProject], + }; + + it('returns only returns non-archived group projects', () => { + expect(getters.activeGroupProjects(state)).toEqual([mockGroupProject1]); + }); + }); }); diff --git a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb index f39b5280490..ec17bb26346 100644 --- a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb +++ b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb @@ -22,7 +22,7 @@ RSpec.describe Banzai::Filter::GollumTagsFilter do path: 'images/image.jpg', raw_data: '') wiki_file = Gitlab::Git::WikiFile.new(gollum_file_double) - expect(wiki).to receive(:find_file).with('images/image.jpg').and_return(wiki_file) + expect(wiki).to receive(:find_file).with('images/image.jpg', load_content: false).and_return(wiki_file) tag = '[[images/image.jpg]]' doc = filter("See #{tag}", wiki: wiki) @@ -31,7 +31,7 @@ RSpec.describe Banzai::Filter::GollumTagsFilter do end it 'does not creates img tag if image does not exist' do - expect(wiki).to receive(:find_file).with('images/image.jpg').and_return(nil) + expect(wiki).to receive(:find_file).with('images/image.jpg', load_content: false).and_return(nil) tag = '[[images/image.jpg]]' doc = filter("See #{tag}", wiki: wiki) diff --git a/spec/lib/gitlab/tracking_spec.rb b/spec/lib/gitlab/tracking_spec.rb index 80740c8112e..ac052bd7a80 100644 --- a/spec/lib/gitlab/tracking_spec.rb +++ b/spec/lib/gitlab/tracking_spec.rb @@ -61,8 +61,8 @@ RSpec.describe Gitlab::Tracking do expect(args[:property]).to eq('property') expect(args[:value]).to eq(1.5) expect(args[:context].length).to eq(2) - expect(args[:context].first).to eq(other_context) - expect(args[:context].last.to_json[:schema]).to eq(Gitlab::Tracking::StandardContext::GITLAB_STANDARD_SCHEMA_URL) + expect(args[:context].first.to_json[:schema]).to eq(Gitlab::Tracking::StandardContext::GITLAB_STANDARD_SCHEMA_URL) + expect(args[:context].last).to eq(other_context) end described_class.event('category', 'action', label: 'label', property: 'property', value: 1.5, diff --git a/spec/mailers/emails/in_product_marketing_spec.rb b/spec/mailers/emails/in_product_marketing_spec.rb new file mode 100644 index 00000000000..e4157eaf5dc --- /dev/null +++ b/spec/mailers/emails/in_product_marketing_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require 'spec_helper' +require 'email_spec' + +RSpec.describe Emails::InProductMarketing do + include EmailSpec::Matchers + include InProductMarketingHelper + + let_it_be(:user) { create(:user) } + let_it_be(:group) { create(:group) } + + describe '#in_product_marketing_email' do + using RSpec::Parameterized::TableSyntax + + where(:track, :series) do + :create | 0 + :create | 1 + :create | 2 + :verify | 0 + :verify | 1 + :verify | 2 + :trial | 0 + :trial | 1 + :trial | 2 + :team | 0 + :team | 1 + :team | 2 + end + + with_them do + subject { Notify.in_product_marketing_email(user.id, group.id, track, series) } + + it 'has the correct subject and content' do + aggregate_failures do + is_expected.to have_subject(subject_line(track, series)) + is_expected.to have_body_text(in_product_marketing_title(track, series)) + is_expected.to have_body_text(in_product_marketing_subtitle(track, series)) + is_expected.to have_body_text(in_product_marketing_cta_text(track, series)) + end + end + end + end +end diff --git a/spec/support/shared_examples/models/wiki_shared_examples.rb b/spec/support/shared_examples/models/wiki_shared_examples.rb index 89d30688b5c..abc6e3ecce8 100644 --- a/spec/support/shared_examples/models/wiki_shared_examples.rb +++ b/spec/support/shared_examples/models/wiki_shared_examples.rb @@ -354,27 +354,47 @@ RSpec.shared_examples 'wiki model' do subject.repository.create_file(user, 'image.png', image, branch_name: subject.default_branch, message: 'add image') end - it 'returns the latest version of the file if it exists' do - file = subject.find_file('image.png') + shared_examples 'find_file results' do + it 'returns the latest version of the file if it exists' do + file = subject.find_file('image.png') - expect(file.mime_type).to eq('image/png') - end + expect(file.mime_type).to eq('image/png') + end + + it 'returns nil if the page does not exist' do + expect(subject.find_file('non-existent')).to eq(nil) + end + + it 'returns a Gitlab::Git::WikiFile instance' do + file = subject.find_file('image.png') + + expect(file).to be_a Gitlab::Git::WikiFile + end - it 'returns nil if the page does not exist' do - expect(subject.find_file('non-existent')).to eq(nil) + it 'returns the whole file' do + file = subject.find_file('image.png') + image.rewind + + expect(file.raw_data.b).to eq(image.read.b) + end end - it 'returns a Gitlab::Git::WikiFile instance' do - file = subject.find_file('image.png') + it_behaves_like 'find_file results' + + context 'when load_content is disabled' do + it 'includes the file data in the Gitlab::Git::WikiFile' do + file = subject.find_file('image.png', load_content: false) - expect(file).to be_a Gitlab::Git::WikiFile + expect(file.raw_data).to be_empty + end end - it 'returns the whole file' do - file = subject.find_file('image.png') - image.rewind + context 'when feature flag :gitaly_find_file is disabled' do + before do + stub_feature_flags(gitaly_find_file: false) + end - expect(file.raw_data.b).to eq(image.read.b) + it_behaves_like 'find_file results' end end diff --git a/spec/tooling/danger/project_helper_spec.rb b/spec/tooling/danger/project_helper_spec.rb index ff4afcf6863..a8fda901b4a 100644 --- a/spec/tooling/danger/project_helper_spec.rb +++ b/spec/tooling/danger/project_helper_spec.rb @@ -236,7 +236,7 @@ RSpec.describe Tooling::Danger::ProjectHelper do subject { project_helper.all_ee_changes } it 'returns all changed files starting with ee/' do - expect(project_helper).to receive(:all_changed_files).and_return(%w[fr/ee/beer.rb ee/wine.rb ee/lib/ido.rb ee.k]) + expect(fake_helper).to receive(:all_changed_files).and_return(%w[fr/ee/beer.rb ee/wine.rb ee/lib/ido.rb ee.k]) is_expected.to match_array(%w[ee/wine.rb ee/lib/ido.rb]) end |