diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-13 12:15:32 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-13 12:15:32 +0300 |
commit | 5d0c43f60d96dfa436edd9a248100b935c05edf1 (patch) | |
tree | 460f7552a41be4f7140b5603601743ba47fcb1f9 /spec | |
parent | 03d085654717ea2f4a884f9286d56cc9e6381f4e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/ci/builds.rb | 5 | ||||
-rw-r--r-- | spec/frontend/boards/components/board_content_sidebar_spec.js | 20 | ||||
-rw-r--r-- | spec/lib/gitlab/gpg/commit_spec.rb | 24 | ||||
-rw-r--r-- | spec/models/ci/build_spec.rb | 10 | ||||
-rw-r--r-- | spec/models/ci/freeze_period_spec.rb | 5 | ||||
-rw-r--r-- | spec/models/ci/resource_group_spec.rb | 5 | ||||
-rw-r--r-- | spec/services/ci/play_build_service_spec.rb | 14 | ||||
-rw-r--r-- | spec/support/shared_examples/views/registration_features_prompt_shared_examples.rb | 27 | ||||
-rw-r--r-- | spec/views/groups/edit.html.haml_spec.rb | 16 |
9 files changed, 71 insertions, 55 deletions
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index d1a9ace605a..1d5df505743 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -597,6 +597,11 @@ FactoryBot.define do failure_reason { 13 } end + trait :deployment_rejected do + failed + failure_reason { 22 } + end + trait :with_runner_session do after(:build) do |build| build.build_runner_session(url: 'https://localhost') diff --git a/spec/frontend/boards/components/board_content_sidebar_spec.js b/spec/frontend/boards/components/board_content_sidebar_spec.js index 7b176cea2a3..368c7d561f8 100644 --- a/spec/frontend/boards/components/board_content_sidebar_spec.js +++ b/spec/frontend/boards/components/board_content_sidebar_spec.js @@ -9,6 +9,7 @@ import BoardContentSidebar from '~/boards/components/board_content_sidebar.vue'; import BoardSidebarTitle from '~/boards/components/sidebar/board_sidebar_title.vue'; import { ISSUABLE } from '~/boards/constants'; import SidebarDateWidget from '~/sidebar/components/date/sidebar_date_widget.vue'; +import SidebarSeverity from '~/sidebar/components/severity/sidebar_severity.vue'; import SidebarSubscriptionsWidget from '~/sidebar/components/subscriptions/sidebar_subscriptions_widget.vue'; import SidebarTodoWidget from '~/sidebar/components/todo_toggle/sidebar_todo_widget.vue'; import SidebarLabelsWidget from '~/vue_shared/components/sidebar/labels_select_widget/labels_select_root.vue'; @@ -96,7 +97,7 @@ describe('BoardContentSidebar', () => { }); it('confirms we render MountingPortal', () => { - expect(wrapper.find(MountingPortal).props()).toMatchObject({ + expect(wrapper.findComponent(MountingPortal).props()).toMatchObject({ mountTo: '#js-right-sidebar-portal', append: true, name: 'board-content-sidebar', @@ -141,6 +142,10 @@ describe('BoardContentSidebar', () => { ); }); + it('does not render SidebarSeverity', () => { + expect(wrapper.findComponent(SidebarSeverity).exists()).toBe(false); + }); + describe('when we emit close', () => { let toggleBoardItem; @@ -160,4 +165,17 @@ describe('BoardContentSidebar', () => { }); }); }); + + describe('incident sidebar', () => { + beforeEach(() => { + createStore({ + mockGetters: { activeBoardItem: () => ({ ...mockIssue, epic: null, type: 'INCIDENT' }) }, + }); + createComponent(); + }); + + it('renders SidebarSeverity', () => { + expect(wrapper.findComponent(SidebarSeverity).exists()).toBe(true); + }); + }); }); diff --git a/spec/lib/gitlab/gpg/commit_spec.rb b/spec/lib/gitlab/gpg/commit_spec.rb index 20d5972bd88..9c399e78d80 100644 --- a/spec/lib/gitlab/gpg/commit_spec.rb +++ b/spec/lib/gitlab/gpg/commit_spec.rb @@ -233,30 +233,6 @@ RSpec.describe Gitlab::Gpg::Commit do verification_status: 'multiple_signatures' ) end - - context 'when feature flag is disabled' do - before do - stub_feature_flags(multiple_gpg_signatures: false) - end - - it 'returns an valid signature' do - verified_signature = double('verified-signature', fingerprint: GpgHelpers::User1.fingerprint, valid?: true) - allow(GPGME::Crypto).to receive(:new).and_return(crypto) - allow(crypto).to receive(:verify).and_yield(verified_signature).and_yield(verified_signature) - - signature = described_class.new(commit).signature - - expect(signature).to have_attributes( - commit_sha: commit_sha, - project: project, - gpg_key: gpg_key, - gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid, - gpg_key_user_name: GpgHelpers::User1.names.first, - gpg_key_user_email: GpgHelpers::User1.emails.first, - verification_status: 'verified' - ) - end - end end context 'commit signed with a subkey' do diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 9d1fa006cf8..9db6fe0279a 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -2002,6 +2002,16 @@ RSpec.describe Ci::Build do it { is_expected.not_to be_retryable } end + + context 'when build is waiting for deployment approval' do + subject { build_stubbed(:ci_build, :manual, environment: 'production') } + + before do + create(:deployment, :blocked, deployable: subject) + end + + it { is_expected.not_to be_retryable } + end end end diff --git a/spec/models/ci/freeze_period_spec.rb b/spec/models/ci/freeze_period_spec.rb index f7f840c6696..b9bf1657e28 100644 --- a/spec/models/ci/freeze_period_spec.rb +++ b/spec/models/ci/freeze_period_spec.rb @@ -5,6 +5,11 @@ require 'spec_helper' RSpec.describe Ci::FreezePeriod, type: :model do subject { build(:ci_freeze_period) } + it_behaves_like 'cleanup by a loose foreign key' do + let!(:parent) { create(:project) } + let!(:model) { create(:ci_freeze_period, project: parent) } + end + let(:invalid_cron) { '0 0 0 * *' } it { is_expected.to belong_to(:project) } diff --git a/spec/models/ci/resource_group_spec.rb b/spec/models/ci/resource_group_spec.rb index aae16157fbf..76e74f3193c 100644 --- a/spec/models/ci/resource_group_spec.rb +++ b/spec/models/ci/resource_group_spec.rb @@ -3,6 +3,11 @@ require 'spec_helper' RSpec.describe Ci::ResourceGroup do + it_behaves_like 'cleanup by a loose foreign key' do + let!(:parent) { create(:project) } + let!(:model) { create(:ci_resource_group, project: parent) } + end + describe 'validation' do it 'valids when key includes allowed character' do resource_group = build(:ci_resource_group, key: 'test') diff --git a/spec/services/ci/play_build_service_spec.rb b/spec/services/ci/play_build_service_spec.rb index 34f77260334..85ef8b60af4 100644 --- a/spec/services/ci/play_build_service_spec.rb +++ b/spec/services/ci/play_build_service_spec.rb @@ -122,7 +122,7 @@ RSpec.describe Ci::PlayBuildService, '#execute' do end context 'when build is not a playable manual action' do - let(:build) { create(:ci_build, when: :manual, pipeline: pipeline) } + let(:build) { create(:ci_build, :success, pipeline: pipeline) } let!(:branch) { create(:protected_branch, :developers_can_merge, name: build.ref, project: project) } it 'duplicates the build' do @@ -138,6 +138,18 @@ RSpec.describe Ci::PlayBuildService, '#execute' do expect(build.user).not_to eq user expect(duplicate.user).to eq user end + + context 'and is not retryable' do + let(:build) { create(:ci_build, :deployment_rejected, pipeline: pipeline) } + + it 'does not duplicate the build' do + expect { service.execute(build) }.not_to change { Ci::Build.count } + end + + it 'does not enqueue the build' do + expect { service.execute(build) }.not_to change { build.status } + end + end end context 'when build is not action' do diff --git a/spec/support/shared_examples/views/registration_features_prompt_shared_examples.rb b/spec/support/shared_examples/views/registration_features_prompt_shared_examples.rb deleted file mode 100644 index 535d078db63..00000000000 --- a/spec/support/shared_examples/views/registration_features_prompt_shared_examples.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -RSpec.shared_examples 'renders registration features prompt' do |disabled_field, feature_title| - it 'renders a placeholder input with registration features message' do - render - - if disabled_field - expect(rendered).to have_field(disabled_field, disabled: true) - end - - expect(rendered).to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: feature_title || s_('RegistrationFeatures|use this feature') }) - expect(rendered).to have_link(s_('RegistrationFeatures|Registration Features Program')) - end -end - -RSpec.shared_examples 'does not render registration features prompt' do |disabled_field, feature_title| - it 'does not render a placeholder input with registration features message' do - render - - if disabled_field - expect(rendered).not_to have_field(disabled_field, disabled: true) - end - - expect(rendered).not_to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: feature_title || s_('RegistrationFeatures|use this feature') }) - expect(rendered).not_to have_link(s_('RegistrationFeatures|Registration Features Program')) - end -end diff --git a/spec/views/groups/edit.html.haml_spec.rb b/spec/views/groups/edit.html.haml_spec.rb index 748fe986d43..eaa909a5da0 100644 --- a/spec/views/groups/edit.html.haml_spec.rb +++ b/spec/views/groups/edit.html.haml_spec.rb @@ -139,7 +139,13 @@ RSpec.describe 'groups/edit.html.haml' do stub_application_setting(usage_ping_enabled: false) end - it_behaves_like 'renders registration features prompt', :group_disabled_ip_restriction_ranges + it 'renders a placeholder input with registration features message' do + render + + expect(rendered).to have_field(:group_disabled_ip_restriction_ranges, disabled: true) + expect(rendered).to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|use this feature') }) + expect(rendered).to have_link(s_('RegistrationFeatures|Registration Features Program')) + end end context 'with service ping enabled' do @@ -147,7 +153,13 @@ RSpec.describe 'groups/edit.html.haml' do stub_application_setting(usage_ping_enabled: true) end - it_behaves_like 'does not render registration features prompt', :group_disabled_ip_restriction_ranges + it 'does not render a placeholder input with registration features message' do + render + + expect(rendered).not_to have_field(:group_disabled_ip_restriction_ranges, disabled: true) + expect(rendered).not_to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|use this feature') }) + expect(rendered).not_to have_link(s_('RegistrationFeatures|Registration Features Program')) + end end end end |