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-10-30 15:06:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-30 15:06:34 +0300
commit228d752ff09362002cc904d28edee7d63cc3cef2 (patch)
tree63e7ff466c0b0794f67c87c34e874f8682fb5de0 /spec
parentb539ac1d619c0aafe5988ab8b125a8b43b14d87f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/search/user_uses_header_search_field_spec.rb22
-rw-r--r--spec/frontend/repository/components/__snapshots__/directory_download_links_spec.js.snap75
-rw-r--r--spec/frontend/repository/components/directory_download_links_spec.js29
-rw-r--r--spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js3
-rw-r--r--spec/initializers/database_config_spec.rb73
-rw-r--r--spec/migrations/remove_empty_github_service_templates_spec.rb55
-rw-r--r--spec/requests/api/graphql/current_user/todos_query_spec.rb12
-rw-r--r--spec/requests/api/graphql/current_user_query_spec.rb33
-rw-r--r--spec/services/clusters/update_service_spec.rb17
9 files changed, 314 insertions, 5 deletions
diff --git a/spec/features/search/user_uses_header_search_field_spec.rb b/spec/features/search/user_uses_header_search_field_spec.rb
index d386e489739..0f60cd42748 100644
--- a/spec/features/search/user_uses_header_search_field_spec.rb
+++ b/spec/features/search/user_uses_header_search_field_spec.rb
@@ -26,6 +26,16 @@ describe 'User uses header search field', :js do
end
end
+ context 'when using the keyboard shortcut' do
+ before do
+ find('body').native.send_keys('s')
+ end
+
+ it 'shows the category search dropdown' do
+ expect(page).to have_selector('.dropdown-header', text: /#{scope_name}/i)
+ end
+ end
+
context 'when clicking the search field' do
before do
page.find('#search.js-autocomplete-disabled').click
@@ -77,15 +87,21 @@ describe 'User uses header search field', :js do
end
context 'when entering text into the search field' do
- before do
+ it 'does not display the category search dropdown' do
page.within('.search-input-wrap') do
fill_in('search', with: scope_name.first(4))
end
- end
- it 'does not display the category search dropdown' do
expect(page).not_to have_selector('.dropdown-header', text: /#{scope_name}/i)
end
+
+ it 'hides the dropdown when there are no results' do
+ page.within('.search-input-wrap') do
+ fill_in('search', with: 'a_search_term_with_no_results')
+ end
+
+ expect(page).not_to have_selector('.dropdown-menu')
+ end
end
end
diff --git a/spec/frontend/repository/components/__snapshots__/directory_download_links_spec.js.snap b/spec/frontend/repository/components/__snapshots__/directory_download_links_spec.js.snap
new file mode 100644
index 00000000000..31a1cd23060
--- /dev/null
+++ b/spec/frontend/repository/components/__snapshots__/directory_download_links_spec.js.snap
@@ -0,0 +1,75 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Repository directory download links component renders downloads links for path app 1`] = `
+<section
+ class="border-top pt-1 mt-1"
+>
+ <h5
+ class="m-0 dropdown-bold-header"
+ >
+ Download this directory
+ </h5>
+
+ <div
+ class="dropdown-menu-content"
+ >
+ <div
+ class="btn-group ml-0 w-100"
+ >
+ <gllink-stub
+ class="btn btn-xs btn-primary"
+ href="http://test.com/?path=app"
+ >
+
+ zip
+
+ </gllink-stub>
+ <gllink-stub
+ class="btn btn-xs"
+ href="http://test.com/?path=app"
+ >
+
+ tar
+
+ </gllink-stub>
+ </div>
+ </div>
+</section>
+`;
+
+exports[`Repository directory download links component renders downloads links for path app/assets 1`] = `
+<section
+ class="border-top pt-1 mt-1"
+>
+ <h5
+ class="m-0 dropdown-bold-header"
+ >
+ Download this directory
+ </h5>
+
+ <div
+ class="dropdown-menu-content"
+ >
+ <div
+ class="btn-group ml-0 w-100"
+ >
+ <gllink-stub
+ class="btn btn-xs btn-primary"
+ href="http://test.com/?path=app/assets"
+ >
+
+ zip
+
+ </gllink-stub>
+ <gllink-stub
+ class="btn btn-xs"
+ href="http://test.com/?path=app/assets"
+ >
+
+ tar
+
+ </gllink-stub>
+ </div>
+ </div>
+</section>
+`;
diff --git a/spec/frontend/repository/components/directory_download_links_spec.js b/spec/frontend/repository/components/directory_download_links_spec.js
new file mode 100644
index 00000000000..4d70b44de08
--- /dev/null
+++ b/spec/frontend/repository/components/directory_download_links_spec.js
@@ -0,0 +1,29 @@
+import { shallowMount } from '@vue/test-utils';
+import DirectoryDownloadLinks from '~/repository/components/directory_download_links.vue';
+
+let vm;
+
+function factory(currentPath) {
+ vm = shallowMount(DirectoryDownloadLinks, {
+ propsData: {
+ currentPath,
+ links: [{ text: 'zip', path: 'http://test.com/' }, { text: 'tar', path: 'http://test.com/' }],
+ },
+ });
+}
+
+describe('Repository directory download links component', () => {
+ afterEach(() => {
+ vm.destroy();
+ });
+
+ it.each`
+ path
+ ${'app'}
+ ${'app/assets'}
+ `('renders downloads links for path $path', ({ path }) => {
+ factory(path);
+
+ expect(vm.element).toMatchSnapshot();
+ });
+});
diff --git a/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js b/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js
index b85e2673624..575d35c50a9 100644
--- a/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js
+++ b/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js
@@ -1,6 +1,7 @@
import Vue from 'vue';
import { formatDate } from '~/lib/utils/datetime_utility';
import { mount, createLocalVue } from '@vue/test-utils';
+import { PathIdSeparator } from 'ee/related_issues/constants';
import RelatedIssuableItem from '~/vue_shared/components/issue/related_issuable_item.vue';
import {
defaultAssignees,
@@ -12,7 +13,7 @@ describe('RelatedIssuableItem', () => {
const props = {
idKey: 1,
displayReference: 'gitlab-org/gitlab-test#1',
- pathIdSeparator: '#',
+ pathIdSeparator: PathIdSeparator.Issue,
path: `${gl.TEST_HOST}/path`,
title: 'title',
confidential: true,
diff --git a/spec/initializers/database_config_spec.rb b/spec/initializers/database_config_spec.rb
new file mode 100644
index 00000000000..a5a074f5884
--- /dev/null
+++ b/spec/initializers/database_config_spec.rb
@@ -0,0 +1,73 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'Database config initializer' do
+ subject do
+ load Rails.root.join('config/initializers/database_config.rb')
+ end
+
+ before do
+ allow(ActiveRecord::Base).to receive(:establish_connection)
+ end
+
+ context "when using Puma" do
+ let(:puma) { double('puma') }
+ let(:puma_options) { { max_threads: 8 } }
+
+ before do
+ stub_const("Puma", puma)
+ allow(puma).to receive_message_chain(:cli_config, :options).and_return(puma_options)
+ end
+
+ context "and no existing pool size is set" do
+ before do
+ stub_database_config(pool_size: nil)
+ end
+
+ it "sets it to the max number of worker threads" do
+ expect { subject }.to change { Gitlab::Database.config['pool'] }.from(nil).to(8)
+ end
+ end
+
+ context "and the existing pool size is smaller than the max number of worker threads" do
+ before do
+ stub_database_config(pool_size: 7)
+ end
+
+ it "sets it to the max number of worker threads" do
+ expect { subject }.to change { Gitlab::Database.config['pool'] }.from(7).to(8)
+ end
+ end
+
+ context "and the existing pool size is larger than the max number of worker threads" do
+ before do
+ stub_database_config(pool_size: 9)
+ end
+
+ it "keeps the configured pool size" do
+ expect { subject }.not_to change { Gitlab::Database.config['pool'] }
+ end
+ end
+ end
+
+ context "when not using Puma" do
+ before do
+ stub_database_config(pool_size: 7)
+ end
+
+ it "does nothing" do
+ expect { subject }.not_to change { Gitlab::Database.config['pool'] }
+ end
+ end
+
+ def stub_database_config(pool_size:)
+ config = {
+ 'adapter' => 'postgresql',
+ 'host' => 'db.host.com',
+ 'pool' => pool_size
+ }.compact
+
+ allow(Gitlab::Database).to receive(:config).and_return(config)
+ end
+end
diff --git a/spec/migrations/remove_empty_github_service_templates_spec.rb b/spec/migrations/remove_empty_github_service_templates_spec.rb
new file mode 100644
index 00000000000..c128c8538db
--- /dev/null
+++ b/spec/migrations/remove_empty_github_service_templates_spec.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20191021101942_remove_empty_github_service_templates.rb')
+
+describe RemoveEmptyGithubServiceTemplates, :migration do
+ subject(:migration) { described_class.new }
+
+ let(:services) do
+ table(:services).tap do |klass|
+ klass.class_eval do
+ serialize :properties, JSON
+ end
+ end
+ end
+
+ before do
+ services.delete_all
+
+ create_service(properties: nil)
+ create_service(properties: {})
+ create_service(properties: { some: :value })
+ create_service(properties: {}, template: false)
+ create_service(properties: {}, type: 'SomeType')
+ end
+
+ def all_service_properties
+ services.where(template: true, type: 'GithubService').pluck(:properties)
+ end
+
+ it 'correctly migrates up and down service templates' do
+ reversible_migration do |migration|
+ migration.before -> do
+ expect(services.count).to eq(5)
+
+ expect(all_service_properties)
+ .to match(a_collection_containing_exactly(nil, {}, { 'some' => 'value' }))
+ end
+
+ migration.after -> do
+ expect(services.count).to eq(4)
+
+ expect(all_service_properties)
+ .to match(a_collection_containing_exactly(nil, { 'some' => 'value' }))
+ end
+ end
+ end
+
+ def create_service(params)
+ data = { template: true, type: 'GithubService' }
+ data.merge!(params)
+
+ services.create!(data)
+ end
+end
diff --git a/spec/requests/api/graphql/current_user/todos_query_spec.rb b/spec/requests/api/graphql/current_user/todos_query_spec.rb
index 6817e37e64b..82deba0d92c 100644
--- a/spec/requests/api/graphql/current_user/todos_query_spec.rb
+++ b/spec/requests/api/graphql/current_user/todos_query_spec.rb
@@ -13,7 +13,7 @@ describe 'Query current user todos' do
let(:fields) do
<<~QUERY
nodes {
- id
+ #{all_graphql_fields_for('todos'.classify)}
}
QUERY
end
@@ -28,6 +28,8 @@ describe 'Query current user todos' do
post_graphql(query, current_user: current_user)
end
+ it_behaves_like 'a working graphql query'
+
it 'contains the expected ids' do
is_expected.to include(
a_hash_including('id' => commit_todo.to_global_id.to_s),
@@ -35,4 +37,12 @@ describe 'Query current user todos' do
a_hash_including('id' => merge_request_todo.to_global_id.to_s)
)
end
+
+ it 'returns Todos for all target types' do
+ is_expected.to include(
+ a_hash_including('targetType' => 'COMMIT'),
+ a_hash_including('targetType' => 'ISSUE'),
+ a_hash_including('targetType' => 'MERGEREQUEST')
+ )
+ end
end
diff --git a/spec/requests/api/graphql/current_user_query_spec.rb b/spec/requests/api/graphql/current_user_query_spec.rb
new file mode 100644
index 00000000000..9db638ea59e
--- /dev/null
+++ b/spec/requests/api/graphql/current_user_query_spec.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'getting project information' do
+ include GraphqlHelpers
+
+ let(:query) do
+ graphql_query_for('currentUser', {}, 'name')
+ end
+
+ subject { graphql_data['currentUser'] }
+
+ before do
+ post_graphql(query, current_user: current_user)
+ end
+
+ context 'when there is a current_user' do
+ set(:current_user) { create(:user) }
+
+ it_behaves_like 'a working graphql query'
+
+ it { is_expected.to include('name' => current_user.name) }
+ end
+
+ context 'when there is no current_user' do
+ let(:current_user) { nil }
+
+ it_behaves_like 'a working graphql query'
+
+ it { is_expected.to be_nil }
+ end
+end
diff --git a/spec/services/clusters/update_service_spec.rb b/spec/services/clusters/update_service_spec.rb
index 8c2d8c9246e..fdbed4fa5d8 100644
--- a/spec/services/clusters/update_service_spec.rb
+++ b/spec/services/clusters/update_service_spec.rb
@@ -138,6 +138,23 @@ describe Clusters::UpdateService do
expect(cluster.management_project_id).to be_nil
end
end
+
+ context 'cluster already has a management project set' do
+ before do
+ cluster.update!(management_project: create(:project))
+ end
+
+ let(:params) do
+ { management_project_id: '' }
+ end
+
+ it 'unsets management_project_id' do
+ is_expected.to eq(true)
+
+ cluster.reload
+ expect(cluster.management_project_id).to be_nil
+ end
+ end
end
context 'project cluster' do