summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/blob/viewer/index_spec.js2
-rw-r--r--spec/frontend/cycle_analytics/stage_nav_item_spec.js152
-rw-r--r--spec/frontend/cycle_analytics/utils_spec.js30
-rw-r--r--spec/graphql/types/global_id_type_spec.rb4
-rw-r--r--spec/graphql/types/permission_types/base_permission_type_spec.rb2
-rw-r--r--spec/lib/gitlab/database_spec.rb10
-rw-r--r--spec/lib/gitlab/middleware/multipart_spec.rb3
-rw-r--r--spec/lib/gitlab/object_hierarchy_spec.rb4
-rw-r--r--spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb4
-rw-r--r--spec/support/shared_examples/metrics/active_record_subscriber_shared_examples.rb6
10 files changed, 18 insertions, 199 deletions
diff --git a/spec/frontend/blob/viewer/index_spec.js b/spec/frontend/blob/viewer/index_spec.js
index 6a24b76abc8..705c4630a68 100644
--- a/spec/frontend/blob/viewer/index_spec.js
+++ b/spec/frontend/blob/viewer/index_spec.js
@@ -3,7 +3,7 @@
import MockAdapter from 'axios-mock-adapter';
import $ from 'jquery';
import { setTestTimeout } from 'helpers/timeout';
-import BlobViewer from '~/blob/viewer/index';
+import { BlobViewer } from '~/blob/viewer/index';
import axios from '~/lib/utils/axios_utils';
const execImmediately = (callback) => {
diff --git a/spec/frontend/cycle_analytics/stage_nav_item_spec.js b/spec/frontend/cycle_analytics/stage_nav_item_spec.js
deleted file mode 100644
index d577d0b602a..00000000000
--- a/spec/frontend/cycle_analytics/stage_nav_item_spec.js
+++ /dev/null
@@ -1,152 +0,0 @@
-import { mount, shallowMount } from '@vue/test-utils';
-import StageNavItem from '~/cycle_analytics/components/stage_nav_item.vue';
-
-describe('StageNavItem', () => {
- let wrapper = null;
- const title = 'Cool stage';
- const value = '1 day';
-
- function createComponent(props, shallow = true) {
- const func = shallow ? shallowMount : mount;
- return func(StageNavItem, {
- propsData: {
- isActive: false,
- isUserAllowed: false,
- isDefaultStage: true,
- title,
- value,
- ...props,
- },
- });
- }
-
- function hasStageName() {
- const stageName = wrapper.find('.stage-name');
- expect(stageName.exists()).toBe(true);
- expect(stageName.text()).toEqual(title);
- }
-
- it('renders stage name', () => {
- wrapper = createComponent({ isUserAllowed: true });
- hasStageName();
- wrapper.destroy();
- });
-
- describe('User has access', () => {
- describe('with a value', () => {
- beforeEach(() => {
- wrapper = createComponent({ isUserAllowed: true });
- });
-
- afterEach(() => {
- wrapper.destroy();
- });
- it('renders the value for median value', () => {
- expect(wrapper.find('.stage-empty').exists()).toBe(false);
- expect(wrapper.find('.not-available').exists()).toBe(false);
- expect(wrapper.find('.stage-median').text()).toEqual(value);
- });
- });
-
- describe('without a value', () => {
- beforeEach(() => {
- wrapper = createComponent({ isUserAllowed: true, value: null });
- });
-
- afterEach(() => {
- wrapper.destroy();
- });
-
- it('has the stage-empty class', () => {
- expect(wrapper.find('.stage-empty').exists()).toBe(true);
- });
-
- it('renders Not enough data for the median value', () => {
- expect(wrapper.find('.stage-median').text()).toEqual('Not enough data');
- });
- });
- });
-
- describe('is active', () => {
- beforeEach(() => {
- wrapper = createComponent({ isActive: true }, false);
- });
-
- afterEach(() => {
- wrapper.destroy();
- });
- it('has the active class', () => {
- expect(wrapper.find('.stage-nav-item').classes('active')).toBe(true);
- });
- });
-
- describe('is not active', () => {
- beforeEach(() => {
- wrapper = createComponent();
- });
-
- afterEach(() => {
- wrapper.destroy();
- });
- it('emits the `select` event when clicked', () => {
- expect(wrapper.emitted().select).toBeUndefined();
- wrapper.trigger('click');
- return wrapper.vm.$nextTick(() => {
- expect(wrapper.emitted().select.length).toBe(1);
- });
- });
- });
-
- describe('User does not have access', () => {
- beforeEach(() => {
- wrapper = createComponent({ isUserAllowed: false }, false);
- });
-
- afterEach(() => {
- wrapper.destroy();
- });
- it('renders stage name', () => {
- hasStageName();
- });
-
- it('has class not-available', () => {
- expect(wrapper.find('.stage-empty').exists()).toBe(false);
- expect(wrapper.find('.not-available').exists()).toBe(true);
- });
-
- it('renders Not available for the median value', () => {
- expect(wrapper.find('.stage-median').text()).toBe('Not available');
- });
- it('does not render options menu', () => {
- expect(wrapper.find('[data-testid="more-actions-toggle"]').exists()).toBe(false);
- });
- });
-
- describe('User can edit stages', () => {
- beforeEach(() => {
- wrapper = createComponent({ isUserAllowed: true }, false);
- });
-
- afterEach(() => {
- wrapper.destroy();
- });
- it('renders stage name', () => {
- hasStageName();
- });
-
- it('does not render options menu', () => {
- expect(wrapper.find('[data-testid="more-actions-toggle"]').exists()).toBe(false);
- });
-
- it('can not edit the stage', () => {
- expect(wrapper.text()).not.toContain('Edit stage');
- });
- it('can not remove the stage', () => {
- expect(wrapper.text()).not.toContain('Remove stage');
- });
-
- it('can not hide the stage', () => {
- expect(wrapper.text()).not.toContain('Hide stage');
- });
- });
-});
diff --git a/spec/frontend/cycle_analytics/utils_spec.js b/spec/frontend/cycle_analytics/utils_spec.js
index 1fecdfc0539..b8bc2bf512a 100644
--- a/spec/frontend/cycle_analytics/utils_spec.js
+++ b/spec/frontend/cycle_analytics/utils_spec.js
@@ -1,6 +1,5 @@
import { useFakeDate } from 'helpers/fake_date';
import {
- decorateEvents,
decorateData,
transformStagesForPathNavigation,
timeSummaryForPathNavigation,
@@ -13,7 +12,6 @@ import {
selectedStage,
rawData,
convertedData,
- rawEvents,
allowedStages,
stageMedians,
pathNavIssueMetric,
@@ -21,34 +19,6 @@ import {
} from './mock_data';
describe('Value stream analytics utils', () => {
- describe('decorateEvents', () => {
- const [result] = decorateEvents(rawEvents, selectedStage);
- const eventKeys = Object.keys(result);
- const authorKeys = Object.keys(result.author);
- it('will return the same number of events', () => {
- expect(decorateEvents(rawEvents, selectedStage).length).toBe(rawEvents.length);
- });
-
- it('will set all the required event fields', () => {
- ['totalTime', 'author', 'createdAt', 'shortSha', 'commitUrl'].forEach((key) => {
- expect(eventKeys).toContain(key);
- });
- ['webUrl', 'avatarUrl'].forEach((key) => {
- expect(authorKeys).toContain(key);
- });
- });
-
- it('will remove unused fields', () => {
- ['total_time', 'created_at', 'short_sha', 'commit_url'].forEach((key) => {
- expect(eventKeys).not.toContain(key);
- });
-
- ['web_url', 'avatar_url'].forEach((key) => {
- expect(authorKeys).not.toContain(key);
- });
- });
- });
-
describe('decorateData', () => {
const result = decorateData(rawData);
it('returns the summary data', () => {
diff --git a/spec/graphql/types/global_id_type_spec.rb b/spec/graphql/types/global_id_type_spec.rb
index cdf09dd9cc9..4efa3018dad 100644
--- a/spec/graphql/types/global_id_type_spec.rb
+++ b/spec/graphql/types/global_id_type_spec.rb
@@ -255,7 +255,7 @@ RSpec.describe Types::GlobalIDType do
query(GraphQL.parse(gql_query), vars).result
end
- all_types = [::GraphQL::ID_TYPE, ::Types::GlobalIDType, ::Types::GlobalIDType[::Project]]
+ all_types = [::GraphQL::Types::ID, ::Types::GlobalIDType, ::Types::GlobalIDType[::Project]]
shared_examples 'a working query' do
# Simplified schema to test compatibility
@@ -284,7 +284,7 @@ RSpec.describe Types::GlobalIDType do
# This is needed so that all types are always registered as input types
field :echo, String, null: true do
- argument :id, ::GraphQL::ID_TYPE, required: false
+ argument :id, ::GraphQL::Types::ID, required: false
argument :gid, ::Types::GlobalIDType, required: false
argument :pid, ::Types::GlobalIDType[::Project], required: false
end
diff --git a/spec/graphql/types/permission_types/base_permission_type_spec.rb b/spec/graphql/types/permission_types/base_permission_type_spec.rb
index 68632a509ee..e4726ad0e6e 100644
--- a/spec/graphql/types/permission_types/base_permission_type_spec.rb
+++ b/spec/graphql/types/permission_types/base_permission_type_spec.rb
@@ -36,7 +36,7 @@ RSpec.describe Types::PermissionTypes::BasePermissionType do
expected_keywords = {
name: :resolve_using_hash,
hash_key: :the_key,
- type: GraphQL::BOOLEAN_TYPE,
+ type: GraphQL::Types::Boolean,
description: "custom description",
null: false
}
diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb
index a834e41c019..674976daf28 100644
--- a/spec/lib/gitlab/database_spec.rb
+++ b/spec/lib/gitlab/database_spec.rb
@@ -487,19 +487,19 @@ RSpec.describe Gitlab::Database do
end
end
- describe '.dbname' do
- it 'returns the dbname for the connection' do
+ describe '.db_config_name' do
+ it 'returns the db_config name for the connection' do
connection = ActiveRecord::Base.connection
- expect(described_class.dbname(connection)).to be_a(String)
- expect(described_class.dbname(connection)).to eq(connection.pool.db_config.database)
+ expect(described_class.db_config_name(connection)).to be_a(String)
+ expect(described_class.db_config_name(connection)).to eq(connection.pool.db_config.name)
end
context 'when the pool is a NullPool' do
it 'returns unknown' do
connection = double(:active_record_connection, pool: ActiveRecord::ConnectionAdapters::NullPool.new)
- expect(described_class.dbname(connection)).to eq('unknown')
+ expect(described_class.db_config_name(connection)).to eq('unknown')
end
end
end
diff --git a/spec/lib/gitlab/middleware/multipart_spec.rb b/spec/lib/gitlab/middleware/multipart_spec.rb
index 65ec3535271..294a5ee82ed 100644
--- a/spec/lib/gitlab/middleware/multipart_spec.rb
+++ b/spec/lib/gitlab/middleware/multipart_spec.rb
@@ -77,7 +77,8 @@ RSpec.describe Gitlab::Middleware::Multipart do
result = subject
expect(result[0]).to eq(400)
- expect(result[2]).to include('insecure path used')
+ expect(result[2]).to be_a(Array)
+ expect(result[2].first).to include('insecure path used')
end
end
end
diff --git a/spec/lib/gitlab/object_hierarchy_spec.rb b/spec/lib/gitlab/object_hierarchy_spec.rb
index 64161fbafdd..86d09f4601c 100644
--- a/spec/lib/gitlab/object_hierarchy_spec.rb
+++ b/spec/lib/gitlab/object_hierarchy_spec.rb
@@ -23,7 +23,7 @@ RSpec.describe Gitlab::ObjectHierarchy do
end
it 'can find ancestors upto a certain level' do
- relation = described_class.new(Group.where(id: child2), options: options).base_and_ancestors(upto: child1)
+ relation = described_class.new(Group.where(id: child2), options: options).base_and_ancestors(upto: child1.id)
expect(relation).to contain_exactly(child2)
end
@@ -143,7 +143,7 @@ RSpec.describe Gitlab::ObjectHierarchy do
end
it 'can find ancestors upto a certain level' do
- relation = described_class.new(Group.where(id: child2), options: options).ancestors(upto: child1)
+ relation = described_class.new(Group.where(id: child2), options: options).ancestors(upto: child1.id)
expect(relation).to be_empty
end
diff --git a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
index 4406b34e638..73a5f64186e 100644
--- a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
+++ b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
@@ -298,7 +298,7 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do
allow(Gitlab::Database::LoadBalancing).to receive(:enable?).and_return(true)
end
- let(:dbname) { ::Gitlab::Database.dbname(ActiveRecord::Base.connection) }
+ let(:db_config_name) { ::Gitlab::Database.db_config_name(ActiveRecord::Base.connection) }
let(:expected_end_payload_with_db) do
expected_end_payload.merge(
@@ -314,7 +314,7 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do
'db_primary_cached_count' => 0,
'db_primary_wal_count' => 0,
'db_primary_duration_s' => a_value > 0,
- "db_primary_#{dbname}_duration_s" => a_value > 0,
+ "db_primary_#{db_config_name}_duration_s" => a_value > 0,
'db_primary_wal_cached_count' => 0,
'db_replica_wal_cached_count' => 0
)
diff --git a/spec/support/shared_examples/metrics/active_record_subscriber_shared_examples.rb b/spec/support/shared_examples/metrics/active_record_subscriber_shared_examples.rb
index a84658780b9..8b21ae1101e 100644
--- a/spec/support/shared_examples/metrics/active_record_subscriber_shared_examples.rb
+++ b/spec/support/shared_examples/metrics/active_record_subscriber_shared_examples.rb
@@ -23,7 +23,7 @@ RSpec.shared_examples 'store ActiveRecord info in RequestStore' do |db_role|
db_replica_wal_cached_count: 0,
db_replica_wal_count: 0
}
- expected[:"db_primary_#{::Gitlab::Database.dbname(connection)}_duration_s"] = 0.002 if record_query
+ expected[:"db_primary_#{::Gitlab::Database.db_config_name(connection)}_duration_s"] = 0.002 if record_query
elsif db_role == :replica
expected = {
db_count: record_query ? 1 : 0,
@@ -40,7 +40,7 @@ RSpec.shared_examples 'store ActiveRecord info in RequestStore' do |db_role|
db_primary_wal_cached_count: 0,
db_primary_wal_count: 0
}
- expected[:"db_replica_#{::Gitlab::Database.dbname(connection)}_duration_s"] = 0.002 if record_query
+ expected[:"db_replica_#{::Gitlab::Database.db_config_name(connection)}_duration_s"] = 0.002 if record_query
else
expected = {
db_count: record_query ? 1 : 0,
@@ -64,7 +64,7 @@ RSpec.shared_examples 'store ActiveRecord info in RequestStore' do |db_role|
subscriber.sql(event)
connection = event.payload[:connection]
- expect(described_class.db_counter_payload).not_to include(:"db_replica_#{::Gitlab::Database.dbname(connection)}_duration_s")
+ expect(described_class.db_counter_payload).not_to include(:"db_replica_#{::Gitlab::Database.db_config_name(connection)}_duration_s")
end
end
end