diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/profiles/user_edit_profile_spec.rb | 1 | ||||
-rw-r--r-- | spec/features/users/show_spec.rb | 2 | ||||
-rw-r--r-- | spec/frontend/vue_shared/components/user_popover/user_popover_spec.js | 10 | ||||
-rw-r--r-- | spec/lib/gitlab/database/migration_helpers_spec.rb | 55 | ||||
-rw-r--r-- | spec/lib/gitlab/usage/metric_definition_spec.rb | 3 | ||||
-rw-r--r-- | spec/models/user_detail_spec.rb | 25 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 1 |
7 files changed, 63 insertions, 34 deletions
diff --git a/spec/features/profiles/user_edit_profile_spec.rb b/spec/features/profiles/user_edit_profile_spec.rb index d941988d12f..3153bef966e 100644 --- a/spec/features/profiles/user_edit_profile_spec.rb +++ b/spec/features/profiles/user_edit_profile_spec.rb @@ -45,7 +45,6 @@ RSpec.describe 'User edit profile' do twitter: 'testtwitter', website_url: 'testurl', bio: 'I <3 GitLab :tada:', - bio_html: '<p data-sourcepos="1:1-1:18" dir="auto">I <3 GitLab <gl-emoji title="party popper" data-name="tada" data-unicode-version="6.0">🎉</gl-emoji></p>', job_title: 'Frontend Engineer', organization: 'GitLab' ) diff --git a/spec/features/users/show_spec.rb b/spec/features/users/show_spec.rb index 6f66cf5e3ae..e629d329033 100644 --- a/spec/features/users/show_spec.rb +++ b/spec/features/users/show_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'User page' do include ExternalAuthorizationServiceHelpers - let_it_be(:user) { create(:user, bio: '**Lorem** _ipsum_ dolor sit [amet](https://example.com)') } + let_it_be(:user) { create(:user, bio: '<b>Lorem</b> <i>ipsum</i> dolor sit <a href="https://example.com">amet</a>') } subject(:visit_profile) { visit(user_path(user)) } diff --git a/spec/frontend/vue_shared/components/user_popover/user_popover_spec.js b/spec/frontend/vue_shared/components/user_popover/user_popover_spec.js index 538e67ef354..3080045e0b1 100644 --- a/spec/frontend/vue_shared/components/user_popover/user_popover_spec.js +++ b/spec/frontend/vue_shared/components/user_popover/user_popover_spec.js @@ -94,7 +94,7 @@ describe('User Popover Component', () => { const bio = 'My super interesting bio'; it('should show only bio if work information is not available', () => { - const user = { ...DEFAULT_PROPS.user, bio, bioHtml: bio }; + const user = { ...DEFAULT_PROPS.user, bio }; createWrapper({ user }); @@ -117,7 +117,6 @@ describe('User Popover Component', () => { const user = { ...DEFAULT_PROPS.user, bio, - bioHtml: bio, workInformation: 'Frontend Engineer at GitLab', }; @@ -127,16 +126,15 @@ describe('User Popover Component', () => { expect(findWorkInformation().text()).toBe('Frontend Engineer at GitLab'); }); - it('should not encode special characters in bio', () => { + it('should encode special characters in bio', () => { const user = { ...DEFAULT_PROPS.user, - bio: 'I like CSS', - bioHtml: 'I like <b>CSS</b>', + bio: 'I like <b>CSS</b>', }; createWrapper({ user }); - expect(findBio().html()).toContain('I like <b>CSS</b>'); + expect(findBio().html()).toContain('I like <b>CSS</b>'); }); it('shows icon for bio', () => { diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb index 9f9aef77de7..bc417a6b554 100644 --- a/spec/lib/gitlab/database/migration_helpers_spec.rb +++ b/spec/lib/gitlab/database/migration_helpers_spec.rb @@ -1886,6 +1886,61 @@ RSpec.describe Gitlab::Database::MigrationHelpers do end end + describe '#restore_conversion_of_integer_to_bigint' do + let(:table) { :test_table } + let(:column) { :id } + let(:tmp_column) { model.convert_to_bigint_column(column) } + + before do + model.create_table table, id: false do |t| + t.bigint :id, primary_key: true + t.bigint :build_id, null: false + t.timestamps + end + end + + context 'when the target table does not exist' do + it 'raises an error' do + expect { model.restore_conversion_of_integer_to_bigint(:this_table_is_not_real, column) } + .to raise_error('Table this_table_is_not_real does not exist') + end + end + + context 'when the column to migrate does not exist' do + it 'raises an error' do + expect { model.restore_conversion_of_integer_to_bigint(table, :this_column_is_not_real) } + .to raise_error(ArgumentError, "Column this_column_is_not_real does not exist on #{table}") + end + end + + context 'when a single column is given' do + let(:column_to_convert) { 'id' } + let(:temporary_column) { model.convert_to_bigint_column(column_to_convert) } + + it 'creates the correct columns and installs the trigger' do + expect(model).to receive(:add_column).with(table, temporary_column, :int, default: 0, null: false) + + expect(model).to receive(:install_rename_triggers).with(table, [column_to_convert], [temporary_column]) + + model.restore_conversion_of_integer_to_bigint(table, column_to_convert) + end + end + + context 'when multiple columns are given' do + let(:columns_to_convert) { %i[id build_id] } + let(:temporary_columns) { columns_to_convert.map { |column| model.convert_to_bigint_column(column) } } + + it 'creates the correct columns and installs the trigger' do + expect(model).to receive(:add_column).with(table, temporary_columns[0], :int, default: 0, null: false) + expect(model).to receive(:add_column).with(table, temporary_columns[1], :int, default: 0, null: false) + + expect(model).to receive(:install_rename_triggers).with(table, columns_to_convert, temporary_columns) + + model.restore_conversion_of_integer_to_bigint(table, columns_to_convert) + end + end + end + describe '#revert_initialize_conversion_of_integer_to_bigint' do let(:table) { :test_table } diff --git a/spec/lib/gitlab/usage/metric_definition_spec.rb b/spec/lib/gitlab/usage/metric_definition_spec.rb index f19e893762f..6406c0b5458 100644 --- a/spec/lib/gitlab/usage/metric_definition_spec.rb +++ b/spec/lib/gitlab/usage/metric_definition_spec.rb @@ -10,6 +10,7 @@ RSpec.describe Gitlab::Usage::MetricDefinition do product_category: 'collection', product_stage: 'growth', status: 'active', + milestone: '14.1', default_generation: 'generation_1', key_path: 'uuid', product_group: 'group::product analytics', @@ -64,6 +65,7 @@ RSpec.describe Gitlab::Usage::MetricDefinition do :value_type | nil :value_type | 'test' :status | nil + :milestone | nil :data_category | nil :key_path | nil :product_group | nil @@ -190,6 +192,7 @@ RSpec.describe Gitlab::Usage::MetricDefinition do product_category: 'collection', product_stage: 'growth', status: 'active', + milestone: '14.1', default_generation: 'generation_1', key_path: 'counter.category.event', product_group: 'group::product analytics', diff --git a/spec/models/user_detail_spec.rb b/spec/models/user_detail_spec.rb index 3c87dcdcbd9..ba7ea3f7ce2 100644 --- a/spec/models/user_detail_spec.rb +++ b/spec/models/user_detail_spec.rb @@ -25,29 +25,4 @@ RSpec.describe UserDetail do it { is_expected.to validate_length_of(:bio).is_at_most(255) } end end - - describe '#bio_html' do - let(:user) { create(:user, bio: 'some **bio**') } - - subject { user.user_detail.bio_html } - - it 'falls back to #bio when the html representation is missing' do - user.user_detail.update!(bio_html: nil) - - expect(subject).to eq(user.user_detail.bio) - end - - it 'stores rendered html' do - expect(subject).to include('some <strong>bio</strong>') - end - - it 'does not try to set the value when the column is not there' do - without_bio_html_column = UserDetail.column_names - ['bio_html'] - - expect(described_class).to receive(:column_names).at_least(:once).and_return(without_bio_html_column) - expect(user.user_detail).not_to receive(:bio_html=) - - subject - end - end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index b41f65d62bd..263a2f219f2 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -82,7 +82,6 @@ RSpec.describe User do it { is_expected.to delegate_method(:bio).to(:user_detail).allow_nil } it { is_expected.to delegate_method(:bio=).to(:user_detail).with_arguments(:args).allow_nil } - it { is_expected.to delegate_method(:bio_html).to(:user_detail).allow_nil } end describe 'associations' do |